Parcourir la source

mall + promotion:
1、mock 优惠劵模版分页
2、mock 批量删除收藏

YunaiV il y a 1 an
Parent
commit
5c9a99c83e

+ 12 - 2
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/AppFavoriteController.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
+import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteBatchReqVO;
 import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO;
 import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteReqVO;
 import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO;
@@ -43,15 +44,24 @@ public class AppFavoriteController {
     }
 
     @DeleteMapping(value = "/delete")
-    @Operation(summary = "取消商品收藏")
+    @Operation(summary = "取消单个商品收藏")
     @PreAuthenticated
     public CommonResult<Boolean> deleteFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) {
         productFavoriteService.deleteFavorite(getLoginUserId(), reqVO.getSpuId());
         return success(Boolean.TRUE);
     }
 
+    @DeleteMapping(value = "/delete-list")
+    @Operation(summary = "取消多个商品收藏")
+    @PreAuthenticated
+    public CommonResult<Boolean> deleteFavoriteList(@RequestBody @Valid AppFavoriteBatchReqVO reqVO) {
+        // todo @jason:待实现
+//        productFavoriteService.deleteFavorite(getLoginUserId(), reqVO.getSpuId());
+        return success(Boolean.TRUE);
+    }
+
     @GetMapping(value = "/page")
-    @Operation(summary = "分页获取商品收藏列表")
+    @Operation(summary = "获得商品收藏分页")
     @PreAuthenticated
     public CommonResult<PageResult<AppFavoriteRespVO>> getFavoritePage(AppFavoritePageReqVO reqVO) {
         PageResult<ProductFavoriteDO> favoritePage = productFavoriteService.getFavoritePage(getLoginUserId(), reqVO);

+ 19 - 0
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteBatchReqVO.java

@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.module.product.controller.app.favorite.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import java.util.List;
+
+import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
+
+@Schema(description = "用户 APP - 商品收藏的批量 Request VO") // 用于收藏、取消收藏、获取收藏
+@Data
+public class AppFavoriteBatchReqVO {
+
+    @Schema(description = "商品 SPU 编号数组", requiredMode = REQUIRED, example = "29502")
+    @NotEmpty(message = "商品 SPU 编号数组不能为空")
+    private List<Long> spuIds;
+
+}

+ 1 - 1
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteReqVO.java

@@ -7,7 +7,7 @@ import javax.validation.constraints.NotNull;
 
 import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
 
-@Schema(description = "用户 APP - 商品收藏 Request VO") // 用于收藏、取消收藏、获取收藏
+@Schema(description = "用户 APP - 商品收藏的单个 Request VO") // 用于收藏、取消收藏、获取收藏
 @Data
 public class AppFavoriteReqVO {
 

+ 31 - 2
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java

@@ -74,11 +74,40 @@ public class AppCouponTemplateController {
         return success(list);
     }
 
-    // TODO 芋艿:待实现
+    // TODO 芋艿:待实现;和 getCouponTemplateList 类似
     @GetMapping("/page")
     @Operation(summary = "获得优惠劵模版分页")
     public CommonResult<PageResult<AppCouponTemplateRespVO>> getCouponTemplatePage(AppCouponTemplatePageReqVO pageReqVO) {
-        return null;
+        List<AppCouponTemplateRespVO> list = new ArrayList<>();
+        Random random = new Random();
+        for (int i = 0; i < 10; i++) {
+            AppCouponTemplateRespVO vo = new AppCouponTemplateRespVO();
+            vo.setId(i + 1L);
+            vo.setName("优惠劵" + (i + 1));
+            vo.setTakeLimitCount(random.nextInt(10) + 1);
+            vo.setUsePrice(random.nextInt(100) * 100);
+            vo.setValidityType(random.nextInt(2) + 1);
+            if (vo.getValidityType() == 1) {
+                vo.setValidStartTime(LocalDateTime.now().plusDays(random.nextInt(10)));
+                vo.setValidEndTime(LocalDateTime.now().plusDays(random.nextInt(20) + 10));
+            } else {
+                vo.setFixedStartTerm(random.nextInt(10));
+                vo.setFixedEndTerm(random.nextInt(10) + vo.getFixedStartTerm() + 1);
+            }
+            vo.setDiscountType(random.nextInt(2) + 1);
+            if (vo.getDiscountType() == 1) {
+                vo.setDiscountPercent(null);
+                vo.setDiscountPrice(random.nextInt(50) * 100);
+                vo.setDiscountLimitPrice(null);
+            } else {
+                vo.setDiscountPercent(random.nextInt(90) + 10);
+                vo.setDiscountPrice(null);
+                vo.setDiscountLimitPrice(random.nextInt(200) * 100);
+            }
+            vo.setTakeStatus(random.nextBoolean());
+            list.add(vo);
+        }
+        return success(new PageResult<>(list, 20L));
     }
 
 }