You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

92 line
3.2 KiB

  1. package com.simple.controller;
  2. import com.github.pagehelper.PageInfo;
  3. import com.simple.common.Result;
  4. import com.simple.common.ResultData;
  5. import com.simple.domain.po.WxMsg;
  6. import com.simple.service.WxMsgService;
  7. import io.swagger.annotations.ApiImplicitParam;
  8. import io.swagger.annotations.ApiImplicitParams;
  9. import io.swagger.annotations.ApiOperation;
  10. import org.apache.log4j.Logger;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.*;
  13. import org.springframework.web.multipart.MultipartFile;
  14. import java.util.Map;
  15. @RestController
  16. @RequestMapping("wxMsg")
  17. public class WxMsgController extends BaseController
  18. {
  19. @Autowired
  20. private WxMsgService wxMsgService;
  21. private Logger logger = Logger.getLogger(WxMsgController.class);
  22. @ApiOperation("分页列表接口")
  23. @GetMapping("list")
  24. @ApiImplicitParams({
  25. @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
  26. @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
  27. public ResultData list(@ModelAttribute WxMsg wxMsg,Integer pageNum, Integer pageSize) {
  28. if (null == wxMsg) wxMsg = new WxMsg();
  29. final PageInfo<WxMsg> page = wxMsgService.listAsPage(wxMsg, pageNum, pageSize);
  30. return new ResultData(page);
  31. }
  32. @ApiOperation("新增接口")
  33. @PostMapping("add")
  34. public ResultData add(@RequestBody WxMsg wxMsg) {
  35. //Assert.notNull(wxMsg.getName(), "角色名不能为空");
  36. //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
  37. wxMsgService.saveOrUpdate(wxMsg);
  38. return new ResultData();
  39. }
  40. @ApiOperation("根据id更新接口")
  41. @PostMapping("update")
  42. public ResultData update(@RequestBody WxMsg wxMsg) {
  43. wxMsgService.saveOrUpdate(wxMsg);
  44. return new ResultData();
  45. }
  46. @ApiOperation("根据id删除接口")
  47. @GetMapping("/del")
  48. @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
  49. public ResultData delete(Long id) {
  50. wxMsgService.deleteById(id);
  51. return new ResultData(Result.SUCCESS, "删除成功", null);
  52. }
  53. @ApiOperation("根据id查询接口")
  54. @GetMapping("/findById")
  55. @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
  56. public ResultData findById(Long id) {
  57. return new ResultData(Result.SUCCESS,"查询成功",wxMsgService.getById(id));
  58. }
  59. @ApiOperation("短信接口回调")
  60. @RequestMapping("/receivemsg/{bid}")
  61. public void receivemsg(@PathVariable String bid,@RequestParam Map<String,String> param) {
  62. //解析param数据插入数据库中
  63. @GetMapping("/sendmsgbyexcel")
  64. public ResultData sendmsgbyexcel(@RequestParam("file") MultipartFile file,@ModelAttribute WxMsg wxMsg) throws Exception {
  65. if (file.isEmpty()) {
  66. return new ResultData(Result.SUCCESS,"上传文件不能为空");
  67. }
  68. return wxMsgService.sendmsgbyexcel(file,wxMsg);
  69. }
  70. @GetMapping("/sendmsgbylabel")
  71. public ResultData sendmsgbylabel(@ModelAttribute WxMsg wxMsg) throws Exception {
  72. return wxMsgService.sendmsgbylabel(wxMsg);
  73. }
  74. }