|
@@ -0,0 +1,76 @@
|
|
|
+package com.chelvc.cloud.admin.controller;
|
|
|
+
|
|
|
+import com.chelvc.cloud.trade.api.dto.CouponDTO;
|
|
|
+import com.chelvc.cloud.trade.api.param.CouponModifyParam;
|
|
|
+import com.chelvc.cloud.trade.api.param.CouponPagingParam;
|
|
|
+import com.chelvc.cloud.trade.api.service.CouponService;
|
|
|
+import com.chelvc.platform.base.annotation.UnifiedResponseBody;
|
|
|
+import com.chelvc.platform.base.model.Pagination;
|
|
|
+import com.chelvc.platform.base.util.ErrorUtils;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.Min;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 优惠券接口
|
|
|
+ *
|
|
|
+ * @author 七仔
|
|
|
+ * @Date 2023/4/3
|
|
|
+ **/
|
|
|
+@Validated
|
|
|
+@RestController
|
|
|
+@UnifiedResponseBody
|
|
|
+public class CouponController {
|
|
|
+ @DubboReference
|
|
|
+ private CouponService couponService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增优惠券
|
|
|
+ *
|
|
|
+ * @param param 新增参数
|
|
|
+ * @return 优惠券主键
|
|
|
+ */
|
|
|
+ @PostMapping("/coupon")
|
|
|
+ public Long addCoupon(@RequestBody @Valid CouponModifyParam param) {
|
|
|
+ return this.couponService.addCoupon(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改优惠券
|
|
|
+ *
|
|
|
+ * @param id 优惠券主键
|
|
|
+ * @param param 修改参数
|
|
|
+ */
|
|
|
+ @PutMapping("/coupon/{id}")
|
|
|
+ public void updateCoupon(@PathVariable("id") @Min(value = 1, message = "优惠券主键不能小于1") Long id,
|
|
|
+ @RequestBody @Valid CouponModifyParam param) {
|
|
|
+ this.couponService.updateCoupon(id, param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取优惠券信息
|
|
|
+ *
|
|
|
+ * @param id 商品分类主键
|
|
|
+ * @return 商品分类信息
|
|
|
+ */
|
|
|
+ @GetMapping("/coupon/{id}")
|
|
|
+ public CouponDTO getCoupon(@PathVariable("id") @Min(value = 1, message = "优惠券主键不能小于1") Long id) {
|
|
|
+ CouponDTO coupon = this.couponService.getCoupon(id);
|
|
|
+ ErrorUtils.requireResource(coupon, "优惠券不存在");
|
|
|
+ return coupon;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询优惠券分页
|
|
|
+ *
|
|
|
+ * @param param 查询参数
|
|
|
+ * @return 优惠券分页信息
|
|
|
+ */
|
|
|
+ @GetMapping("/coupon/paging")
|
|
|
+ public Pagination<CouponDTO> getCouponPaging(@Valid CouponPagingParam param) {
|
|
|
+ return this.couponService.getCouponPaging(param);
|
|
|
+ }
|
|
|
+}
|