123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- package com.example.xiaoshiweixinback.controller;
- import com.example.xiaoshiweixinback.business.common.Constants;
- import com.example.xiaoshiweixinback.business.common.Response;
- import com.example.xiaoshiweixinback.business.common.base.Records;
- import com.example.xiaoshiweixinback.entity.assoPersonVoucher.PersonVoucherQueryDTO;
- import com.example.xiaoshiweixinback.entity.assoPersonVoucher.SendVoucherToPersonVO;
- import com.example.xiaoshiweixinback.entity.vouchar.*;
- import com.example.xiaoshiweixinback.service.AssoPersonVoucherService;
- import com.example.xiaoshiweixinback.service.VoucherService;
- import io.swagger.v3.oas.annotations.Operation;
- import io.swagger.v3.oas.models.security.SecurityScheme;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- /**
- * 用户管理模块
- */
- @Slf4j
- @RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/voucherManage")
- @RestController
- @RequiredArgsConstructor
- public class VoucherManageController {
- private final VoucherService voucherService;
- private final AssoPersonVoucherService assoPersonVoucherService;
- @Operation(summary = "添加优惠券")
- @PostMapping("/addVoucher")
- public Response addVoucher (@RequestBody VoucherAddDTO voucherAddDTO) {
- Integer id= voucherService.addVoucher(voucherAddDTO);
- return Response.success(id);
- }
- @Operation(summary = "编辑优惠券")
- @PostMapping("/editVoucher")
- public Response editVoucher (@RequestBody VoucherUpdateDTO voucherUpdateDTO) {
- Integer id= voucherService.editVoucher(voucherUpdateDTO);
- return Response.success(id);
- }
- @Operation(summary = "查询优惠券")
- @PostMapping("/queryVoucher")
- public Response queryVoucher (@RequestBody VoucherQueryDTO voucherQueryDTO) {
- Records records =new Records();
- try {
- records = voucherService.queryVector(voucherQueryDTO);
- }
- catch (Exception e){
- e.printStackTrace();
- return Response.error("请求失败");
- }
- return Response.success(records);
- }
- @Operation(summary = "下架优惠券")
- @PostMapping("/updateBatchVoucher")
- public Response updateBatchVoucher (@RequestBody VoucherBatchUpdateDTO voucherBatchUpdateDTO) {
- List<Integer> ids= voucherService.updateBatchVoucher(voucherBatchUpdateDTO);
- return Response.success(true);
- }
- @Operation(summary = "查看优惠券详情")
- @GetMapping("/queryVectorDetail")
- public Response queryVectorDetail (Integer id) {
- VoucherVO voucherVO = voucherService.queryVectorDetail(id);
- return Response.success(voucherVO);
- }
- @Operation(summary = "向多个用户发放优惠券")
- @PostMapping("/sendVoucherToPerson")
- public Response sendVoucherToPerson (@RequestBody SendVoucherToPersonVO sendVoucherToPersonVO) {
- try {
- sendVoucherToPersonVO.setGetWay(0);
- assoPersonVoucherService.sendVoucherToPerson(sendVoucherToPersonVO);
- }
- catch (Exception e)
- {
- return Response.error(e.getMessage());
- }
- return Response.success(true);
- }
- @Operation(summary = "查看个人拥有的优惠券")
- @PostMapping("/queryPersonVoucher")
- public Response queryPersonVoucher (@RequestBody PersonVoucherQueryDTO personVoucherQueryDTO) {
- Records records =new Records();
- try {
- records= assoPersonVoucherService.queryPersonVoucher(personVoucherQueryDTO);
- }
- catch (Exception e)
- {e.printStackTrace();
- return Response.error(e.getMessage());
- }
- return Response.success(records);
- }
- }
|