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.
 
 
 
 
 

89 lines
3.6 KiB

  1. package com.simple.controller;
  2. import com.github.pagehelper.PageInfo;
  3. import com.simple.common.ErrorCode;
  4. import com.simple.common.Result;
  5. import com.simple.common.ResultData;
  6. import com.simple.domain.po.WxMerchant;
  7. import com.simple.domain.po.WxProfitSharingReceiver;
  8. import com.simple.service.WxMerchantService;
  9. import com.simple.service.WxProfitSharingReceiverService;
  10. import io.swagger.annotations.ApiImplicitParam;
  11. import io.swagger.annotations.ApiImplicitParams;
  12. import io.swagger.annotations.ApiOperation;
  13. import org.slf4j.Logger;
  14. import org.slf4j.LoggerFactory;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.web.bind.annotation.*;
  17. import java.util.List;
  18. @RestController
  19. @RequestMapping("wxProfitSharingReceiver")
  20. public class WxProfitSharingReceiverController extends BaseController {
  21. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  22. @Autowired
  23. private WxProfitSharingReceiverService wxProfitSharingReceiverService;
  24. @Autowired
  25. private WxMerchantService wxMerchantService;
  26. @ApiOperation("分页列表接口")
  27. @GetMapping("list")
  28. @ApiImplicitParams({
  29. @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
  30. @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
  31. public ResultData list(@ModelAttribute WxProfitSharingReceiver receiver, Integer pageNum, Integer pageSize) {
  32. if (null == receiver) receiver = new WxProfitSharingReceiver();
  33. final PageInfo<WxProfitSharingReceiver> page = wxProfitSharingReceiverService.listAsPage(receiver, pageNum, pageSize);
  34. return new ResultData(page);
  35. }
  36. @ApiOperation("新增接口")
  37. @PostMapping("add")
  38. public ResultData add(@ModelAttribute WxProfitSharingReceiver receiver) {
  39. if (receiver == null)
  40. return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
  41. if (receiver.getMerchantId() == null)
  42. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
  43. if (receiver.getReceiverType() == null)
  44. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
  45. if (receiver.getReceiverComments() == null)
  46. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
  47. if (receiver.getReceiverAccount() == null)
  48. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
  49. if (receiver.getTrueName() == null)
  50. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
  51. WxMerchant merchant = wxMerchantService.getById(receiver.getMerchantId());
  52. if (merchant == null)
  53. return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND);
  54. return wxProfitSharingReceiverService.addReceiver(merchant, receiver);
  55. }
  56. @ApiOperation("根据id删除接口")
  57. @GetMapping("del")
  58. public ResultData delete(@ModelAttribute WxProfitSharingReceiver receiver) {
  59. if (receiver == null)
  60. return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
  61. if (receiver.getMerchantId() == null)
  62. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
  63. if (receiver.getReceiverType() == null)
  64. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
  65. if (receiver.getReceiverAccount() == null)
  66. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
  67. WxMerchant merchant = wxMerchantService.getById(receiver.getMerchantId());
  68. if (merchant == null)
  69. return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND);
  70. return wxProfitSharingReceiverService.delReceiver(merchant, receiver);
  71. }
  72. }