|
|
@@ -1,9 +1,63 @@
|
|
|
package cn.seecoder.courselearning.controller;
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import cn.seecoder.courselearning.dto.CourseCouponDTO;
|
|
|
+import cn.seecoder.courselearning.dto.UniversalCouponDTO;
|
|
|
+import cn.seecoder.courselearning.dto.UserCouponDTO;
|
|
|
+import cn.seecoder.courselearning.service.CouponService;
|
|
|
+import cn.seecoder.courselearning.vo.CouponVO;
|
|
|
+import cn.seecoder.courselearning.vo.CourseOrderVO;
|
|
|
+import cn.seecoder.courselearning.vo.ResultVO;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/coupon")
|
|
|
public class CouponController {
|
|
|
+ @Resource
|
|
|
+ CouponService couponService;
|
|
|
+
|
|
|
+ // 创建通用型优惠券
|
|
|
+ @PostMapping("/create/universal")
|
|
|
+ ResultVO<CouponVO> createUniversalCoupon(@RequestBody UniversalCouponDTO universalCouponDTO) {
|
|
|
+ return couponService.createUniversalCoupon(universalCouponDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建课程型优惠券
|
|
|
+ @PostMapping("/create/course")
|
|
|
+ ResultVO<CouponVO> createCourseCoupon(@RequestBody CourseCouponDTO courseCouponDTO) {
|
|
|
+ return couponService.createCourseCoupon(courseCouponDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建用户定制化优惠券
|
|
|
+ @PostMapping("/create/universal")
|
|
|
+ ResultVO<CouponVO> createUserCoupon(@RequestBody UserCouponDTO userCouponDTO) {
|
|
|
+ return couponService.createUserCoupon(userCouponDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查看所有的网站通用型优惠券
|
|
|
+ @GetMapping("/universal")
|
|
|
+ List<CouponVO> getUniversalCoupons() {
|
|
|
+ return couponService.getUniversalCoupons();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 查看当前课程所有的课程优惠券(不含网站通用优惠券、用户定制化优惠券) 包含已经失效了的优惠活动
|
|
|
+ @GetMapping("/course/{courseId}")
|
|
|
+ List<CouponVO> getCourseCoupons(@PathVariable Integer courseId) {
|
|
|
+ return couponService.getCourseCoupons(courseId);
|
|
|
+ }
|
|
|
+
|
|
|
+// // 查询 userId 对应的用户 目前可以使用的有效的优惠券
|
|
|
+// @GetMapping("/user/{userId}")
|
|
|
+// List<CouponVO> getAllEffectiveCouponsForUser(@PathVariable Integer userId) {
|
|
|
+// return couponService.getAllEffectiveUserCoupons(userId);
|
|
|
+// }
|
|
|
+
|
|
|
+ // 查看当前用户购买此课程可生效的所有优惠
|
|
|
+ @GetMapping("/check_for_order")
|
|
|
+ List<CouponVO> getAllEffectiveCouponsForOrder(@RequestBody CourseOrderVO orderVO) {
|
|
|
+ return couponService.getAllEffectiveCouponsForOrder(orderVO);
|
|
|
+ }
|
|
|
}
|