RepalCustomerController.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package com.winhc.repal.controller;
  2. import com.winhc.common.base.BeanResponse;
  3. import com.winhc.common.enums.CodeMsg;
  4. import com.winhc.common.model.base.VOPage;
  5. import com.winhc.repal.common.BaseController;
  6. import com.winhc.repal.enums.Dict;
  7. import com.winhc.repal.model.dto.*;
  8. import com.winhc.repal.model.vo.*;
  9. import com.winhc.repal.service.RepalBillService;
  10. import com.winhc.repal.service.RepalCustomerService;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiOperation;
  13. import io.swagger.annotations.ApiParam;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.web.bind.annotation.*;
  16. import java.util.List;
  17. /**
  18. * @author Aaron
  19. * @date 2022/4/19 13:08
  20. * @description
  21. */
  22. @Api(tags = "回款宝 客户/供应 商管理")
  23. @RestController
  24. @RequestMapping(value = "/repalCustomer")
  25. public class RepalCustomerController extends BaseController {
  26. @Autowired
  27. private RepalCustomerService repalCustomerService;
  28. @Autowired
  29. private RepalBillService repalBillService;
  30. @ApiOperation("客户/供应商下拉框")
  31. @GetMapping(value = "/list")
  32. public BeanResponse<List<RepalCustomerSimpleVO>> getCustList(@ApiParam("1客户 2供应商") @RequestParam("custType")Integer custType){
  33. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.getCustList(custType));
  34. }
  35. @ApiOperation("分页查询客户")
  36. @GetMapping(value = "/cust/page")
  37. public BeanResponse<VOPage<RepalCustomerInfoVO>> getRepalCustPage(RepalCustomerQueryDTO dto){
  38. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.find(dto.setCustType(Dict.custTypeEnum.客户.getCode()),getUser()));
  39. }
  40. @ApiOperation("添加客户")
  41. @PostMapping("/cust")
  42. public BeanResponse<RepalCustomerDetailVO> addCustomer(@RequestBody RepalCustomerDTO dto){
  43. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.addCustomer(dto.setCustType(Dict.custTypeEnum.客户.getCode()),getUser()));
  44. }
  45. @ApiOperation("修改客户")
  46. @PostMapping("/cust/modify")
  47. public BeanResponse<RepalCustomerDetailVO> modifyCustomer(@RequestBody RepalCustomerUpdateDTO dto){
  48. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.updateCustomer(dto.setCustType(Dict.custTypeEnum.客户.getCode()),getUser()));
  49. }
  50. @ApiOperation("客户详情")
  51. @GetMapping(value = "/cust/{custId}")
  52. public BeanResponse<RepalCustomerDetailVO> getRepalCustomerDetail(@PathVariable("custId")Long custId){
  53. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.getDetailById(custId,getUser(),Dict.custTypeEnum.客户.getCode()));
  54. }
  55. @ApiOperation("分页查询供应商")
  56. @GetMapping(value = "/supply/page")
  57. public BeanResponse<VOPage<RepalCustomerInfoVO>> getRepalSupplyPage(RepalCustomerQueryDTO dto){
  58. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.find(dto.setCustType(Dict.custTypeEnum.供应商.getCode()),getUser()));
  59. }
  60. @ApiOperation("添加供应商")
  61. @PostMapping("/supply")
  62. public BeanResponse<RepalCustomerDetailVO> addSupply(@RequestBody RepalCustomerDTO dto){
  63. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.addCustomer(dto.setCustType(Dict.custTypeEnum.客户.getCode()),getUser()));
  64. }
  65. @ApiOperation("修改供应商")
  66. @PostMapping("/supply/modify")
  67. public BeanResponse<RepalCustomerDetailVO> modifySupply(@RequestBody RepalCustomerUpdateDTO dto){
  68. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.updateCustomer(dto.setCustType(Dict.custTypeEnum.供应商.getCode()),getUser()));
  69. }
  70. @ApiOperation("供应商详情")
  71. @GetMapping(value = "/supply/{custId}")
  72. public BeanResponse<RepalCustomerDetailVO> getRepalSupplyDetail(@PathVariable("custId")Long custId){
  73. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.getDetailById(custId,getUser(),Dict.custTypeEnum.供应商.getCode()));
  74. }
  75. @ApiOperation("删除客户/供应商")
  76. @DeleteMapping("/{custId}")
  77. public BeanResponse<Boolean> deleteCustomer(@PathVariable("custId")Long custId){
  78. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.deleteCustomer(custId,getUser()));
  79. }
  80. @ApiOperation("获取客户下的账款列表(应收or应付)")
  81. @RequestMapping(value = "/page/cust", method = RequestMethod.GET)
  82. public BeanResponse<VOPage<RepalBillPageVO>> getCustRepalBillPage(@RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
  83. @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize,
  84. @RequestParam("custId")Long custId) {
  85. return BeanResponse.success(CodeMsg.SUCCESS, repalBillService.getCustRepalBillPage(pageNum,pageSize,custId));
  86. }
  87. @ApiOperation("查询客户联系人列表")
  88. @GetMapping("/link")
  89. public BeanResponse<List<RepalLinkVO>> queryLink(@RequestParam("custId")Long custId){
  90. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.queryLink(custId));
  91. }
  92. @ApiOperation("添加(修改)联系人")
  93. @PostMapping("/link")
  94. public BeanResponse<RepalLinkVO> updateLink(@RequestBody RepalLinkUpdateDTO dto){
  95. return BeanResponse.success(CodeMsg.SUCCESS,repalCustomerService.updateLink(dto));
  96. }
  97. }