Commit f6c8159dace97da29ec3feac16c8b0e2cfae6f02
1 parent
fe5c5e42
✨ MALL:简化 SPU 的 VO 转化
Showing
32 changed files
with
312 additions
and
663 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/object/BeanUtils.java
| ... | ... | @@ -21,6 +21,14 @@ public class BeanUtils { |
| 21 | 21 | return BeanUtil.toBean(source, targetClass); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | + public static <T> T toBean(Object source, Class<T> targetClass, Consumer<T> peek) { | |
| 25 | + T target = toBean(source, targetClass); | |
| 26 | + if (target != null) { | |
| 27 | + peek.accept(target); | |
| 28 | + } | |
| 29 | + return target; | |
| 30 | + } | |
| 31 | + | |
| 24 | 32 | public static <S, T> List<T> toBean(List<S> source, Class<T> targetType) { |
| 25 | 33 | if (source == null) { |
| 26 | 34 | return null; |
| ... | ... | @@ -28,6 +36,14 @@ public class BeanUtils { |
| 28 | 36 | return CollectionUtils.convertList(source, s -> toBean(s, targetType)); |
| 29 | 37 | } |
| 30 | 38 | |
| 39 | + public static <S, T> List<T> toBean(List<S> source, Class<T> targetType, Consumer<T> peek) { | |
| 40 | + List<T> list = toBean(source, targetType); | |
| 41 | + if (list != null) { | |
| 42 | + list.forEach(peek); | |
| 43 | + } | |
| 44 | + return list; | |
| 45 | + } | |
| 46 | + | |
| 31 | 47 | public static <S, T> PageResult<T> toBean(PageResult<S> source, Class<T> targetType) { |
| 32 | 48 | return toBean(source, targetType, null); |
| 33 | 49 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.product.api.sku; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 3 | 4 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 4 | 5 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 5 | -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; | |
| 6 | 6 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 7 | 7 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; |
| 8 | +import jakarta.annotation.Resource; | |
| 8 | 9 | import org.springframework.stereotype.Service; |
| 9 | 10 | import org.springframework.validation.annotation.Validated; |
| 10 | 11 | |
| 11 | -import jakarta.annotation.Resource; | |
| 12 | 12 | import java.util.Collection; |
| 13 | 13 | import java.util.List; |
| 14 | 14 | |
| ... | ... | @@ -28,19 +28,19 @@ public class ProductSkuApiImpl implements ProductSkuApi { |
| 28 | 28 | @Override |
| 29 | 29 | public ProductSkuRespDTO getSku(Long id) { |
| 30 | 30 | ProductSkuDO sku = productSkuService.getSku(id); |
| 31 | - return ProductSkuConvert.INSTANCE.convert02(sku); | |
| 31 | + return BeanUtils.toBean(sku, ProductSkuRespDTO.class); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | @Override |
| 35 | 35 | public List<ProductSkuRespDTO> getSkuList(Collection<Long> ids) { |
| 36 | 36 | List<ProductSkuDO> skus = productSkuService.getSkuList(ids); |
| 37 | - return ProductSkuConvert.INSTANCE.convertList04(skus); | |
| 37 | + return BeanUtils.toBean(skus, ProductSkuRespDTO.class); | |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | @Override |
| 41 | 41 | public List<ProductSkuRespDTO> getSkuListBySpuId(Collection<Long> spuIds) { |
| 42 | 42 | List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spuIds); |
| 43 | - return ProductSkuConvert.INSTANCE.convertList04(skus); | |
| 43 | + return BeanUtils.toBean(skus, ProductSkuRespDTO.class); | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | @Override | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.product.api.spu; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.collection.CollectionUtil; | |
| 3 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 4 | 4 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 5 | -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; | |
| 5 | +import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | |
| 6 | 6 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| 7 | +import jakarta.annotation.Resource; | |
| 7 | 8 | import org.springframework.stereotype.Service; |
| 8 | 9 | import org.springframework.validation.annotation.Validated; |
| 9 | 10 | |
| 10 | -import jakarta.annotation.Resource; | |
| 11 | 11 | import java.util.Collection; |
| 12 | -import java.util.Collections; | |
| 13 | 12 | import java.util.List; |
| 14 | 13 | |
| 15 | 14 | /** |
| ... | ... | @@ -27,17 +26,20 @@ public class ProductSpuApiImpl implements ProductSpuApi { |
| 27 | 26 | |
| 28 | 27 | @Override |
| 29 | 28 | public List<ProductSpuRespDTO> getSpuList(Collection<Long> ids) { |
| 30 | - return ProductSpuConvert.INSTANCE.convertList2(spuService.getSpuList(ids)); | |
| 29 | + List<ProductSpuDO> spus = spuService.getSpuList(ids); | |
| 30 | + return BeanUtils.toBean(spus, ProductSpuRespDTO.class); | |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | @Override |
| 34 | 34 | public List<ProductSpuRespDTO> validateSpuList(Collection<Long> ids) { |
| 35 | - return ProductSpuConvert.INSTANCE.convertList2(spuService.validateSpuList(ids)); | |
| 35 | + List<ProductSpuDO> spus = spuService.validateSpuList(ids); | |
| 36 | + return BeanUtils.toBean(spus, ProductSpuRespDTO.class); | |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | 39 | @Override |
| 39 | 40 | public ProductSpuRespDTO getSpu(Long id) { |
| 40 | - return ProductSpuConvert.INSTANCE.convert02(spuService.getSpu(id)); | |
| 41 | + ProductSpuDO spu = spuService.getSpu(id); | |
| 42 | + return BeanUtils.toBean(spu, ProductSpuRespDTO.class); | |
| 41 | 43 | } |
| 42 | 44 | |
| 43 | 45 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.product.controller.admin.comment.vo; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; | |
| 3 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; | |
| 4 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 5 | 6 | import lombok.Data; |
| 6 | 7 | import lombok.EqualsAndHashCode; |
| 7 | 8 | import lombok.ToString; |
| 8 | 9 | |
| 9 | -import jakarta.validation.constraints.NotNull; | |
| 10 | 10 | import java.time.LocalDateTime; |
| 11 | 11 | import java.util.List; |
| 12 | 12 | |
| ... | ... | @@ -58,6 +58,6 @@ public class ProductCommentRespVO extends ProductCommentBaseVO { |
| 58 | 58 | private String skuPicUrl; |
| 59 | 59 | |
| 60 | 60 | @Schema(description = "商品 SKU 规格值数组") |
| 61 | - private List<ProductSkuBaseVO.Property> skuProperties; | |
| 61 | + private List<ProductSkuSaveReqVO.Property> skuProperties; | |
| 62 | 62 | |
| 63 | 63 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueDetailRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.Data; | |
| 5 | - | |
| 6 | -@Schema(description = "管理后台 - 商品属性值的明细 Response VO") | |
| 7 | -@Data | |
| 8 | -public class ProductPropertyValueDetailRespVO { | |
| 9 | - | |
| 10 | - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 11 | - private Long propertyId; | |
| 12 | - | |
| 13 | - @Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") | |
| 14 | - private String propertyName; | |
| 15 | - | |
| 16 | - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 17 | - private Long valueId; | |
| 18 | - | |
| 19 | - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") | |
| 20 | - private String valueName; | |
| 21 | - | |
| 22 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.sku; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.tags.Tag; | |
| 4 | -import org.springframework.validation.annotation.Validated; | |
| 5 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 6 | -import org.springframework.web.bind.annotation.RestController; | |
| 7 | - | |
| 8 | -@Tag(name = "管理后台 - 商品 SKU") | |
| 9 | -@RestController | |
| 10 | -@RequestMapping("/product/sku") | |
| 11 | -@Validated | |
| 12 | -public class ProductSkuController { | |
| 13 | - | |
| 14 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.Data; | |
| 5 | -import lombok.EqualsAndHashCode; | |
| 6 | -import lombok.ToString; | |
| 7 | - | |
| 8 | -import java.util.List; | |
| 9 | - | |
| 10 | -@Schema(description = "管理后台 - 商品 SKU 创建/更新 Request VO") | |
| 11 | -@Data | |
| 12 | -@EqualsAndHashCode(callSuper = true) | |
| 13 | -@ToString(callSuper = true) | |
| 14 | -public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO { | |
| 15 | - | |
| 16 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.*; | |
| 5 | - | |
| 6 | -import jakarta.validation.constraints.NotNull; | |
| 7 | -import java.util.List; | |
| 8 | - | |
| 9 | -@Schema(description = "管理后台 - 商品 SKU Response VO") | |
| 10 | -@Data | |
| 11 | -@EqualsAndHashCode(callSuper = true) | |
| 12 | -@ToString(callSuper = true) | |
| 13 | -public class ProductSkuRespVO extends ProductSkuBaseVO { | |
| 14 | - | |
| 15 | - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 16 | - private Long id; | |
| 17 | - | |
| 18 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.controller.admin.spu; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 5 | 6 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 6 | 7 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 7 | 8 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| ... | ... | @@ -14,23 +15,22 @@ import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| 14 | 15 | import io.swagger.v3.oas.annotations.Operation; |
| 15 | 16 | import io.swagger.v3.oas.annotations.Parameter; |
| 16 | 17 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 18 | +import jakarta.annotation.Resource; | |
| 19 | +import jakarta.servlet.http.HttpServletResponse; | |
| 20 | +import jakarta.validation.Valid; | |
| 17 | 21 | import org.springframework.security.access.prepost.PreAuthorize; |
| 18 | 22 | import org.springframework.validation.annotation.Validated; |
| 19 | 23 | import org.springframework.web.bind.annotation.*; |
| 20 | 24 | |
| 21 | -import jakarta.annotation.Resource; | |
| 22 | -import jakarta.servlet.http.HttpServletResponse; | |
| 23 | -import jakarta.validation.Valid; | |
| 24 | 25 | import java.io.IOException; |
| 25 | 26 | import java.util.Collection; |
| 26 | 27 | import java.util.Comparator; |
| 27 | 28 | import java.util.List; |
| 28 | 29 | import java.util.Map; |
| 29 | 30 | |
| 30 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 31 | 31 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 32 | +import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | |
| 32 | 33 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 33 | -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; | |
| 34 | 34 | |
| 35 | 35 | @Tag(name = "管理后台 - 商品 SPU") |
| 36 | 36 | @RestController |
| ... | ... | @@ -46,14 +46,14 @@ public class ProductSpuController { |
| 46 | 46 | @PostMapping("/create") |
| 47 | 47 | @Operation(summary = "创建商品 SPU") |
| 48 | 48 | @PreAuthorize("@ss.hasPermission('product:spu:create')") |
| 49 | - public CommonResult<Long> createProductSpu(@Valid @RequestBody ProductSpuCreateReqVO createReqVO) { | |
| 49 | + public CommonResult<Long> createProductSpu(@Valid @RequestBody ProductSpuSaveReqVO createReqVO) { | |
| 50 | 50 | return success(productSpuService.createSpu(createReqVO)); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | @PutMapping("/update") |
| 54 | 54 | @Operation(summary = "更新商品 SPU") |
| 55 | 55 | @PreAuthorize("@ss.hasPermission('product:spu:update')") |
| 56 | - public CommonResult<Boolean> updateSpu(@Valid @RequestBody ProductSpuUpdateReqVO updateReqVO) { | |
| 56 | + public CommonResult<Boolean> updateSpu(@Valid @RequestBody ProductSpuSaveReqVO updateReqVO) { | |
| 57 | 57 | productSpuService.updateSpu(updateReqVO); |
| 58 | 58 | return success(true); |
| 59 | 59 | } |
| ... | ... | @@ -79,15 +79,15 @@ public class ProductSpuController { |
| 79 | 79 | @Operation(summary = "获得商品 SPU 明细") |
| 80 | 80 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 81 | 81 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 82 | - public CommonResult<ProductSpuDetailRespVO> getSpuDetail(@RequestParam("id") Long id) { | |
| 82 | + public CommonResult<ProductSpuRespVO> getSpuDetail(@RequestParam("id") Long id) { | |
| 83 | 83 | // 获得商品 SPU |
| 84 | 84 | ProductSpuDO spu = productSpuService.getSpu(id); |
| 85 | 85 | if (spu == null) { |
| 86 | - throw exception(SPU_NOT_EXISTS); | |
| 86 | + return success(null); | |
| 87 | 87 | } |
| 88 | 88 | // 查询商品 SKU |
| 89 | 89 | List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId()); |
| 90 | - return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus)); | |
| 90 | + return success(ProductSpuConvert.INSTANCE.convert(spu, skus)); | |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | @GetMapping("/list-all-simple") |
| ... | ... | @@ -97,14 +97,14 @@ public class ProductSpuController { |
| 97 | 97 | List<ProductSpuDO> list = productSpuService.getSpuListByStatus(ProductSpuStatusEnum.ENABLE.getStatus()); |
| 98 | 98 | // 降序排序后,返回给前端 |
| 99 | 99 | list.sort(Comparator.comparing(ProductSpuDO::getSort).reversed()); |
| 100 | - return success(ProductSpuConvert.INSTANCE.convertList02(list)); | |
| 100 | + return success(BeanUtils.toBean(list, ProductSpuSimpleRespVO.class)); | |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | @GetMapping("/list") |
| 104 | 104 | @Operation(summary = "获得商品 SPU 详情列表") |
| 105 | 105 | @Parameter(name = "spuIds", description = "spu 编号列表", required = true, example = "[1,2,3]") |
| 106 | 106 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 107 | - public CommonResult<List<ProductSpuDetailRespVO>> getSpuList(@RequestParam("spuIds") Collection<Long> spuIds) { | |
| 107 | + public CommonResult<List<ProductSpuRespVO>> getSpuList(@RequestParam("spuIds") Collection<Long> spuIds) { | |
| 108 | 108 | return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespListVO( |
| 109 | 109 | productSpuService.getSpuList(spuIds), productSkuService.getSkuListBySpuId(spuIds))); |
| 110 | 110 | } |
| ... | ... | @@ -113,7 +113,8 @@ public class ProductSpuController { |
| 113 | 113 | @Operation(summary = "获得商品 SPU 分页") |
| 114 | 114 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 115 | 115 | public CommonResult<PageResult<ProductSpuRespVO>> getSpuPage(@Valid ProductSpuPageReqVO pageVO) { |
| 116 | - return success(ProductSpuConvert.INSTANCE.convertPage(productSpuService.getSpuPage(pageVO))); | |
| 116 | + PageResult<ProductSpuDO> pageResult = productSpuService.getSpuPage(pageVO); | |
| 117 | + return success(BeanUtils.toBean(pageResult, ProductSpuRespVO.class)); | |
| 117 | 118 | } |
| 118 | 119 | |
| 119 | 120 | @GetMapping("/get-count") |
| ... | ... | @@ -127,12 +128,13 @@ public class ProductSpuController { |
| 127 | 128 | @Operation(summary = "导出商品") |
| 128 | 129 | @PreAuthorize("@ss.hasPermission('product:spu:export')") |
| 129 | 130 | @OperateLog(type = EXPORT) |
| 130 | - public void exportUserList(@Validated ProductSpuExportReqVO reqVO, | |
| 131 | + public void exportSpuList(@Validated ProductSpuPageReqVO reqVO, | |
| 131 | 132 | HttpServletResponse response) throws IOException { |
| 132 | - List<ProductSpuDO> spuList = productSpuService.getSpuList(reqVO); | |
| 133 | + reqVO.setPageSize(PAGE_SIZE_NONE); | |
| 134 | + List<ProductSpuDO> list = productSpuService.getSpuPage(reqVO).getList(); | |
| 133 | 135 | // 导出 Excel |
| 134 | - List<ProductSpuExcelVO> datas = ProductSpuConvert.INSTANCE.convertList03(spuList); | |
| 135 | - ExcelUtils.write(response, "商品列表.xls", "数据", ProductSpuExcelVO.class, datas); | |
| 136 | + ExcelUtils.write(response, "商品列表.xls", "数据", ProductSpuRespVO.class, | |
| 137 | + BeanUtils.toBean(list, ProductSpuRespVO.class)); | |
| 136 | 138 | } |
| 137 | 139 | |
| 138 | 140 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuRespVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.util.List; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - 商品 SKU Response VO") | |
| 9 | +@Data | |
| 10 | +public class ProductSkuRespVO { | |
| 11 | + | |
| 12 | + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 13 | + private Long id; | |
| 14 | + | |
| 15 | + @Schema(description = "商品 SKU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") | |
| 16 | + private String name; | |
| 17 | + | |
| 18 | + @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") | |
| 19 | + private Integer price; | |
| 20 | + | |
| 21 | + @Schema(description = "市场价", example = "2999") | |
| 22 | + private Integer marketPrice; | |
| 23 | + | |
| 24 | + @Schema(description = "成本价", example = "19") | |
| 25 | + private Integer costPrice; | |
| 26 | + | |
| 27 | + @Schema(description = "条形码", example = "15156165456") | |
| 28 | + private String barCode; | |
| 29 | + | |
| 30 | + @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") | |
| 31 | + private String picUrl; | |
| 32 | + | |
| 33 | + @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") | |
| 34 | + private Integer stock; | |
| 35 | + | |
| 36 | + @Schema(description = "商品重量,单位:kg 千克", example = "1.2") | |
| 37 | + private Double weight; | |
| 38 | + | |
| 39 | + @Schema(description = "商品体积,单位:m^3 平米", example = "2.5") | |
| 40 | + private Double volume; | |
| 41 | + | |
| 42 | + @Schema(description = "一级分销的佣金,单位:分", example = "199") | |
| 43 | + private Integer firstBrokeragePrice; | |
| 44 | + | |
| 45 | + @Schema(description = "二级分销的佣金,单位:分", example = "19") | |
| 46 | + private Integer secondBrokeragePrice; | |
| 47 | + | |
| 48 | + @Schema(description = "属性数组") | |
| 49 | + private List<ProductSkuSaveReqVO.Property> properties; | |
| 50 | + | |
| 51 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; | |
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import lombok.AllArgsConstructor; | |
| 5 | -import lombok.Data; | |
| 6 | -import lombok.NoArgsConstructor; | |
| 7 | - | |
| 8 | 4 | import jakarta.validation.constraints.NotEmpty; |
| 9 | 5 | import jakarta.validation.constraints.NotNull; |
| 6 | +import lombok.*; | |
| 7 | + | |
| 10 | 8 | import java.util.List; |
| 11 | 9 | |
| 12 | -/** | |
| 13 | -* 商品 SKU Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 14 | -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 15 | -*/ | |
| 10 | +@Schema(description = "管理后台 - 商品 SKU 创建/更新 Request VO") | |
| 16 | 11 | @Data |
| 17 | -public class ProductSkuBaseVO { | |
| 12 | +public class ProductSkuSaveReqVO { | |
| 18 | 13 | |
| 19 | 14 | @Schema(description = "商品 SKU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") |
| 20 | 15 | @NotEmpty(message = "商品 SKU 名字不能为空") |
| ... | ... | @@ -41,9 +36,6 @@ public class ProductSkuBaseVO { |
| 41 | 36 | @NotNull(message = "库存不能为空") |
| 42 | 37 | private Integer stock; |
| 43 | 38 | |
| 44 | - @Schema(description = "预警预存", example = "10") | |
| 45 | - private Integer warnStock; | |
| 46 | - | |
| 47 | 39 | @Schema(description = "商品重量,单位:kg 千克", example = "1.2") |
| 48 | 40 | private Double weight; |
| 49 | 41 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | |
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | -import lombok.Data; | |
| 6 | -import lombok.EqualsAndHashCode; | |
| 7 | -import lombok.ToString; | |
| 8 | - | |
| 9 | -import jakarta.validation.Valid; | |
| 10 | -import java.util.List; | |
| 11 | - | |
| 12 | -@Schema(description = "管理后台 - 商品 SPU 创建 Request VO") | |
| 13 | -@Data | |
| 14 | -@EqualsAndHashCode(callSuper = true) | |
| 15 | -@ToString(callSuper = true) | |
| 16 | -public class ProductSpuCreateReqVO extends ProductSpuBaseVO { | |
| 17 | - | |
| 18 | - // ========== SKU 相关字段 ========= | |
| 19 | - | |
| 20 | - @Schema(description = "SKU 数组") | |
| 21 | - @Valid | |
| 22 | - private List<ProductSkuCreateOrUpdateReqVO> skus; | |
| 23 | - | |
| 24 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; | |
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | -import lombok.Data; | |
| 6 | -import lombok.EqualsAndHashCode; | |
| 7 | -import lombok.ToString; | |
| 8 | - | |
| 9 | -import java.util.List; | |
| 10 | - | |
| 11 | -@Schema(description = "管理后台 - 商品 SPU 详细 Response VO") | |
| 12 | -@Data | |
| 13 | -@EqualsAndHashCode(callSuper = true) | |
| 14 | -@ToString(callSuper = true) | |
| 15 | -public class ProductSpuDetailRespVO extends ProductSpuRespVO { | |
| 16 | - | |
| 17 | - // ========== SKU 相关字段 ========= | |
| 18 | - | |
| 19 | - @Schema(description = "SKU 数组") | |
| 20 | - private List<ProductSkuRespVO> skus; | |
| 21 | - | |
| 22 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | -import cn.iocoder.yudao.module.product.enums.DictTypeConstants; | |
| 6 | -import com.alibaba.excel.annotation.ExcelProperty; | |
| 7 | -import lombok.Data; | |
| 8 | - | |
| 9 | - | |
| 10 | -import java.time.LocalDateTime; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 商品 Spu Excel 导出 VO TODO 暂定 | |
| 14 | - * | |
| 15 | - * @author HUIHUI | |
| 16 | - */ | |
| 17 | -@Data | |
| 18 | -public class ProductSpuExcelVO { | |
| 19 | - | |
| 20 | - @ExcelProperty("商品编号") | |
| 21 | - private Long id; | |
| 22 | - | |
| 23 | - @ExcelProperty("商品名称") | |
| 24 | - private String name; | |
| 25 | - | |
| 26 | - @ExcelProperty("关键字") | |
| 27 | - private String keyword; | |
| 28 | - | |
| 29 | - @ExcelProperty("商品简介") | |
| 30 | - private String introduction; | |
| 31 | - | |
| 32 | - @ExcelProperty("商品详情") | |
| 33 | - private String description; | |
| 34 | - | |
| 35 | - @ExcelProperty("条形码") | |
| 36 | - private String barCode; | |
| 37 | - | |
| 38 | - @ExcelProperty("商品分类编号") | |
| 39 | - private Long categoryId; | |
| 40 | - | |
| 41 | - @ExcelProperty("商品品牌编号") | |
| 42 | - private Long brandId; | |
| 43 | - | |
| 44 | - @ExcelProperty("商品封面图") | |
| 45 | - private String picUrl; | |
| 46 | - | |
| 47 | - @ExcelProperty("排序字段") | |
| 48 | - private Integer sort; | |
| 49 | - | |
| 50 | - @ExcelProperty(value = "商品状态", converter = DictConvert.class) | |
| 51 | - @DictFormat(DictTypeConstants.PRODUCT_SPU_STATUS) | |
| 52 | - private Integer status; | |
| 53 | - | |
| 54 | - @ExcelProperty("规格类型") | |
| 55 | - private Boolean specType; | |
| 56 | - | |
| 57 | - @ExcelProperty("商品价格") | |
| 58 | - private Integer price; | |
| 59 | - | |
| 60 | - @ExcelProperty("市场价") | |
| 61 | - private Integer marketPrice; | |
| 62 | - | |
| 63 | - @ExcelProperty("成本价") | |
| 64 | - private Integer costPrice; | |
| 65 | - | |
| 66 | - @ExcelProperty("库存") | |
| 67 | - private Integer stock; | |
| 68 | - | |
| 69 | - @ExcelProperty("物流配置模板编号") | |
| 70 | - private Long deliveryTemplateId; | |
| 71 | - | |
| 72 | - @ExcelProperty("赠送积分") | |
| 73 | - private Integer giveIntegral; | |
| 74 | - | |
| 75 | - @ExcelProperty("分销类型") | |
| 76 | - private Boolean subCommissionType; | |
| 77 | - | |
| 78 | - @ExcelProperty("商品销量") | |
| 79 | - private Integer salesCount; | |
| 80 | - | |
| 81 | - @ExcelProperty("虚拟销量") | |
| 82 | - private Integer virtualSalesCount; | |
| 83 | - | |
| 84 | - @ExcelProperty("商品点击量") | |
| 85 | - private Integer browseCount; | |
| 86 | - | |
| 87 | - @ExcelProperty("创建时间") | |
| 88 | - private LocalDateTime createTime; | |
| 89 | - | |
| 90 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.AllArgsConstructor; | |
| 5 | -import lombok.Data; | |
| 6 | -import lombok.NoArgsConstructor; | |
| 7 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | - | |
| 9 | -import java.time.LocalDateTime; | |
| 10 | - | |
| 11 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 12 | - | |
| 13 | -@Schema(description = "管理后台 - 商品 SPU 导出 Request VO,参数和 ProductSpuPageReqVO 是一致的") | |
| 14 | -@Data | |
| 15 | -@NoArgsConstructor | |
| 16 | -@AllArgsConstructor | |
| 17 | -public class ProductSpuExportReqVO { | |
| 18 | - | |
| 19 | - @Schema(description = "商品名称", example = "清凉小短袖") | |
| 20 | - private String name; | |
| 21 | - | |
| 22 | - @Schema(description = "前端请求的tab类型", example = "1") | |
| 23 | - private Integer tabType; | |
| 24 | - | |
| 25 | - @Schema(description = "商品分类编号", example = "100") | |
| 26 | - private Long categoryId; | |
| 27 | - | |
| 28 | - @Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]") | |
| 29 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 30 | - private LocalDateTime[] createTime; | |
| 31 | - | |
| 32 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.product.controller.admin.spu.vo; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | +import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; | |
| 6 | +import cn.iocoder.yudao.module.product.enums.DictTypeConstants; | |
| 7 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |
| 8 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 3 | 9 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 10 | import lombok.Data; |
| 5 | -import lombok.EqualsAndHashCode; | |
| 6 | -import lombok.ToString; | |
| 7 | 11 | |
| 8 | 12 | import java.time.LocalDateTime; |
| 13 | +import java.util.List; | |
| 9 | 14 | |
| 10 | 15 | @Schema(description = "管理后台 - 商品 SPU Response VO") |
| 11 | 16 | @Data |
| 12 | -@EqualsAndHashCode(callSuper = true) | |
| 13 | -@ToString(callSuper = true) | |
| 14 | -public class ProductSpuRespVO extends ProductSpuBaseVO { | |
| 17 | +@ExcelIgnoreUnannotated | |
| 18 | +public class ProductSpuRespVO { | |
| 15 | 19 | |
| 16 | 20 | @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") |
| 21 | + @ExcelProperty("商品编号") | |
| 17 | 22 | private Long id; |
| 18 | 23 | |
| 24 | + @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") | |
| 25 | + @ExcelProperty("商品名称") | |
| 26 | + private String name; | |
| 27 | + | |
| 28 | + @Schema(description = "关键字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑不出汗") | |
| 29 | + @ExcelProperty("关键字") | |
| 30 | + private String keyword; | |
| 31 | + | |
| 32 | + @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖简介") | |
| 33 | + @ExcelProperty("商品简介") | |
| 34 | + private String introduction; | |
| 35 | + | |
| 36 | + @Schema(description = "商品详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖详情") | |
| 37 | + @ExcelProperty("商品详情") | |
| 38 | + private String description; | |
| 39 | + | |
| 40 | + @Schema(description = "商品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 41 | + @ExcelProperty("商品分类编号") | |
| 42 | + private Long categoryId; | |
| 43 | + | |
| 44 | + @Schema(description = "商品品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 45 | + @ExcelProperty("商品品牌编号") | |
| 46 | + private Long brandId; | |
| 47 | + | |
| 48 | + @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") | |
| 49 | + @ExcelProperty("商品封面图") | |
| 50 | + private String picUrl; | |
| 51 | + | |
| 52 | + @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") | |
| 53 | + private List<String> sliderPicUrls; | |
| 54 | + | |
| 55 | + @Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 56 | + @ExcelProperty("排序字段") | |
| 57 | + private Integer sort; | |
| 58 | + | |
| 59 | + @Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 60 | + @ExcelProperty(value = "商品状态", converter = DictConvert.class) | |
| 61 | + @DictFormat(DictTypeConstants.PRODUCT_SPU_STATUS) | |
| 62 | + private Integer status; | |
| 63 | + | |
| 64 | + @Schema(description = "商品创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-05-24 00:00:00") | |
| 65 | + @ExcelProperty("创建时间") | |
| 66 | + private LocalDateTime createTime; | |
| 67 | + | |
| 68 | + // ========== SKU 相关字段 ========= | |
| 69 | + | |
| 70 | + @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | |
| 71 | + @ExcelProperty("规格类型") | |
| 72 | + private Boolean specType; | |
| 73 | + | |
| 19 | 74 | @Schema(description = "商品价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") |
| 75 | + @ExcelProperty(value = "商品价格", converter = MoneyConvert.class) | |
| 20 | 76 | private Integer price; |
| 21 | 77 | |
| 22 | - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") | |
| 23 | - private Integer salesCount; | |
| 24 | - | |
| 25 | 78 | @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "199") |
| 79 | + @ExcelProperty(value = "市场价", converter = MoneyConvert.class) | |
| 26 | 80 | private Integer marketPrice; |
| 27 | 81 | |
| 28 | 82 | @Schema(description = "成本价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "19") |
| 83 | + @ExcelProperty(value = "成本价", converter = MoneyConvert.class) | |
| 29 | 84 | private Integer costPrice; |
| 30 | 85 | |
| 31 | 86 | @Schema(description = "商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") |
| 87 | + @ExcelProperty("库存") | |
| 32 | 88 | private Integer stock; |
| 33 | 89 | |
| 34 | - @Schema(description = "商品创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-05-24 00:00:00") | |
| 35 | - private LocalDateTime createTime; | |
| 90 | + @Schema(description = "SKU 数组") | |
| 91 | + private List<ProductSkuRespVO> skus; | |
| 36 | 92 | |
| 37 | - @Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 38 | - private Integer status; | |
| 93 | + // ========== 物流相关字段 ========= | |
| 94 | + | |
| 95 | + @Schema(description = "配送方式数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 96 | + private List<Integer> deliveryTypes; | |
| 97 | + | |
| 98 | + @Schema(description = "物流配置模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") | |
| 99 | + @ExcelProperty("物流配置模板编号") | |
| 100 | + private Long deliveryTemplateId; | |
| 101 | + | |
| 102 | + // ========== 营销相关字段 ========= | |
| 103 | + | |
| 104 | + @Schema(description = "赠送积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") | |
| 105 | + @ExcelProperty("赠送积分") | |
| 106 | + private Integer giveIntegral; | |
| 107 | + | |
| 108 | + @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | |
| 109 | + @ExcelProperty("分销类型") | |
| 110 | + private Boolean subCommissionType; | |
| 111 | + | |
| 112 | + // ========== 统计相关字段 ========= | |
| 113 | + | |
| 114 | + @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") | |
| 115 | + @ExcelProperty("商品销量") | |
| 116 | + private Integer salesCount; | |
| 117 | + | |
| 118 | + @Schema(description = "虚拟销量", example = "66") | |
| 119 | + @ExcelProperty("虚拟销量") | |
| 120 | + private Integer virtualSalesCount; | |
| 39 | 121 | |
| 40 | 122 | @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") |
| 123 | + @ExcelProperty("商品点击量") | |
| 41 | 124 | private Integer browseCount; |
| 42 | 125 | |
| 43 | 126 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.product.controller.admin.spu.vo; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import lombok.Data; | |
| 5 | - | |
| 4 | +import jakarta.validation.Valid; | |
| 6 | 5 | import jakarta.validation.constraints.NotEmpty; |
| 7 | 6 | import jakarta.validation.constraints.NotNull; |
| 7 | +import lombok.Data; | |
| 8 | + | |
| 8 | 9 | import java.util.List; |
| 9 | 10 | |
| 10 | -/** | |
| 11 | -* 商品 SPU Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 12 | -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 13 | - * | |
| 14 | - * @author HUIHUI | |
| 15 | - */ | |
| 11 | +@Schema(description = "管理后台 - 商品 SPU 新增/更新 Request VO") | |
| 16 | 12 | @Data |
| 17 | -public class ProductSpuBaseVO { | |
| 13 | +public class ProductSpuSaveReqVO { | |
| 14 | + | |
| 15 | + @Schema(description = "商品编号", example = "1") | |
| 16 | + private Long id; | |
| 18 | 17 | |
| 19 | 18 | @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") |
| 20 | 19 | @NotEmpty(message = "商品名称不能为空") |
| ... | ... | @@ -44,7 +43,8 @@ public class ProductSpuBaseVO { |
| 44 | 43 | @NotEmpty(message = "商品封面图不能为空") |
| 45 | 44 | private String picUrl; |
| 46 | 45 | |
| 47 | - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") | |
| 46 | + @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED, | |
| 47 | + example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") | |
| 48 | 48 | private List<String> sliderPicUrls; |
| 49 | 49 | |
| 50 | 50 | @Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| ... | ... | @@ -64,7 +64,6 @@ public class ProductSpuBaseVO { |
| 64 | 64 | private List<Integer> deliveryTypes; |
| 65 | 65 | |
| 66 | 66 | @Schema(description = "物流配置模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") |
| 67 | - @NotNull(message = "物流配置模板编号不能为空") | |
| 68 | 67 | private Long deliveryTemplateId; |
| 69 | 68 | |
| 70 | 69 | // ========== 营销相关字段 ========= |
| ... | ... | @@ -82,4 +81,16 @@ public class ProductSpuBaseVO { |
| 82 | 81 | @Schema(description = "虚拟销量", example = "66") |
| 83 | 82 | private Integer virtualSalesCount; |
| 84 | 83 | |
| 84 | + @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") | |
| 85 | + private Integer salesCount; | |
| 86 | + | |
| 87 | + @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") | |
| 88 | + private Integer browseCount; | |
| 89 | + | |
| 90 | + // ========== SKU 相关字段 ========= | |
| 91 | + | |
| 92 | + @Schema(description = "SKU 数组") | |
| 93 | + @Valid | |
| 94 | + private List<ProductSkuSaveReqVO> skus; | |
| 95 | + | |
| 85 | 96 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 4 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | |
| 5 | -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; | |
| 6 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 7 | -import lombok.Data; | |
| 8 | -import lombok.EqualsAndHashCode; | |
| 9 | -import lombok.ToString; | |
| 10 | - | |
| 11 | -import jakarta.validation.Valid; | |
| 12 | -import jakarta.validation.constraints.NotNull; | |
| 13 | -import java.util.List; | |
| 14 | - | |
| 15 | -@Schema(description = "管理后台 - 商品 SPU 更新 Request VO") | |
| 16 | -@Data | |
| 17 | -@EqualsAndHashCode(callSuper = true) | |
| 18 | -@ToString(callSuper = true) | |
| 19 | -public class ProductSpuUpdateReqVO extends ProductSpuBaseVO { | |
| 20 | - | |
| 21 | - @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 22 | - @NotNull(message = "商品编号不能为空") | |
| 23 | - private Long id; | |
| 24 | - | |
| 25 | - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") | |
| 26 | - private Integer salesCount; | |
| 27 | - | |
| 28 | - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") | |
| 29 | - private Integer browseCount; | |
| 30 | - | |
| 31 | - @Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 32 | - @InEnum(ProductSpuStatusEnum.class) | |
| 33 | - private Integer status; | |
| 34 | - | |
| 35 | - // ========== SKU 相关字段 ========= | |
| 36 | - | |
| 37 | - @Schema(description = "SKU 数组") | |
| 38 | - @Valid | |
| 39 | - private List<ProductSkuCreateOrUpdateReqVO> skus; | |
| 40 | - | |
| 41 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
| ... | ... | @@ -3,14 +3,14 @@ package cn.iocoder.yudao.module.product.controller.app.spu; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 6 | 7 | import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; |
| 7 | 8 | import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; |
| 8 | 9 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; |
| 9 | 10 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 10 | 11 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; |
| 11 | 12 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 12 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRespVO; | |
| 13 | -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; | |
| 13 | +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRespVO; | |
| 14 | 14 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 15 | 15 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 16 | 16 | import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; |
| ... | ... | @@ -19,16 +19,15 @@ import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; |
| 19 | 19 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| 20 | 20 | import io.swagger.v3.oas.annotations.Operation; |
| 21 | 21 | import io.swagger.v3.oas.annotations.Parameter; |
| 22 | -import io.swagger.v3.oas.annotations.Parameters; | |
| 23 | 22 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 23 | +import jakarta.annotation.Resource; | |
| 24 | +import jakarta.validation.Valid; | |
| 24 | 25 | import org.springframework.validation.annotation.Validated; |
| 25 | 26 | import org.springframework.web.bind.annotation.GetMapping; |
| 26 | 27 | import org.springframework.web.bind.annotation.RequestMapping; |
| 27 | 28 | import org.springframework.web.bind.annotation.RequestParam; |
| 28 | 29 | import org.springframework.web.bind.annotation.RestController; |
| 29 | 30 | |
| 30 | -import jakarta.annotation.Resource; | |
| 31 | -import jakarta.validation.Valid; | |
| 32 | 31 | import java.util.Collections; |
| 33 | 32 | import java.util.List; |
| 34 | 33 | import java.util.Set; |
| ... | ... | @@ -57,39 +56,18 @@ public class AppProductSpuController { |
| 57 | 56 | @Resource |
| 58 | 57 | private MemberUserApi memberUserApi; |
| 59 | 58 | |
| 60 | - @GetMapping("/list") | |
| 61 | - @Operation(summary = "获得商品 SPU 列表") | |
| 62 | - @Parameters({ | |
| 63 | - @Parameter(name = "recommendType", description = "推荐类型", required = true), // 参见 AppProductSpuPageReqVO.RECOMMEND_TYPE_XXX 常量 | |
| 64 | - @Parameter(name = "count", description = "数量", required = true) | |
| 65 | - }) | |
| 66 | - public CommonResult<List<AppProductSpuPageRespVO>> getSpuList( | |
| 67 | - @RequestParam("recommendType") String recommendType, | |
| 68 | - @RequestParam(value = "count", defaultValue = "10") Integer count) { | |
| 69 | - List<ProductSpuDO> list = productSpuService.getSpuList(recommendType, count); | |
| 70 | - if (CollUtil.isEmpty(list)) { | |
| 71 | - return success(Collections.emptyList()); | |
| 72 | - } | |
| 73 | - | |
| 74 | - // 拼接返回 | |
| 75 | - List<AppProductSpuPageRespVO> voList = ProductSpuConvert.INSTANCE.convertListForGetSpuList(list); | |
| 76 | - // 处理 vip 价格 | |
| 77 | - MemberLevelRespDTO memberLevel = getMemberLevel(); | |
| 78 | - voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); | |
| 79 | - return success(voList); | |
| 80 | - } | |
| 81 | - | |
| 82 | 59 | @GetMapping("/list-by-ids") |
| 83 | 60 | @Operation(summary = "获得商品 SPU 列表") |
| 84 | 61 | @Parameter(name = "ids", description = "编号列表", required = true) |
| 85 | - public CommonResult<List<AppProductSpuPageRespVO>> getSpuList(@RequestParam("ids") Set<Long> ids) { | |
| 62 | + public CommonResult<List<AppProductSpuRespVO>> getSpuList(@RequestParam("ids") Set<Long> ids) { | |
| 86 | 63 | List<ProductSpuDO> list = productSpuService.getSpuList(ids); |
| 87 | 64 | if (CollUtil.isEmpty(list)) { |
| 88 | 65 | return success(Collections.emptyList()); |
| 89 | 66 | } |
| 90 | 67 | |
| 91 | 68 | // 拼接返回 |
| 92 | - List<AppProductSpuPageRespVO> voList = ProductSpuConvert.INSTANCE.convertListForGetSpuList(list); | |
| 69 | + list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount())); | |
| 70 | + List<AppProductSpuRespVO> voList = BeanUtils.toBean(list, AppProductSpuRespVO.class); | |
| 93 | 71 | // 处理 vip 价格 |
| 94 | 72 | MemberLevelRespDTO memberLevel = getMemberLevel(); |
| 95 | 73 | voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); |
| ... | ... | @@ -98,14 +76,15 @@ public class AppProductSpuController { |
| 98 | 76 | |
| 99 | 77 | @GetMapping("/page") |
| 100 | 78 | @Operation(summary = "获得商品 SPU 分页") |
| 101 | - public CommonResult<PageResult<AppProductSpuPageRespVO>> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) { | |
| 79 | + public CommonResult<PageResult<AppProductSpuRespVO>> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) { | |
| 102 | 80 | PageResult<ProductSpuDO> pageResult = productSpuService.getSpuPage(pageVO); |
| 103 | 81 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 104 | 82 | return success(PageResult.empty(pageResult.getTotal())); |
| 105 | 83 | } |
| 106 | 84 | |
| 107 | 85 | // 拼接返回 |
| 108 | - PageResult<AppProductSpuPageRespVO> voPageResult = ProductSpuConvert.INSTANCE.convertPageForGetSpuPage(pageResult); | |
| 86 | + pageResult.getList().forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount())); | |
| 87 | + PageResult<AppProductSpuRespVO> voPageResult = BeanUtils.toBean(pageResult, AppProductSpuRespVO.class); | |
| 109 | 88 | // 处理 vip 价格 |
| 110 | 89 | MemberLevelRespDTO memberLevel = getMemberLevel(); |
| 111 | 90 | voPageResult.getList().forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); |
| ... | ... | @@ -124,6 +103,8 @@ public class AppProductSpuController { |
| 124 | 103 | if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) { |
| 125 | 104 | throw exception(SPU_NOT_ENABLE); |
| 126 | 105 | } |
| 106 | + // 获得商品 SKU | |
| 107 | + List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId()); | |
| 127 | 108 | |
| 128 | 109 | // 增加浏览量 |
| 129 | 110 | productSpuService.updateBrowseCount(id, 1); |
| ... | ... | @@ -131,12 +112,13 @@ public class AppProductSpuController { |
| 131 | 112 | productBrowseHistoryService.createBrowseHistory(getLoginUserId(), id); |
| 132 | 113 | |
| 133 | 114 | // 拼接返回 |
| 134 | - List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId()); | |
| 135 | - AppProductSpuDetailRespVO detailVO = ProductSpuConvert.INSTANCE.convertForGetSpuDetail(spu, skus); | |
| 115 | + spu.setBrowseCount(spu.getBrowseCount() + spu.getVirtualSalesCount()); | |
| 116 | + AppProductSpuDetailRespVO spuVO = BeanUtils.toBean(spu, AppProductSpuDetailRespVO.class) | |
| 117 | + .setSkus(BeanUtils.toBean(skus, AppProductSpuDetailRespVO.Sku.class)); | |
| 136 | 118 | // 处理 vip 价格 |
| 137 | 119 | MemberLevelRespDTO memberLevel = getMemberLevel(); |
| 138 | - detailVO.setVipPrice(calculateVipPrice(detailVO.getPrice(), memberLevel)); | |
| 139 | - return success(detailVO); | |
| 120 | + spuVO.setVipPrice(calculateVipPrice(spuVO.getPrice(), memberLevel)); | |
| 121 | + return success(spuVO); | |
| 140 | 122 | } |
| 141 | 123 | |
| 142 | 124 | private MemberLevelRespDTO getMemberLevel() { | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java
| ... | ... | @@ -21,12 +21,6 @@ public class AppProductSpuPageReqVO extends PageParam { |
| 21 | 21 | public static final String SORT_FIELD_SALES_COUNT = "salesCount"; |
| 22 | 22 | public static final String SORT_FIELD_CREATE_TIME = "createTime"; |
| 23 | 23 | |
| 24 | - public static final String RECOMMEND_TYPE_HOT = "hot"; | |
| 25 | - public static final String RECOMMEND_TYPE_BENEFIT = "benefit"; | |
| 26 | - public static final String RECOMMEND_TYPE_BEST = "best"; | |
| 27 | - public static final String RECOMMEND_TYPE_NEW = "new"; | |
| 28 | - public static final String RECOMMEND_TYPE_GOOD = "good"; | |
| 29 | - | |
| 30 | 24 | @Schema(description = "商品 SPU 编号数组", example = "1,3,5") |
| 31 | 25 | private List<Long> ids; |
| 32 | 26 | |
| ... | ... | @@ -45,9 +39,6 @@ public class AppProductSpuPageReqVO extends PageParam { |
| 45 | 39 | @Schema(description = "排序方式", example = "true") |
| 46 | 40 | private Boolean sortAsc; |
| 47 | 41 | |
| 48 | - @Schema(description = "推荐类型", example = "hot") // 参见 AppProductSpuPageReqVO.RECOMMEND_TYPE_XXX 常量 | |
| 49 | - private String recommendType; | |
| 50 | - | |
| 51 | 42 | @AssertTrue(message = "排序字段不合法") |
| 52 | 43 | @JsonIgnore |
| 53 | 44 | public boolean isSortFieldValid() { | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageRespVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRespVO.java
| ... | ... | @@ -7,7 +7,7 @@ import java.util.List; |
| 7 | 7 | |
| 8 | 8 | @Schema(description = "用户 App - 商品 SPU Response VO") |
| 9 | 9 | @Data |
| 10 | -public class AppProductSpuPageRespVO { | |
| 10 | +public class AppProductSpuRespVO { | |
| 11 | 11 | |
| 12 | 12 | @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 13 | 13 | private Long id; | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java
| ... | ... | @@ -2,10 +2,7 @@ package cn.iocoder.yudao.module.product.convert.sku; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | |
| 6 | 5 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 7 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | |
| 8 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; | |
| 9 | 6 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 10 | 7 | import org.mapstruct.Mapper; |
| 11 | 8 | import org.mapstruct.factory.Mappers; |
| ... | ... | @@ -25,24 +22,6 @@ public interface ProductSkuConvert { |
| 25 | 22 | |
| 26 | 23 | ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class); |
| 27 | 24 | |
| 28 | - ProductSkuDO convert(ProductSkuCreateOrUpdateReqVO bean); | |
| 29 | - | |
| 30 | - ProductSkuRespVO convert(ProductSkuDO bean); | |
| 31 | - | |
| 32 | - List<ProductSkuRespVO> convertList(List<ProductSkuDO> list); | |
| 33 | - | |
| 34 | - List<ProductSkuDO> convertList06(List<ProductSkuCreateOrUpdateReqVO> list); | |
| 35 | - | |
| 36 | - default List<ProductSkuDO> convertList06(List<ProductSkuCreateOrUpdateReqVO> list, Long spuId) { | |
| 37 | - List<ProductSkuDO> result = convertList06(list); | |
| 38 | - result.forEach(item -> item.setSpuId(spuId)); | |
| 39 | - return result; | |
| 40 | - } | |
| 41 | - | |
| 42 | - ProductSkuRespDTO convert02(ProductSkuDO bean); | |
| 43 | - | |
| 44 | - List<ProductSkuRespDTO> convertList04(List<ProductSkuDO> list); | |
| 45 | - | |
| 46 | 25 | /** |
| 47 | 26 | * 获得 SPU 的库存变化 Map |
| 48 | 27 | * | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.product.convert.spu; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 3 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 5 | -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | |
| 6 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | |
| 7 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; | |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 5 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuRespVO; | |
| 6 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 9 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRespVO; | |
| 10 | -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; | |
| 11 | 9 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 12 | 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 13 | 11 | import org.mapstruct.Mapper; |
| 14 | -import org.mapstruct.Mapping; | |
| 15 | -import org.mapstruct.Named; | |
| 16 | 12 | import org.mapstruct.factory.Mappers; |
| 17 | 13 | |
| 18 | -import java.util.ArrayList; | |
| 19 | 14 | import java.util.List; |
| 20 | 15 | import java.util.Map; |
| 21 | 16 | |
| 22 | -import static cn.hutool.core.util.ObjectUtil.defaultIfNull; | |
| 23 | 17 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; |
| 24 | 18 | |
| 25 | 19 | /** |
| ... | ... | @@ -32,73 +26,17 @@ public interface ProductSpuConvert { |
| 32 | 26 | |
| 33 | 27 | ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); |
| 34 | 28 | |
| 35 | - ProductSpuDO convert(ProductSpuCreateReqVO bean); | |
| 36 | - | |
| 37 | - ProductSpuDO convert(ProductSpuUpdateReqVO bean); | |
| 38 | - | |
| 39 | - List<ProductSpuDO> convertList(List<ProductSpuDO> list); | |
| 40 | - | |
| 41 | - PageResult<ProductSpuRespVO> convertPage(PageResult<ProductSpuDO> page); | |
| 42 | - | |
| 43 | 29 | ProductSpuPageReqVO convert(AppProductSpuPageReqVO bean); |
| 44 | 30 | |
| 45 | - List<ProductSpuRespDTO> convertList2(List<ProductSpuDO> list); | |
| 46 | - | |
| 47 | - List<ProductSpuSimpleRespVO> convertList02(List<ProductSpuDO> list); | |
| 48 | - | |
| 49 | - @Mapping(target = "price", expression = "java(spu.getPrice() / 100)") | |
| 50 | - @Mapping(target = "marketPrice", expression = "java(spu.getMarketPrice() / 100)") | |
| 51 | - @Mapping(target = "costPrice", expression = "java(spu.getCostPrice() / 100)") | |
| 52 | - ProductSpuExcelVO convert(ProductSpuDO spu); | |
| 53 | - | |
| 54 | - default List<ProductSpuExcelVO> convertList03(List<ProductSpuDO> list) { | |
| 55 | - List<ProductSpuExcelVO> spuExcelVOs = new ArrayList<>(); | |
| 56 | - list.forEach(spu -> { | |
| 57 | - ProductSpuExcelVO spuExcelVO = convert(spu); | |
| 58 | - spuExcelVOs.add(spuExcelVO); | |
| 59 | - }); | |
| 60 | - return spuExcelVOs; | |
| 61 | - } | |
| 62 | - | |
| 63 | - ProductSpuDetailRespVO convert03(ProductSpuDO spu); | |
| 64 | - | |
| 65 | - ProductSpuRespDTO convert02(ProductSpuDO bean); | |
| 66 | - | |
| 67 | - // ========== 用户 App 相关 ========== | |
| 68 | - | |
| 69 | - PageResult<AppProductSpuPageRespVO> convertPageForGetSpuPage(PageResult<ProductSpuDO> page); | |
| 70 | - | |
| 71 | - default List<AppProductSpuPageRespVO> convertListForGetSpuList(List<ProductSpuDO> list) { | |
| 72 | - // 处理虚拟销量 | |
| 73 | - list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount())); | |
| 74 | - // 处理 VO 字段 | |
| 75 | - return convertListForGetSpuList0(list); | |
| 76 | - } | |
| 77 | - | |
| 78 | - @Named("convertListForGetSpuList0") | |
| 79 | - List<AppProductSpuPageRespVO> convertListForGetSpuList0(List<ProductSpuDO> list); | |
| 80 | - | |
| 81 | - default AppProductSpuDetailRespVO convertForGetSpuDetail(ProductSpuDO spu, List<ProductSkuDO> skus) { | |
| 82 | - // 处理 SPU | |
| 83 | - AppProductSpuDetailRespVO spuVO = convertForGetSpuDetail(spu) | |
| 84 | - .setSalesCount(spu.getSalesCount() + defaultIfNull(spu.getVirtualSalesCount(), 0)); | |
| 85 | - // 处理 SKU | |
| 86 | - spuVO.setSkus(convertListForGetSpuDetail(skus)); | |
| 31 | + default ProductSpuRespVO convert(ProductSpuDO spu, List<ProductSkuDO> skus) { | |
| 32 | + ProductSpuRespVO spuVO = BeanUtils.toBean(spu, ProductSpuRespVO.class); | |
| 33 | + spuVO.setSkus(BeanUtils.toBean(skus, ProductSkuRespVO.class)); | |
| 87 | 34 | return spuVO; |
| 88 | 35 | } |
| 89 | 36 | |
| 90 | - AppProductSpuDetailRespVO convertForGetSpuDetail(ProductSpuDO spu); | |
| 91 | - | |
| 92 | - List<AppProductSpuDetailRespVO.Sku> convertListForGetSpuDetail(List<ProductSkuDO> skus); | |
| 93 | - | |
| 94 | - default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List<ProductSkuDO> skus) { | |
| 95 | - return convert03(spu).setSkus(ProductSkuConvert.INSTANCE.convertList(skus)); | |
| 96 | - } | |
| 97 | - | |
| 98 | - default List<ProductSpuDetailRespVO> convertForSpuDetailRespListVO(List<ProductSpuDO> spus, List<ProductSkuDO> skus) { | |
| 37 | + default List<ProductSpuRespVO> convertForSpuDetailRespListVO(List<ProductSpuDO> spus, List<ProductSkuDO> skus) { | |
| 99 | 38 | Map<Long, List<ProductSkuDO>> skuMultiMap = convertMultiMap(skus, ProductSkuDO::getSpuId); |
| 100 | - return CollectionUtils.convertList(spus, spu -> convert03(spu) | |
| 101 | - .setSkus(ProductSkuConvert.INSTANCE.convertList(skuMultiMap.get(spu.getId())))); | |
| 39 | + return CollectionUtils.convertList(spus, spu -> convert(spu, skuMultiMap.get(spu.getId()))); | |
| 102 | 40 | } |
| 103 | 41 | |
| 104 | 42 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java
| ... | ... | @@ -4,7 +4,6 @@ import cn.hutool.core.lang.Assert; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | 6 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 7 | -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 8 | 7 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 9 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 9 | |
| ... | ... | @@ -56,8 +55,4 @@ public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> { |
| 56 | 55 | return update(null, updateWrapper); |
| 57 | 56 | } |
| 58 | 57 | |
| 59 | - default List<ProductSkuDO> selectListByAlarmStock() { | |
| 60 | - return selectList(new QueryWrapper<ProductSkuDO>().apply("stock <= warn_stock")); | |
| 61 | - } | |
| 62 | - | |
| 63 | 58 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.product.dal.mysql.spu; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.util.ObjUtil; | |
| 4 | 3 | import cn.hutool.core.util.ObjectUtil; |
| 5 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 7 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 8 | -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | |
| 9 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuExportReqVO; | |
| 10 | 7 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; |
| 11 | 8 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 12 | 9 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| ... | ... | @@ -15,7 +12,6 @@ import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; |
| 15 | 12 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 16 | 13 | import org.apache.ibatis.annotations.Mapper; |
| 17 | 14 | |
| 18 | -import java.util.List; | |
| 19 | 15 | import java.util.Objects; |
| 20 | 16 | import java.util.Set; |
| 21 | 17 | |
| ... | ... | @@ -81,21 +77,6 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> { |
| 81 | 77 | return selectPage(pageReqVO, query); |
| 82 | 78 | } |
| 83 | 79 | |
| 84 | - default List<ProductSpuDO> selectListByRecommendType(String recommendType, Integer count) { | |
| 85 | - QueryWrapperX<ProductSpuDO> query = new QueryWrapperX<>(); | |
| 86 | - // 上架状态 且有库存 | |
| 87 | - query.eq("status", ProductSpuStatusEnum.ENABLE.getStatus()).gt("stock", 0); | |
| 88 | - // 推荐类型的过滤条件 | |
| 89 | - if (ObjUtil.equal(recommendType, AppProductSpuPageReqVO.RECOMMEND_TYPE_HOT)) { | |
| 90 | - query.eq("recommend_hot", true); | |
| 91 | - } else if (ObjUtil.equal(recommendType, AppProductSpuPageReqVO.RECOMMEND_TYPE_GOOD)) { | |
| 92 | - query.eq("recommend_good", true); | |
| 93 | - } | |
| 94 | - // 设置最大长度 | |
| 95 | - query.limitN(count); | |
| 96 | - return selectList(query); | |
| 97 | - } | |
| 98 | - | |
| 99 | 80 | /** |
| 100 | 81 | * 更新商品 SPU 库存 |
| 101 | 82 | * |
| ... | ... | @@ -111,22 +92,6 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> { |
| 111 | 92 | } |
| 112 | 93 | |
| 113 | 94 | /** |
| 114 | - * 获得 Spu 列表 | |
| 115 | - * | |
| 116 | - * @param reqVO 查询条件 | |
| 117 | - * @return Spu 列表 | |
| 118 | - */ | |
| 119 | - default List<ProductSpuDO> selectList(ProductSpuExportReqVO reqVO) { | |
| 120 | - Integer tabType = reqVO.getTabType(); | |
| 121 | - LambdaQueryWrapperX<ProductSpuDO> queryWrapper = new LambdaQueryWrapperX<>(); | |
| 122 | - queryWrapper.eqIfPresent(ProductSpuDO::getName, reqVO.getName()); | |
| 123 | - queryWrapper.eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()); | |
| 124 | - queryWrapper.betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime()); | |
| 125 | - appendTabQuery(tabType, queryWrapper); | |
| 126 | - return selectList(queryWrapper); | |
| 127 | - } | |
| 128 | - | |
| 129 | - /** | |
| 130 | 95 | * 添加后台 Tab 选项的查询条件 |
| 131 | 96 | * |
| 132 | 97 | * @param tabType 标签类型 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java
| 1 | 1 | package cn.iocoder.yudao.module.product.service.sku; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 4 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | |
| 4 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; | |
| 5 | 5 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 6 | 6 | |
| 7 | 7 | import java.util.Collection; |
| ... | ... | @@ -32,13 +32,6 @@ public interface ProductSkuService { |
| 32 | 32 | /** |
| 33 | 33 | * 获得商品 SKU 列表 |
| 34 | 34 | * |
| 35 | - * @return 商品sku列表 | |
| 36 | - */ | |
| 37 | - List<ProductSkuDO> getSkuList(); | |
| 38 | - | |
| 39 | - /** | |
| 40 | - * 获得商品 SKU 列表 | |
| 41 | - * | |
| 42 | 35 | * @param ids 编号 |
| 43 | 36 | * @return 商品sku列表 |
| 44 | 37 | */ |
| ... | ... | @@ -49,7 +42,7 @@ public interface ProductSkuService { |
| 49 | 42 | * |
| 50 | 43 | * @param list sku组合的集合 |
| 51 | 44 | */ |
| 52 | - void validateSkuList(List<ProductSkuCreateOrUpdateReqVO> list, Boolean specType); | |
| 45 | + void validateSkuList(List<ProductSkuSaveReqVO> list, Boolean specType); | |
| 53 | 46 | |
| 54 | 47 | /** |
| 55 | 48 | * 批量创建 SKU |
| ... | ... | @@ -57,7 +50,7 @@ public interface ProductSkuService { |
| 57 | 50 | * @param spuId 商品 SPU 编号 |
| 58 | 51 | * @param list SKU 对象集合 |
| 59 | 52 | */ |
| 60 | - void createSkuList(Long spuId, List<ProductSkuCreateOrUpdateReqVO> list); | |
| 53 | + void createSkuList(Long spuId, List<ProductSkuSaveReqVO> list); | |
| 61 | 54 | |
| 62 | 55 | /** |
| 63 | 56 | * 根据 SPU 编号,批量更新它的 SKU 信息 |
| ... | ... | @@ -65,7 +58,7 @@ public interface ProductSkuService { |
| 65 | 58 | * @param spuId SPU 编码 |
| 66 | 59 | * @param skus SKU 的集合 |
| 67 | 60 | */ |
| 68 | - void updateSkuList(Long spuId, List<ProductSkuCreateOrUpdateReqVO> skus); | |
| 61 | + void updateSkuList(Long spuId, List<ProductSkuSaveReqVO> skus); | |
| 69 | 62 | |
| 70 | 63 | /** |
| 71 | 64 | * 更新 SKU 库存(增量) |
| ... | ... | @@ -100,13 +93,6 @@ public interface ProductSkuService { |
| 100 | 93 | void deleteSkuBySpuId(Long spuId); |
| 101 | 94 | |
| 102 | 95 | /** |
| 103 | - * 获得库存预警的 SKU 数组 | |
| 104 | - * | |
| 105 | - * @return SKU 数组 | |
| 106 | - */ | |
| 107 | - List<ProductSkuDO> getSkuListByAlarmStock(); | |
| 108 | - | |
| 109 | - /** | |
| 110 | 96 | * 更新 sku 属性 |
| 111 | 97 | * |
| 112 | 98 | * @param propertyId 属性 id | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
| ... | ... | @@ -3,9 +3,9 @@ package cn.iocoder.yudao.module.product.service.sku; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.collection.ListUtil; |
| 5 | 5 | import cn.hutool.core.util.ObjectUtil; |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 6 | 7 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 7 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; | |
| 8 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | |
| 8 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; | |
| 9 | 9 | import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; |
| 10 | 10 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; |
| 11 | 11 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; |
| ... | ... | @@ -14,12 +14,12 @@ import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; |
| 14 | 14 | import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; |
| 15 | 15 | import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; |
| 16 | 16 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| 17 | +import jakarta.annotation.Resource; | |
| 17 | 18 | import org.springframework.context.annotation.Lazy; |
| 18 | 19 | import org.springframework.stereotype.Service; |
| 19 | 20 | import org.springframework.transaction.annotation.Transactional; |
| 20 | 21 | import org.springframework.validation.annotation.Validated; |
| 21 | 22 | |
| 22 | -import jakarta.annotation.Resource; | |
| 23 | 23 | import java.util.*; |
| 24 | 24 | import java.util.stream.Collectors; |
| 25 | 25 | |
| ... | ... | @@ -69,11 +69,6 @@ public class ProductSkuServiceImpl implements ProductSkuService { |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | @Override |
| 72 | - public List<ProductSkuDO> getSkuList() { | |
| 73 | - return productSkuMapper.selectList(); | |
| 74 | - } | |
| 75 | - | |
| 76 | - @Override | |
| 77 | 72 | public List<ProductSkuDO> getSkuList(Collection<Long> ids) { |
| 78 | 73 | if (CollUtil.isEmpty(ids)) { |
| 79 | 74 | return ListUtil.empty(); |
| ... | ... | @@ -82,20 +77,18 @@ public class ProductSkuServiceImpl implements ProductSkuService { |
| 82 | 77 | } |
| 83 | 78 | |
| 84 | 79 | @Override |
| 85 | - public void validateSkuList(List<ProductSkuCreateOrUpdateReqVO> skus, Boolean specType) { | |
| 80 | + public void validateSkuList(List<ProductSkuSaveReqVO> skus, Boolean specType) { | |
| 86 | 81 | // 0、校验skus是否为空 |
| 87 | 82 | if (CollUtil.isEmpty(skus)) { |
| 88 | 83 | throw exception(SKU_NOT_EXISTS); |
| 89 | 84 | } |
| 90 | 85 | // 单规格,赋予单规格默认属性 |
| 91 | 86 | if (ObjectUtil.equal(specType, false)) { |
| 92 | - ProductSkuCreateOrUpdateReqVO skuVO = skus.get(0); | |
| 93 | - List<ProductSkuBaseVO.Property> properties = new ArrayList<>(); | |
| 94 | - ProductSkuBaseVO.Property property = new ProductSkuBaseVO.Property(); | |
| 95 | - property.setPropertyId(ProductPropertyDO.ID_DEFAULT); | |
| 96 | - property.setPropertyName(ProductPropertyDO.NAME_DEFAULT); | |
| 97 | - property.setValueId(ProductPropertyValueDO.ID_DEFAULT); | |
| 98 | - property.setValueName(ProductPropertyValueDO.NAME_DEFAULT); | |
| 87 | + ProductSkuSaveReqVO skuVO = skus.get(0); | |
| 88 | + List<ProductSkuSaveReqVO.Property> properties = new ArrayList<>(); | |
| 89 | + ProductSkuSaveReqVO.Property property = new ProductSkuSaveReqVO.Property() | |
| 90 | + .setPropertyId(ProductPropertyDO.ID_DEFAULT).setPropertyName(ProductPropertyDO.NAME_DEFAULT) | |
| 91 | + .setValueId(ProductPropertyValueDO.ID_DEFAULT).setValueName(ProductPropertyValueDO.NAME_DEFAULT); | |
| 99 | 92 | properties.add(property); |
| 100 | 93 | skuVO.setProperties(properties); |
| 101 | 94 | return; // 单规格不需要后续的校验 |
| ... | ... | @@ -106,7 +99,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { |
| 106 | 99 | // 遍历多个 Property 属性 |
| 107 | 100 | .flatMap(p -> p.getProperties().stream()) |
| 108 | 101 | // 将每个 Property 转换成对应的 propertyId,最后形成集合 |
| 109 | - .map(ProductSkuCreateOrUpdateReqVO.Property::getPropertyId) | |
| 102 | + .map(ProductSkuSaveReqVO.Property::getPropertyId) | |
| 110 | 103 | .collect(Collectors.toSet()); |
| 111 | 104 | List<ProductPropertyDO> propertyList = productPropertyService.getPropertyList(propertyIds); |
| 112 | 105 | if (propertyList.size() != propertyIds.size()) { |
| ... | ... | @@ -133,17 +126,18 @@ public class ProductSkuServiceImpl implements ProductSkuService { |
| 133 | 126 | // 4. 最后校验,每个 Sku 之间不是重复的 |
| 134 | 127 | // 每个元素,都是一个 Sku 的 attrValueId 集合。这样,通过最外层的 Set ,判断是否有重复的. |
| 135 | 128 | Set<Set<Long>> skuAttrValues = new HashSet<>(); |
| 136 | - for (ProductSkuCreateOrUpdateReqVO sku : skus) { | |
| 129 | + for (ProductSkuSaveReqVO sku : skus) { | |
| 137 | 130 | // 添加失败,说明重复 |
| 138 | - if (!skuAttrValues.add(convertSet(sku.getProperties(), ProductSkuCreateOrUpdateReqVO.Property::getValueId))) { | |
| 131 | + if (!skuAttrValues.add(convertSet(sku.getProperties(), ProductSkuSaveReqVO.Property::getValueId))) { | |
| 139 | 132 | throw exception(SPU_SKU_NOT_DUPLICATE); |
| 140 | 133 | } |
| 141 | 134 | } |
| 142 | 135 | } |
| 143 | 136 | |
| 144 | 137 | @Override |
| 145 | - public void createSkuList(Long spuId, List<ProductSkuCreateOrUpdateReqVO> skuCreateReqList) { | |
| 146 | - productSkuMapper.insertBatch(ProductSkuConvert.INSTANCE.convertList06(skuCreateReqList, spuId)); | |
| 138 | + public void createSkuList(Long spuId, List<ProductSkuSaveReqVO> skuCreateReqList) { | |
| 139 | + List<ProductSkuDO> skus = BeanUtils.toBean(skuCreateReqList, ProductSkuDO.class, sku -> sku.setSpuId(spuId)); | |
| 140 | + productSkuMapper.insertBatch(skus); | |
| 147 | 141 | } |
| 148 | 142 | |
| 149 | 143 | @Override |
| ... | ... | @@ -165,11 +159,6 @@ public class ProductSkuServiceImpl implements ProductSkuService { |
| 165 | 159 | } |
| 166 | 160 | |
| 167 | 161 | @Override |
| 168 | - public List<ProductSkuDO> getSkuListByAlarmStock() { | |
| 169 | - return productSkuMapper.selectListByAlarmStock(); | |
| 170 | - } | |
| 171 | - | |
| 172 | - @Override | |
| 173 | 162 | public int updateSkuProperty(Long propertyId, String propertyName) { |
| 174 | 163 | // 获取所有的 sku |
| 175 | 164 | List<ProductSkuDO> skuDOList = productSkuMapper.selectList(); |
| ... | ... | @@ -220,7 +209,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { |
| 220 | 209 | |
| 221 | 210 | @Override |
| 222 | 211 | @Transactional(rollbackFor = Exception.class) |
| 223 | - public void updateSkuList(Long spuId, List<ProductSkuCreateOrUpdateReqVO> skus) { | |
| 212 | + public void updateSkuList(Long spuId, List<ProductSkuSaveReqVO> skus) { | |
| 224 | 213 | // 构建属性与 SKU 的映射关系; |
| 225 | 214 | Map<String, Long> existsSkuMap = convertMap(productSkuMapper.selectListBySpuId(spuId), |
| 226 | 215 | ProductSkuConvert.INSTANCE::buildPropertyKey, ProductSkuDO::getId); |
| ... | ... | @@ -228,7 +217,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { |
| 228 | 217 | // 拆分三个集合,新插入的、需要更新的、需要删除的 |
| 229 | 218 | List<ProductSkuDO> insertSkus = new ArrayList<>(); |
| 230 | 219 | List<ProductSkuDO> updateSkus = new ArrayList<>(); |
| 231 | - List<ProductSkuDO> allUpdateSkus = ProductSkuConvert.INSTANCE.convertList06(skus, spuId); | |
| 220 | + List<ProductSkuDO> allUpdateSkus = BeanUtils.toBean(skus, ProductSkuDO.class, sku -> sku.setSpuId(spuId)); | |
| 232 | 221 | allUpdateSkus.forEach(sku -> { |
| 233 | 222 | String propertiesKey = ProductSkuConvert.INSTANCE.buildPropertyKey(sku); |
| 234 | 223 | // 1、找得到的,进行更新 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java
| 1 | 1 | package cn.iocoder.yudao.module.product.service.spu; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | |
| 4 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; | |
| 5 | 7 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 6 | 8 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 7 | - | |
| 8 | 9 | import jakarta.validation.Valid; |
| 9 | 10 | import org.springframework.scheduling.annotation.Async; |
| 10 | 11 | |
| ... | ... | @@ -12,8 +13,6 @@ import java.util.Collection; |
| 12 | 13 | import java.util.List; |
| 13 | 14 | import java.util.Map; |
| 14 | 15 | |
| 15 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | |
| 16 | - | |
| 17 | 16 | /** |
| 18 | 17 | * 商品 SPU Service 接口 |
| 19 | 18 | * |
| ... | ... | @@ -27,14 +26,14 @@ public interface ProductSpuService { |
| 27 | 26 | * @param createReqVO 创建信息 |
| 28 | 27 | * @return 编号 |
| 29 | 28 | */ |
| 30 | - Long createSpu(@Valid ProductSpuCreateReqVO createReqVO); | |
| 29 | + Long createSpu(@Valid ProductSpuSaveReqVO createReqVO); | |
| 31 | 30 | |
| 32 | 31 | /** |
| 33 | 32 | * 更新商品 SPU |
| 34 | 33 | * |
| 35 | 34 | * @param updateReqVO 更新信息 |
| 36 | 35 | */ |
| 37 | - void updateSpu(@Valid ProductSpuUpdateReqVO updateReqVO); | |
| 36 | + void updateSpu(@Valid ProductSpuSaveReqVO updateReqVO); | |
| 38 | 37 | |
| 39 | 38 | /** |
| 40 | 39 | * 删除商品 SPU |
| ... | ... | @@ -60,16 +59,6 @@ public interface ProductSpuService { |
| 60 | 59 | List<ProductSpuDO> getSpuList(Collection<Long> ids); |
| 61 | 60 | |
| 62 | 61 | /** |
| 63 | - * 获得商品 SPU 映射 | |
| 64 | - * | |
| 65 | - * @param ids 编号数组 | |
| 66 | - * @return 商品 SPU 映射 | |
| 67 | - */ | |
| 68 | - default Map<Long, ProductSpuDO> getSpuMap(Collection<Long> ids) { | |
| 69 | - return convertMap(getSpuList(ids), ProductSpuDO::getId); | |
| 70 | - } | |
| 71 | - | |
| 72 | - /** | |
| 73 | 62 | * 获得指定状态的商品 SPU 列表 |
| 74 | 63 | * |
| 75 | 64 | * @param status 状态 |
| ... | ... | @@ -78,14 +67,6 @@ public interface ProductSpuService { |
| 78 | 67 | List<ProductSpuDO> getSpuListByStatus(Integer status); |
| 79 | 68 | |
| 80 | 69 | /** |
| 81 | - * 获得所有商品 SPU 列表 | |
| 82 | - * | |
| 83 | - * @param reqVO 导出条件 | |
| 84 | - * @return 商品 SPU 列表 | |
| 85 | - */ | |
| 86 | - List<ProductSpuDO> getSpuList(ProductSpuExportReqVO reqVO); | |
| 87 | - | |
| 88 | - /** | |
| 89 | 70 | * 获得商品 SPU 分页,提供给挂你兰后台使用 |
| 90 | 71 | * |
| 91 | 72 | * @param pageReqVO 分页查询 |
| ... | ... | @@ -102,15 +83,6 @@ public interface ProductSpuService { |
| 102 | 83 | PageResult<ProductSpuDO> getSpuPage(AppProductSpuPageReqVO pageReqVO); |
| 103 | 84 | |
| 104 | 85 | /** |
| 105 | - * 获得商品 SPU 列表,提供给用户 App 使用 | |
| 106 | - * | |
| 107 | - * @param recommendType 推荐类型 | |
| 108 | - * @param count 数量 | |
| 109 | - * @return 商品 SPU 列表 | |
| 110 | - */ | |
| 111 | - List<ProductSpuDO> getSpuList(String recommendType, Integer count); | |
| 112 | - | |
| 113 | - /** | |
| 114 | 86 | * 更新商品 SPU 库存(增量) |
| 115 | 87 | * |
| 116 | 88 | * @param stockIncrCounts SPU 编号与库存变化(增量)的映射 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| ... | ... | @@ -5,11 +5,13 @@ import cn.hutool.core.util.ObjectUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 8 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 8 | 9 | import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; |
| 9 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | |
| 10 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | |
| 10 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; | |
| 11 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; | |
| 12 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO; | |
| 13 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; | |
| 11 | 14 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 12 | -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; | |
| 13 | 15 | import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; |
| 14 | 16 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 15 | 17 | import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; |
| ... | ... | @@ -53,15 +55,15 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 53 | 55 | |
| 54 | 56 | @Override |
| 55 | 57 | @Transactional(rollbackFor = Exception.class) |
| 56 | - public Long createSpu(ProductSpuCreateReqVO createReqVO) { | |
| 58 | + public Long createSpu(ProductSpuSaveReqVO createReqVO) { | |
| 57 | 59 | // 校验分类、品牌 |
| 58 | 60 | validateCategory(createReqVO.getCategoryId()); |
| 59 | 61 | brandService.validateProductBrand(createReqVO.getBrandId()); |
| 60 | 62 | // 校验 SKU |
| 61 | - List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus(); | |
| 63 | + List<ProductSkuSaveReqVO> skuSaveReqList = createReqVO.getSkus(); | |
| 62 | 64 | productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); |
| 63 | 65 | |
| 64 | - ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); | |
| 66 | + ProductSpuDO spu = BeanUtils.toBean(createReqVO, ProductSpuDO.class); | |
| 65 | 67 | // 初始化 SPU 中 SKU 相关属性 |
| 66 | 68 | initSpuFromSkus(spu, skuSaveReqList); |
| 67 | 69 | // 插入 SPU |
| ... | ... | @@ -74,18 +76,18 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 74 | 76 | |
| 75 | 77 | @Override |
| 76 | 78 | @Transactional(rollbackFor = Exception.class) |
| 77 | - public void updateSpu(ProductSpuUpdateReqVO updateReqVO) { | |
| 79 | + public void updateSpu(ProductSpuSaveReqVO updateReqVO) { | |
| 78 | 80 | // 校验 SPU 是否存在 |
| 79 | 81 | validateSpuExists(updateReqVO.getId()); |
| 80 | 82 | // 校验分类、品牌 |
| 81 | 83 | validateCategory(updateReqVO.getCategoryId()); |
| 82 | 84 | brandService.validateProductBrand(updateReqVO.getBrandId()); |
| 83 | 85 | // 校验SKU |
| 84 | - List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = updateReqVO.getSkus(); | |
| 86 | + List<ProductSkuSaveReqVO> skuSaveReqList = updateReqVO.getSkus(); | |
| 85 | 87 | productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); |
| 86 | 88 | |
| 87 | 89 | // 更新 SPU |
| 88 | - ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); | |
| 90 | + ProductSpuDO updateObj = BeanUtils.toBean(updateReqVO, ProductSpuDO.class); | |
| 89 | 91 | initSpuFromSkus(updateObj, skuSaveReqList); |
| 90 | 92 | productSpuMapper.updateById(updateObj); |
| 91 | 93 | // 批量更新 SKU |
| ... | ... | @@ -99,26 +101,20 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 99 | 101 | * @param spu 商品 SPU |
| 100 | 102 | * @param skus 商品 SKU 数组 |
| 101 | 103 | */ |
| 102 | - private void initSpuFromSkus(ProductSpuDO spu, List<ProductSkuCreateOrUpdateReqVO> skus) { | |
| 104 | + private void initSpuFromSkus(ProductSpuDO spu, List<ProductSkuSaveReqVO> skus) { | |
| 103 | 105 | // sku 单价最低的商品的价格 |
| 104 | - spu.setPrice(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getPrice)); | |
| 106 | + spu.setPrice(getMinValue(skus, ProductSkuSaveReqVO::getPrice)); | |
| 105 | 107 | // sku 单价最低的商品的市场价格 |
| 106 | - spu.setMarketPrice(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getMarketPrice)); | |
| 108 | + spu.setMarketPrice(getMinValue(skus, ProductSkuSaveReqVO::getMarketPrice)); | |
| 107 | 109 | // sku 单价最低的商品的成本价格 |
| 108 | - spu.setCostPrice(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getCostPrice)); | |
| 109 | - // sku 单价最低的商品的条形码 TODO 芋艿:条形码字段,是不是可以删除 | |
| 110 | - spu.setBarCode(""); | |
| 111 | -// spu.setBarCode(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getBarCode)); | |
| 110 | + spu.setCostPrice(getMinValue(skus, ProductSkuSaveReqVO::getCostPrice)); | |
| 112 | 111 | // skus 库存总数 |
| 113 | - spu.setStock(getSumValue(skus, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum)); | |
| 112 | + spu.setStock(getSumValue(skus, ProductSkuSaveReqVO::getStock, Integer::sum)); | |
| 114 | 113 | // 若是 spu 已有状态则不处理 |
| 115 | 114 | if (spu.getStatus() == null) { |
| 116 | - // 默认状态为上架 | |
| 117 | - spu.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()); | |
| 118 | - // 默认商品销量 | |
| 119 | - spu.setSalesCount(0); | |
| 120 | - // 默认商品浏览量 | |
| 121 | - spu.setBrowseCount(0); | |
| 115 | + spu.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()); // 默认状态为上架 | |
| 116 | + spu.setSalesCount(0); // 默认商品销量 | |
| 117 | + spu.setBrowseCount(0); // 默认商品浏览量 | |
| 122 | 118 | } |
| 123 | 119 | } |
| 124 | 120 | |
| ... | ... | @@ -204,11 +200,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 204 | 200 | } |
| 205 | 201 | |
| 206 | 202 | @Override |
| 207 | - public List<ProductSpuDO> getSpuList(ProductSpuExportReqVO reqVO) { | |
| 208 | - return productSpuMapper.selectList(reqVO); | |
| 209 | - } | |
| 210 | - | |
| 211 | - @Override | |
| 212 | 203 | public PageResult<ProductSpuDO> getSpuPage(ProductSpuPageReqVO pageReqVO) { |
| 213 | 204 | return productSpuMapper.selectPage(pageReqVO); |
| 214 | 205 | } |
| ... | ... | @@ -234,11 +225,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 234 | 225 | } |
| 235 | 226 | |
| 236 | 227 | @Override |
| 237 | - public List<ProductSpuDO> getSpuList(String recommendType, Integer count) { | |
| 238 | - return productSpuMapper.selectListByRecommendType(recommendType, count); | |
| 239 | - } | |
| 240 | - | |
| 241 | - @Override | |
| 242 | 228 | @Transactional(rollbackFor = Exception.class) |
| 243 | 229 | public void updateSpuStock(Map<Long, Integer> stockIncrCounts) { |
| 244 | 230 | stockIncrCounts.forEach((id, incCount) -> productSpuMapper.updateStock(id, incCount)); | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceTest.java
| ... | ... | @@ -4,7 +4,7 @@ import cn.hutool.core.util.RandomUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | 5 | import cn.iocoder.yudao.framework.test.core.util.AssertUtils; |
| 6 | 6 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 7 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 9 | 9 | import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; |
| 10 | 10 | import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; |
| ... | ... | @@ -74,13 +74,13 @@ public class ProductSkuServiceTest extends BaseDbUnitTest { |
| 74 | 74 | // 准备参数 |
| 75 | 75 | Long spuId = 1L; |
| 76 | 76 | String spuName = "测试商品"; |
| 77 | - List<ProductSkuCreateOrUpdateReqVO> skus = Arrays.asList( | |
| 78 | - randomPojo(ProductSkuCreateOrUpdateReqVO.class, o -> { // 测试更新 | |
| 79 | - o.setProperties(singletonList(new ProductSkuCreateOrUpdateReqVO.Property( | |
| 77 | + List<ProductSkuSaveReqVO> skus = Arrays.asList( | |
| 78 | + randomPojo(ProductSkuSaveReqVO.class, o -> { // 测试更新 | |
| 79 | + o.setProperties(singletonList(new ProductSkuSaveReqVO.Property( | |
| 80 | 80 | 10L, "颜色", 20L, "红色"))); |
| 81 | 81 | }), |
| 82 | - randomPojo(ProductSkuCreateOrUpdateReqVO.class, o -> { // 测试新增 | |
| 83 | - o.setProperties(singletonList(new ProductSkuCreateOrUpdateReqVO.Property( | |
| 82 | + randomPojo(ProductSkuSaveReqVO.class, o -> { // 测试新增 | |
| 83 | + o.setProperties(singletonList(new ProductSkuSaveReqVO.Property( | |
| 84 | 84 | 10L, "颜色", 20L, "红色"))); |
| 85 | 85 | }) |
| 86 | 86 | ); | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java
| ... | ... | @@ -6,12 +6,9 @@ import cn.hutool.core.util.RandomUtil; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 8 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 9 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | |
| 10 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; | |
| 9 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; | |
| 11 | 10 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; |
| 12 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; | |
| 13 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; | |
| 14 | -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; | |
| 11 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO; | |
| 15 | 12 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 16 | 13 | import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; |
| 17 | 14 | import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; |
| ... | ... | @@ -21,13 +18,13 @@ import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; |
| 21 | 18 | import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; |
| 22 | 19 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuServiceImpl; |
| 23 | 20 | import com.google.common.collect.Lists; |
| 21 | +import jakarta.annotation.Resource; | |
| 24 | 22 | import org.junit.jupiter.api.Assertions; |
| 25 | 23 | import org.junit.jupiter.api.Disabled; |
| 26 | 24 | import org.junit.jupiter.api.Test; |
| 27 | 25 | import org.springframework.boot.test.mock.mockito.MockBean; |
| 28 | 26 | import org.springframework.context.annotation.Import; |
| 29 | 27 | |
| 30 | -import jakarta.annotation.Resource; | |
| 31 | 28 | import java.math.RoundingMode; |
| 32 | 29 | import java.util.ArrayList; |
| 33 | 30 | import java.util.Date; |
| ... | ... | @@ -87,20 +84,19 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { |
| 87 | 84 | @Test |
| 88 | 85 | public void testCreateSpu_success() { |
| 89 | 86 | // 准备参数 |
| 90 | - ProductSkuCreateOrUpdateReqVO skuCreateOrUpdateReqVO = randomPojo(ProductSkuCreateOrUpdateReqVO.class,o->{ | |
| 87 | + ProductSkuSaveReqVO skuCreateOrUpdateReqVO = randomPojo(ProductSkuSaveReqVO.class, o->{ | |
| 91 | 88 | // 限制范围为正整数 |
| 92 | 89 | o.setCostPrice(generaInt()); |
| 93 | 90 | o.setPrice(generaInt()); |
| 94 | 91 | o.setMarketPrice(generaInt()); |
| 95 | 92 | o.setStock(generaInt()); |
| 96 | - o.setWarnStock(10); | |
| 97 | 93 | o.setFirstBrokeragePrice(generaInt()); |
| 98 | 94 | o.setSecondBrokeragePrice(generaInt()); |
| 99 | 95 | // 限制分数为两位数 |
| 100 | 96 | o.setWeight(RandomUtil.randomDouble(10,2, RoundingMode.HALF_UP)); |
| 101 | 97 | o.setVolume(RandomUtil.randomDouble(10,2, RoundingMode.HALF_UP)); |
| 102 | 98 | }); |
| 103 | - ProductSpuCreateReqVO createReqVO = randomPojo(ProductSpuCreateReqVO.class,o->{ | |
| 99 | + ProductSpuSaveReqVO createReqVO = randomPojo(ProductSpuSaveReqVO.class,o->{ | |
| 104 | 100 | o.setCategoryId(generateId()); |
| 105 | 101 | o.setBrandId(generateId()); |
| 106 | 102 | o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 |
| ... | ... | @@ -134,13 +130,12 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { |
| 134 | 130 | }); |
| 135 | 131 | productSpuMapper.insert(createReqVO); |
| 136 | 132 | // 准备参数 |
| 137 | - ProductSkuCreateOrUpdateReqVO skuCreateOrUpdateReqVO = randomPojo(ProductSkuCreateOrUpdateReqVO.class,o->{ | |
| 133 | + ProductSkuSaveReqVO skuCreateOrUpdateReqVO = randomPojo(ProductSkuSaveReqVO.class, o->{ | |
| 138 | 134 | // 限制范围为正整数 |
| 139 | 135 | o.setCostPrice(generaInt()); |
| 140 | 136 | o.setPrice(generaInt()); |
| 141 | 137 | o.setMarketPrice(generaInt()); |
| 142 | 138 | o.setStock(generaInt()); |
| 143 | - o.setWarnStock(10); | |
| 144 | 139 | o.setFirstBrokeragePrice(generaInt()); |
| 145 | 140 | o.setSecondBrokeragePrice(generaInt()); |
| 146 | 141 | // 限制分数为两位数 |
| ... | ... | @@ -148,7 +143,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { |
| 148 | 143 | o.setVolume(RandomUtil.randomDouble(10,2, RoundingMode.HALF_UP)); |
| 149 | 144 | }); |
| 150 | 145 | // 准备参数 |
| 151 | - ProductSpuUpdateReqVO reqVO = randomPojo(ProductSpuUpdateReqVO.class, o -> { | |
| 146 | + ProductSpuSaveReqVO reqVO = randomPojo(ProductSpuSaveReqVO.class, o -> { | |
| 152 | 147 | o.setId(createReqVO.getId()); // 设置更新的 ID |
| 153 | 148 | o.setCategoryId(generateId()); |
| 154 | 149 | o.setBrandId(generateId()); |
| ... | ... | @@ -158,7 +153,6 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { |
| 158 | 153 | o.setGiveIntegral(generaInt()); // 限制范围为正整数 |
| 159 | 154 | o.setSalesCount(generaInt()); // 限制范围为正整数 |
| 160 | 155 | o.setBrowseCount(generaInt()); // 限制范围为正整数 |
| 161 | - o.setStatus(0); | |
| 162 | 156 | o.setSkus(newArrayList(skuCreateOrUpdateReqVO,skuCreateOrUpdateReqVO,skuCreateOrUpdateReqVO)); |
| 163 | 157 | }); |
| 164 | 158 | when(categoryService.getCategoryLevel(eq(reqVO.getCategoryId()))).thenReturn(2); |
| ... | ... | @@ -171,7 +165,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { |
| 171 | 165 | |
| 172 | 166 | @Test |
| 173 | 167 | public void testValidateSpuExists_exception() { |
| 174 | - ProductSpuUpdateReqVO reqVO = randomPojo(ProductSpuUpdateReqVO.class); | |
| 168 | + ProductSpuSaveReqVO reqVO = randomPojo(ProductSpuSaveReqVO.class); | |
| 175 | 169 | // 调用 |
| 176 | 170 | Assertions.assertThrows(ServiceException.class, () -> productSpuService.updateSpu(reqVO)); |
| 177 | 171 | } |
| ... | ... | @@ -394,8 +388,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { |
| 394 | 388 | |
| 395 | 389 | PageResult<ProductSpuDO> spuPage = productSpuService.getSpuPage(productSpuPageReqVO); |
| 396 | 390 | |
| 397 | - PageResult<ProductSpuRespVO> result = ProductSpuConvert.INSTANCE.convertPage(productSpuMapper.selectPage(productSpuPageReqVO)); | |
| 398 | - assertEquals(result.getTotal(), spuPage.getTotal()); | |
| 391 | + assertEquals(1, spuPage.getTotal()); | |
| 399 | 392 | } |
| 400 | 393 | |
| 401 | 394 | /** | ... | ... |