CouponController.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package com.ygj.yuemum.controller.coupon;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.ygj.yuemum.domain.coupon.Coupon;
  4. import com.ygj.yuemum.service.coupon.CouponService;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.*;
  7. import java.util.List;
  8. import java.util.Map;
  9. @RestController
  10. public class CouponController {
  11. @Autowired
  12. private CouponService couponService;
  13. @GetMapping("/getCoupons")
  14. public String getCoupons(@RequestParam("page") Integer page,@RequestParam("limit") Integer limit) {
  15. Map<String, Object> coupons= couponService.getCoupons(page,limit);
  16. String jso = JSONObject.toJSONString(coupons);
  17. return jso;
  18. }
  19. @GetMapping("/getAllCoupons")
  20. public List<Coupon> getAllCoupons() {
  21. return couponService.getAll();
  22. }
  23. @PostMapping("/addCoupon")
  24. public int add(@ModelAttribute Coupon coupon) {
  25. return couponService.addCoupon(coupon);
  26. }
  27. @GetMapping("/deleteCoupon/{id}")
  28. public int delete(@PathVariable("id") Integer id) {
  29. return couponService.deleteCoupon(id);
  30. }
  31. @PostMapping("/updateCoupon")
  32. public int update(@ModelAttribute Coupon coupon) {
  33. return couponService.updateCoupon(coupon);
  34. }
  35. @GetMapping("/getCoupon/{id}")
  36. public Coupon getOne(@PathVariable("id") Integer id) {
  37. return couponService.getCoupon(id);
  38. }
  39. //Modoo API
  40. @GetMapping("/getNewUserCoupon") //新用户礼包
  41. public int getNewUserCoupon(@RequestParam("phone") String phone, @RequestParam("channel") Integer channel) {
  42. return couponService.getNewUserCoupon(phone,channel);
  43. }
  44. @GetMapping("/getConsultTaskCoupon") //咨询任务
  45. public int getConsultTaskCoupon(@RequestParam("phone") String phone , @RequestParam("channel") Integer channel) {
  46. return couponService.getConsultTaskCoupon(phone,channel);
  47. }
  48. @GetMapping("/getDetectionTaskCoupon") //测胎心任务
  49. public int getDetectionTaskCoupon(@RequestParam("phone") String phone , @RequestParam("channel") Integer channel) {
  50. return couponService.getDetectionTaskCoupon(phone,channel);
  51. }
  52. @GetMapping("/getRechargeTaskCoupon") //充值任务
  53. public int getRechargeTaskCoupon(@RequestParam("phone") String phone , @RequestParam("channel") Integer channel) {
  54. return couponService.getRechargeTaskCoupon(phone,channel);
  55. }
  56. }