CouponBatchController.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package com.ygj.yuemum.controller.coupon;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.ygj.yuemum.domain.coupon.CouponBatch;
  4. import com.ygj.yuemum.service.coupon.CouponBatchService;
  5. import com.ygj.yuemum.service.coupon.CouponCreateService;
  6. import io.swagger.annotations.Api;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.*;
  9. import java.util.List;
  10. import java.util.Map;
  11. @Api(tags = "代金券组相关接口")
  12. @RestController
  13. public class CouponBatchController {
  14. @Autowired
  15. private CouponBatchService couponBatchService;
  16. @Autowired
  17. private CouponCreateService couponCreateService;
  18. @GetMapping("/getCouponbatchs")
  19. public String getCouponbatchs(@RequestParam("page") Integer page,@RequestParam("limit") Integer limit) {
  20. Map<String, Object> couponBatchs= couponBatchService.getCouponBatchs(page,limit);
  21. String jso = JSONObject.toJSONString(couponBatchs);
  22. return jso;
  23. }
  24. @GetMapping("/getAllCouponBatchs")
  25. public List<CouponBatch> getAllCouponBatchs() {
  26. return couponBatchService.getAll();
  27. }
  28. @GetMapping("/selectCouponBatch")
  29. public List<CouponBatch> selectCouponBatch() {
  30. return couponBatchService.selectCouponBatch();
  31. }
  32. @PostMapping("/addCouponBatch")
  33. public int add(@ModelAttribute CouponBatch couponbatch) {
  34. return couponBatchService.addCouponBatch(couponbatch);
  35. }
  36. @GetMapping("/deleteCouponBatch")
  37. public int delete(@RequestParam("cb_code") String cb_code) {
  38. if(couponCreateService.checkCouponBatch(cb_code) > 0){
  39. return 9;
  40. } else {
  41. return couponBatchService.deleteCouponBatch(cb_code);
  42. }
  43. }
  44. @PostMapping("/updateCouponBatch")
  45. public int update(@ModelAttribute CouponBatch couponbatch) {
  46. return couponBatchService.updateCouponBatch(couponbatch);
  47. }
  48. @PostMapping("/getQCouponBatch")
  49. public String getQCouponBatch(@ModelAttribute CouponBatch couponbatch) {
  50. Map<String, Object> couponBatchs= couponBatchService.getQCouponBatch(couponbatch);
  51. String jso = JSONObject.toJSONString(couponBatchs);
  52. return jso;
  53. }
  54. @GetMapping("/getCouponBatch")
  55. public CouponBatch getOne(@RequestParam("id") Integer id) {
  56. return couponBatchService.getCouponBatch(id);
  57. }
  58. }