VoucherManageController.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package com.example.xiaoshiweixinback.controller;
  2. import com.example.xiaoshiweixinback.business.common.Constants;
  3. import com.example.xiaoshiweixinback.business.common.Response;
  4. import com.example.xiaoshiweixinback.business.common.base.Records;
  5. import com.example.xiaoshiweixinback.entity.assoPersonVoucher.PersonVoucherQueryDTO;
  6. import com.example.xiaoshiweixinback.entity.assoPersonVoucher.SendVoucherToPersonVO;
  7. import com.example.xiaoshiweixinback.entity.vouchar.*;
  8. import com.example.xiaoshiweixinback.service.AssoPersonVoucherService;
  9. import com.example.xiaoshiweixinback.service.VoucherService;
  10. import io.swagger.v3.oas.annotations.Operation;
  11. import io.swagger.v3.oas.models.security.SecurityScheme;
  12. import lombok.RequiredArgsConstructor;
  13. import lombok.extern.slf4j.Slf4j;
  14. import org.springframework.web.bind.annotation.*;
  15. import java.util.List;
  16. /**
  17. * 用户管理模块
  18. */
  19. @Slf4j
  20. @RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/voucherManage")
  21. @RestController
  22. @RequiredArgsConstructor
  23. public class VoucherManageController {
  24. private final VoucherService voucherService;
  25. private final AssoPersonVoucherService assoPersonVoucherService;
  26. @Operation(summary = "添加优惠券")
  27. @PostMapping("/addVoucher")
  28. public Response addVoucher (@RequestBody VoucherAddDTO voucherAddDTO) {
  29. Integer id= voucherService.addVoucher(voucherAddDTO);
  30. return Response.success(id);
  31. }
  32. @Operation(summary = "编辑优惠券")
  33. @PostMapping("/editVoucher")
  34. public Response editVoucher (@RequestBody VoucherUpdateDTO voucherUpdateDTO) {
  35. Integer id= voucherService.editVoucher(voucherUpdateDTO);
  36. return Response.success(id);
  37. }
  38. @Operation(summary = "查询优惠券")
  39. @PostMapping("/queryVoucher")
  40. public Response queryVoucher (@RequestBody VoucherQueryDTO voucherQueryDTO) {
  41. Records records =new Records();
  42. try {
  43. records = voucherService.queryVector(voucherQueryDTO);
  44. }
  45. catch (Exception e){
  46. e.printStackTrace();
  47. return Response.error("请求失败");
  48. }
  49. return Response.success(records);
  50. }
  51. @Operation(summary = "下架优惠券")
  52. @PostMapping("/updateBatchVoucher")
  53. public Response updateBatchVoucher (@RequestBody VoucherBatchUpdateDTO voucherBatchUpdateDTO) {
  54. List<Integer> ids= voucherService.updateBatchVoucher(voucherBatchUpdateDTO);
  55. return Response.success(true);
  56. }
  57. @Operation(summary = "查看优惠券详情")
  58. @GetMapping("/queryVectorDetail")
  59. public Response queryVectorDetail (Integer id) {
  60. VoucherVO voucherVO = voucherService.queryVectorDetail(id);
  61. return Response.success(voucherVO);
  62. }
  63. @Operation(summary = "向多个用户发放优惠券")
  64. @PostMapping("/sendVoucherToPerson")
  65. public Response sendVoucherToPerson (@RequestBody SendVoucherToPersonVO sendVoucherToPersonVO) {
  66. try {
  67. sendVoucherToPersonVO.setGetWay(0);
  68. assoPersonVoucherService.sendVoucherToPerson(sendVoucherToPersonVO);
  69. }
  70. catch (Exception e)
  71. {
  72. return Response.error(e.getMessage());
  73. }
  74. return Response.success(true);
  75. }
  76. @Operation(summary = "查看个人拥有的优惠券")
  77. @PostMapping("/queryPersonVoucher")
  78. public Response queryPersonVoucher (@RequestBody PersonVoucherQueryDTO personVoucherQueryDTO) {
  79. Records records =new Records();
  80. try {
  81. records= assoPersonVoucherService.queryPersonVoucher(personVoucherQueryDTO);
  82. }
  83. catch (Exception e)
  84. {e.printStackTrace();
  85. return Response.error(e.getMessage());
  86. }
  87. return Response.success(records);
  88. }
  89. }