From c06077e3a6be384fabc0877f9905a1af6a96d33e Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 5 Sep 2022 21:02:44 +0800 Subject: [PATCH] =?UTF-8?q?mall=EF=BC=9Acode=20review=20=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/sku/ProductSkuController.java | 75 +------------ .../admin/sku/vo/ProductSkuBaseVO.java | 6 - .../sku/vo/ProductSkuCreateOrUpdateReqVO.java | 7 ++ .../admin/sku/vo/ProductSkuExcelVO.java | 53 --------- .../admin/sku/vo/ProductSkuExportReqVO.java | 43 -------- .../admin/sku/vo/ProductSkuPageReqVO.java | 45 -------- .../admin/sku/vo/ProductSkuRespVO.java | 18 ++- .../admin/sku/vo/ProductSkuUpdateReqVO.java | 18 --- .../admin/spu/ProductSpuController.java | 20 ++-- .../admin/spu/vo/ProductSpuBaseVO.java | 3 +- .../admin/spu/vo/ProductSpuDetailRespVO.java | 57 ++++++++++ ...ageReqVO.java => ProductSpuPageReqVO.java} | 4 +- .../{SpuRespVO.java => ProductSpuRespVO.java} | 10 +- .../app/spu/AppProductSpuController.java | 1 - .../controller/app/spu/vo/AppSpuRespVO.java | 5 +- .../property/ProductPropertyConvert.java | 8 +- .../convert/sku/ProductSkuConvert.java | 9 -- .../convert/spu/ProductSpuConvert.java | 8 +- .../mysql/property/ProductPropertyMapper.java | 13 +-- .../dal/mysql/sku/ProductSkuMapper.java | 19 +--- .../dal/mysql/spu/ProductSpuMapper.java | 4 +- .../service/sku/ProductSkuService.java | 26 ----- .../service/sku/ProductSkuServiceImpl.java | 26 ----- .../service/spu/ProductSpuService.java | 8 +- .../service/spu/ProductSpuServiceImpl.java | 14 +-- .../service/sku/SkuServiceImplTest.java | 103 +----------------- .../spu/ProductSpuServiceImplTest.java | 8 +- 27 files changed, 126 insertions(+), 485 deletions(-) delete mode 100755 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExcelVO.java delete mode 100755 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExportReqVO.java delete mode 100755 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuPageReqVO.java delete mode 100755 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuUpdateReqVO.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/{SpuPageReqVO.java => ProductSpuPageReqVO.java} (92%) rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/{SpuRespVO.java => ProductSpuRespVO.java} (90%) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java index cefa6afe08..2081e7da80 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java @@ -1,27 +1,9 @@ package cn.iocoder.yudao.module.product.controller.admin.sku; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @Api(tags = "管理后台 - 商品 sku") @RestController @@ -29,57 +11,4 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Validated public class ProductSkuController { - @Resource - private ProductSkuService ProductSkuService; - - @PostMapping("/create") - @ApiOperation("创建商品sku") - @PreAuthorize("@ss.hasPermission('product:sku:create')") - public CommonResult createSku(@Valid @RequestBody ProductSkuCreateOrUpdateReqVO createReqVO) { - return success(ProductSkuService.createSku(createReqVO)); - } - - @PutMapping("/update") - @ApiOperation("更新商品sku") - @PreAuthorize("@ss.hasPermission('product:sku:update')") - public CommonResult updateSku(@Valid @RequestBody ProductSkuUpdateReqVO updateReqVO) { - ProductSkuService.updateSku(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @ApiOperation("删除商品sku") - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) - @PreAuthorize("@ss.hasPermission('product:sku:delete')") - public CommonResult deleteSku(@RequestParam("id") Long id) { - ProductSkuService.deleteSku(id); - return success(true); - } - - @GetMapping("/get") - @ApiOperation("获得商品sku") - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) - @PreAuthorize("@ss.hasPermission('product:sku:query')") - public CommonResult getSku(@RequestParam("id") Long id) { - ProductSkuDO sku = ProductSkuService.getSku(id); - return success(ProductSkuConvert.INSTANCE.convert(sku)); - } - - @GetMapping("/list") - @ApiOperation("获得商品sku列表") - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) - @PreAuthorize("@ss.hasPermission('product:sku:query')") - public CommonResult> getSkuList(@RequestParam("ids") Collection ids) { - List list = ProductSkuService.getSkuList(ids); - return success(ProductSkuConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @ApiOperation("获得商品sku分页") - @PreAuthorize("@ss.hasPermission('product:sku:query')") - public CommonResult> getSkuPage(@Valid ProductSkuPageReqVO pageVO) { - PageResult pageResult = ProductSkuService.getSkuPage(pageVO); - return success(ProductSkuConvert.INSTANCE.convertPage(pageResult)); - } - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java index c6d8b54599..43f67ee530 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java @@ -8,7 +8,6 @@ import lombok.Data; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; -import java.util.List; /** * 商品 SKU Base VO,提供给添加、修改、详细的子 VO 使用 @@ -21,11 +20,6 @@ public class ProductSkuBaseVO { @NotEmpty(message = "商品 SKU 名字不能为空") private String name; - /** - * 规格值数组 - */ - private List properties; - @ApiModelProperty(value = "销售价格,单位:分", required = true, example = "1024", notes = "单位:分") @NotNull(message = "销售价格,单位:分不能为空") private Integer price; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java index adc4500113..84d71d9b74 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java @@ -6,6 +6,8 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; +import java.util.List; + @ApiModel("管理后台 - 商品 SKU 创建/更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) @@ -16,4 +18,9 @@ public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO { @ApiModelProperty(value = "商品 id 更新时须有", example = "1") private Long id; + /** + * 规格值数组 + */ + private List properties; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExcelVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExcelVO.java deleted file mode 100755 index 7caf1313d2..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExcelVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.util.Date; -import java.util.List; - -/** - * 商品sku Excel VO - * - * @author 芋道源码 - */ -@Data -public class ProductSkuExcelVO { - - @ExcelProperty("主键") - private Long id; - - @ExcelProperty("spu编号") - private Long spuId; - - // TODO @franky:这个单元格,可能会有点展示的问题 - @ExcelProperty("规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]") - private List properties; - - @ExcelProperty("销售价格,单位:分") - private Integer price; - - @ExcelProperty("原价, 单位: 分") - private Integer originalPrice; - - @ExcelProperty("成本价,单位: 分") - private Integer costPrice; - - @ExcelProperty("条形码") - private String barCode; - - @ExcelProperty("图片地址") - private String picUrl; - - @ExcelProperty("状态: 0-正常 1-禁用") - private Integer status; - - @ExcelProperty("创建时间") - private Date createTime; - - @Data - public static class Property { - private Integer propertyId; - private Integer valueId; - } -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExportReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExportReqVO.java deleted file mode 100755 index 0bf34a67d2..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExportReqVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import lombok.*; -import java.util.*; -import io.swagger.annotations.*; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@ApiModel(value = "管理后台 - 商品sku Excel 导出 Request VO", description = "参数和 SkuPageReqVO 是一致的") -@Data -public class ProductSkuExportReqVO { - - @ApiModelProperty(value = "spu编号") - private Long spuId; - - @ApiModelProperty(value = "规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]") - private String properties; - - @ApiModelProperty(value = "销售价格,单位:分") - private Integer price; - - @ApiModelProperty(value = "原价, 单位: 分") - private Integer originalPrice; - - @ApiModelProperty(value = "成本价,单位: 分") - private Integer costPrice; - - @ApiModelProperty(value = "条形码") - private String barCode; - - @ApiModelProperty(value = "图片地址") - private String picUrl; - - @ApiModelProperty(value = "状态: 0-正常 1-禁用") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "创建时间") - private Date[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuPageReqVO.java deleted file mode 100755 index b5a4949025..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import lombok.*; -import java.util.*; -import io.swagger.annotations.*; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@ApiModel("管理后台 - 商品sku分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSkuPageReqVO extends PageParam { - - @ApiModelProperty(value = "spu编号") - private Long spuId; - - @ApiModelProperty(value = "规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]") - private String properties; - - @ApiModelProperty(value = "销售价格,单位:分") - private Integer price; - - @ApiModelProperty(value = "原价, 单位: 分") - private Integer originalPrice; - - @ApiModelProperty(value = "成本价,单位: 分") - private Integer costPrice; - - @ApiModelProperty(value = "条形码") - private String barCode; - - @ApiModelProperty(value = "图片地址") - private String picUrl; - - @ApiModelProperty(value = "状态: 0-正常 1-禁用") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "创建时间") - private Date[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java index 3b12ba21c7..46e76cc63c 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java @@ -1,8 +1,13 @@ package cn.iocoder.yudao.module.product.controller.admin.sku.vo; -import lombok.*; -import java.util.*; -import io.swagger.annotations.*; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Date; +import java.util.List; @ApiModel("管理后台 - 商品sku Response VO") @Data @@ -10,10 +15,15 @@ import io.swagger.annotations.*; @ToString(callSuper = true) public class ProductSkuRespVO extends ProductSkuBaseVO { - @ApiModelProperty(value = "主键", required = true) + @ApiModelProperty(value = "主键", required = true, example = "1024") private Long id; @ApiModelProperty(value = "创建时间") private Date createTime; + /** + * 规格值数组 + */ + private List properties; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuUpdateReqVO.java deleted file mode 100755 index 984976eeec..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuUpdateReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import lombok.*; -import java.util.*; -import io.swagger.annotations.*; -import javax.validation.constraints.*; - -@ApiModel("管理后台 - 商品sku更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSkuUpdateReqVO extends ProductSkuBaseVO { - - @ApiModelProperty(value = "主键", required = true) - @NotNull(message = "主键不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java index 4fa59012df..ddae45dc25 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java @@ -3,9 +3,9 @@ package cn.iocoder.yudao.module.product.controller.admin.spu; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; @@ -48,7 +48,7 @@ public class ProductSpuController { } @DeleteMapping("/delete") - @ApiOperation("删除商品spu") + @ApiOperation("删除商品 SPU") @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('product:spu:delete')") public CommonResult deleteSpu(@RequestParam("id") Long id) { @@ -57,26 +57,28 @@ public class ProductSpuController { } @GetMapping("/get") - @ApiOperation("获得商品spu") + @ApiOperation("获得商品 SPU") @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult getSpu(@RequestParam("id") Long id) { + public CommonResult getSpu(@RequestParam("id") Long id) { return success(spuService.getSpu(id)); } + // TODO @luowenfeng:新增 get-detail,返回 SpuDetailRespVO + @GetMapping("/list") - @ApiOperation("获得商品spu列表") + @ApiOperation("获得商品 SPU 列表") @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuList(@RequestParam("ids") Collection ids) { + public CommonResult> getSpuList(@RequestParam("ids") Collection ids) { List list = spuService.getSpuList(ids); return success(ProductSpuConvert.INSTANCE.convertList(list)); } @GetMapping("/page") - @ApiOperation("获得商品spu分页") + @ApiOperation("获得商品 SPU 分页") @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuPage(@Valid SpuPageReqVO pageVO) { + public CommonResult> getSpuPage(@Valid ProductSpuPageReqVO pageVO) { return success(spuService.getSpuPage(pageVO)); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java index 5f6c69e94e..ec58bab765 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java @@ -35,8 +35,7 @@ public class ProductSpuBaseVO { @NotNull(message = "商品分类编号不能为空") private Long categoryId; - @ApiModelProperty(value = "商品品牌编号", required = true, example = "1") -// @NotNull(message = "商品品牌编号不能为空") + @ApiModelProperty(value = "商品品牌编号", example = "1") private Long brandId; @ApiModelProperty(value = "商品图片的数组", required = true) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java new file mode 100644 index 0000000000..dafb0a6802 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.product.controller.admin.spu.vo; + +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Date; +import java.util.List; + +@ApiModel(value = "管理后台 - 商品 SPU 详细 Response VO", description = "包括关联的 SKU 等信息") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ProductSpuDetailRespVO extends ProductSpuBaseVO { + + @ApiModelProperty(value = "主键", required = true, example = "1") + private Long id; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + /** + * SKU 数组 + */ + private List skus; + + @ApiModel(value = "管理后台 - 商品 SKU 详细 Response VO") + @Data + @EqualsAndHashCode(callSuper = true) + @ToString(callSuper = true) + public static class Sku extends ProductSkuBaseVO { + + /** + * 规格的数组 + */ + private List properties; + + } + + @ApiModel(value = "管理后台 - 商品规格的详细 Response VO") + @Data + @EqualsAndHashCode(callSuper = true) + @ToString(callSuper = true) + public static class Property extends ProductSkuBaseVO.Property { + + @ApiModelProperty(value = "规格的名字", required = true, example = "颜色") + private String propertyName; + + @ApiModelProperty(value = "规格值的名字", required = true, example = "蓝色") + private String valueName; + + } + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java similarity index 92% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuPageReqVO.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java index 1af946ebe1..36a37541bd 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuPageReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java @@ -8,11 +8,11 @@ import org.springframework.format.annotation.DateTimeFormat; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@ApiModel("管理后台 - 商品spu分页 Request VO") +@ApiModel("管理后台 - 商品 SPU 分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class SpuPageReqVO extends PageParam { +public class ProductSpuPageReqVO extends PageParam { @ApiModelProperty(value = "商品名称") private String name; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java similarity index 90% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuRespVO.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java index 7cdf6f975e..9db319fdc6 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java @@ -9,16 +9,14 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import java.util.Date; -import java.util.LinkedList; import java.util.List; -@ApiModel("管理后台 - 商品spu Response VO") +// TODO @Luowenfeng:这个类只返回 SPU 相关的信息,删除 skus、categoryIds、productPropertyViews;明细使用 SpuDetailRespVO 替代 +@ApiModel("管理后台 - 商品 SPU Response VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class SpuRespVO extends ProductSpuBaseVO { - - // TODO @franky:注解要完整 +public class ProductSpuRespVO extends ProductSpuBaseVO { @ApiModelProperty(value = "主键", required = true, example = "1") private Long id; @@ -33,7 +31,7 @@ public class SpuRespVO extends ProductSpuBaseVO { private List skus; @ApiModelProperty(value = "分类id数组,一直递归到一级父节点", example = "[1,2,4]") - private LinkedList categoryIds; + private List categoryIds; // TODO @芋艿:再琢磨下 这个 VO 类,其实变成 SpuRespVO 内嵌的 VO 类会更好一点;然后把 SpuRespVO 改成 SpuDetailSpuVO diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java index 1cb07eec50..7e0f912b4d 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.product.controller.app.spu; import cn.hutool.core.bean.BeanUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuRespVO; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuRespVO.java index 7f638a7041..b459873700 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuRespVO.java @@ -1,10 +1,9 @@ package cn.iocoder.yudao.module.product.controller.app.spu.vo; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.ToString; /** *

@@ -16,7 +15,7 @@ import lombok.ToString; @ApiModel("App - 商品spu Response VO") @Data @EqualsAndHashCode(callSuper = true) -public class AppSpuRespVO extends SpuRespVO { +public class AppSpuRespVO extends ProductSpuRespVO { } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java index eb6bc55e23..52b82a2ea6 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java @@ -1,17 +1,15 @@ package cn.iocoder.yudao.module.product.convert.property; -import java.util.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; - import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyAndValueRespVO; import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyExcelVO; import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyUpdateReqVO; import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +import java.util.List; + /** * 规格名称 Convert * @@ -32,6 +30,4 @@ public interface ProductPropertyConvert { PageResult convertPage(PageResult page); - List convertList02(List list); - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java index 8011ac0772..0ee468d36a 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java @@ -1,10 +1,7 @@ package cn.iocoder.yudao.module.product.convert.sku; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuExcelVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -24,8 +21,6 @@ public interface ProductSkuConvert { ProductSkuDO convert(ProductSkuCreateOrUpdateReqVO bean); - ProductSkuDO convert(ProductSkuUpdateReqVO bean); - @Mapping(source = "properties", target = "properties") ProductSkuRespVO convert(ProductSkuDO bean); @@ -33,8 +28,4 @@ public interface ProductSkuConvert { List convertSkuDOList(List list); - PageResult convertPage(PageResult page); - - List convertList02(List list); - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java index 4ff755b930..2fb6639ab4 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java @@ -24,13 +24,13 @@ public interface ProductSpuConvert { ProductSpuDO convert(ProductSpuUpdateReqVO bean); - SpuRespVO convert(ProductSpuDO bean); + ProductSpuRespVO convert(ProductSpuDO bean); - List convertList(List list); + List convertList(List list); - PageResult convertPage(PageResult page); + PageResult convertPage(PageResult page); - SpuPageReqVO convert(AppSpuPageReqVO bean); + ProductSpuPageReqVO convert(AppSpuPageReqVO bean); AppSpuPageRespVO convertAppResp(ProductSpuDO list); diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java index 2272c0a524..bd088466f6 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java @@ -1,11 +1,8 @@ package cn.iocoder.yudao.module.product.dal.mysql.property; -import java.util.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyExportReqVO; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; import org.apache.ibatis.annotations.Mapper; @@ -26,12 +23,4 @@ public interface ProductPropertyMapper extends BaseMapperX { .orderByDesc(ProductPropertyDO::getId)); } - default List selectList(ProductPropertyExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ProductPropertyDO::getName, reqVO.getName()) - .eqIfPresent(ProductPropertyDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(ProductPropertyDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductPropertyDO::getId)); - } - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java index 0e3c8653ca..cc45e5764e 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java @@ -1,37 +1,20 @@ package cn.iocoder.yudao.module.product.dal.mysql.sku; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import org.apache.ibatis.annotations.Mapper; import java.util.List; /** - * 商品sku Mapper + * 商品 SKU Mapper * * @author 芋道源码 */ @Mapper public interface ProductSkuMapper extends BaseMapperX { - default PageResult selectPage(ProductSkuPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ProductSkuDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(ProductSkuDO::getProperties, reqVO.getProperties()) - .eqIfPresent(ProductSkuDO::getPrice, reqVO.getPrice()) -// .eqIfPresent(ProductSkuDO::getOriginalPrice, reqVO.getOriginalPrice()) -// .eqIfPresent(ProductSkuDO::getCostPrice, reqVO.getCostPrice()) - .eqIfPresent(ProductSkuDO::getBarCode, reqVO.getBarCode()) - .eqIfPresent(ProductSkuDO::getPicUrl, reqVO.getPicUrl()) - .eqIfPresent(ProductSkuDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(ProductSkuDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductSkuDO::getId)); - } - - // TODO @franky:方法名 selectList; 可以直接调用 selectList default List selectListBySpuIds(List spuIds) { return selectList(ProductSkuDO::getSpuId, spuIds); diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java index fa4bc36bad..1755695cba 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.product.dal.mysql.spu; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import org.apache.ibatis.annotations.Mapper; @@ -15,7 +15,7 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface ProductSpuMapper extends BaseMapperX { - default PageResult selectPage(SpuPageReqVO reqVO) { + default PageResult selectPage(ProductSpuPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(ProductSpuDO::getName, reqVO.getName()) .eqIfPresent(ProductSpuDO::getSellPoint, reqVO.getSellPoint()) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java index 7629bd5a36..5316f4764d 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java @@ -1,9 +1,6 @@ package cn.iocoder.yudao.module.product.service.sku; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import javax.validation.Valid; @@ -17,21 +14,6 @@ import java.util.List; */ public interface ProductSkuService { - /** - * 创建商品 SKU - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSku(@Valid ProductSkuCreateOrUpdateReqVO createReqVO); - - /** - * 更新商品sku - * - * @param updateReqVO 更新信息 - */ - void updateSku(@Valid ProductSkuUpdateReqVO updateReqVO); - /** * 删除商品sku * @@ -55,14 +37,6 @@ public interface ProductSkuService { */ List getSkuList(Collection ids); - /** - * 获得商品sku分页 - * - * @param pageReqVO 分页查询 - * @return 商品sku分页 - */ - PageResult getSkuPage(ProductSkuPageReqVO pageReqVO); - /** * 对 sku 的组合的属性等进行合法性校验 * diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java index c08a8133b7..bf8dab778f 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java @@ -2,14 +2,11 @@ package cn.iocoder.yudao.module.product.service.sku; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyAndValueRespVO; import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; @@ -42,24 +39,6 @@ public class ProductSkuServiceImpl implements ProductSkuService { @Resource private ProductPropertyService productPropertyService; - @Override - public Long createSku(ProductSkuCreateOrUpdateReqVO createReqVO) { - // 插入 - ProductSkuDO sku = ProductSkuConvert.INSTANCE.convert(createReqVO); - productSkuMapper.insert(sku); - // 返回 - return sku.getId(); - } - - @Override - public void updateSku(ProductSkuUpdateReqVO updateReqVO) { - // 校验存在 - this.validateSkuExists(updateReqVO.getId()); - // 更新 - ProductSkuDO updateObj = ProductSkuConvert.INSTANCE.convert(updateReqVO); - productSkuMapper.updateById(updateObj); - } - @Override public void deleteSku(Long id) { // 校验存在 @@ -84,11 +63,6 @@ public class ProductSkuServiceImpl implements ProductSkuService { return productSkuMapper.selectBatchIds(ids); } - @Override - public PageResult getSkuPage(ProductSkuPageReqVO pageReqVO) { - return productSkuMapper.selectPage(pageReqVO); - } - @Override public void validateSkus(List skus, Integer specType) { // 非多规格,不需要校验 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java index 8907c62071..e5affa8d2d 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java @@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.product.service.spu; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; @@ -48,7 +48,7 @@ public interface ProductSpuService { * @param id 编号 * @return 商品spu */ - SpuRespVO getSpu(Long id); + ProductSpuRespVO getSpu(Long id); /** * 获得商品spu列表 @@ -64,7 +64,7 @@ public interface ProductSpuService { * @param pageReqVO 分页查询 * @return 商品spu分页 */ - PageResult getSpuPage(SpuPageReqVO pageReqVO); + PageResult getSpuPage(ProductSpuPageReqVO pageReqVO); /** * 获得商品spu分页 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java index a72a1fcef4..847301ba80 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java @@ -9,9 +9,9 @@ import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; @@ -125,9 +125,9 @@ public class ProductSpuServiceImpl implements ProductSpuService { @Override // TODO @芋艿:需要再 review 下 - public SpuRespVO getSpu(Long id) { + public ProductSpuRespVO getSpu(Long id) { ProductSpuDO spu = ProductSpuMapper.selectById(id); - SpuRespVO spuVO = ProductSpuConvert.INSTANCE.convert(spu); + ProductSpuRespVO spuVO = ProductSpuConvert.INSTANCE.convert(spu); if (null != spuVO) { List skuReqs = ProductSkuConvert.INSTANCE.convertList(productSkuService.getSkusBySpuId(id)); spuVO.setSkus(skuReqs); @@ -179,10 +179,10 @@ public class ProductSpuServiceImpl implements ProductSpuService { } @Override - public PageResult getSpuPage(SpuPageReqVO pageReqVO) { - PageResult spuVOs = ProductSpuConvert.INSTANCE.convertPage(ProductSpuMapper.selectPage(pageReqVO)); + public PageResult getSpuPage(ProductSpuPageReqVO pageReqVO) { + PageResult spuVOs = ProductSpuConvert.INSTANCE.convertPage(ProductSpuMapper.selectPage(pageReqVO)); // 查询 sku 的信息 - List spuIds = spuVOs.getList().stream().map(SpuRespVO::getId).collect(Collectors.toList()); + List spuIds = spuVOs.getList().stream().map(ProductSpuRespVO::getId).collect(Collectors.toList()); List skus = ProductSkuConvert.INSTANCE.convertList(productSkuService.getSkusBySpuIds(spuIds)); // TODO @franky:使用 CollUtil 里的方法替代哈 // TODO 芋艿:临时注释 diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java index be3362f194..10ab8a3d12 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java +++ b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java @@ -1,24 +1,17 @@ package cn.iocoder.yudao.module.product.service.sku; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Import; import javax.annotation.Resource; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertNull; /** * {@link ProductSkuServiceImpl} 的单元测试类 @@ -34,46 +27,6 @@ public class SkuServiceImplTest extends BaseDbUnitTest { @Resource private ProductSkuMapper ProductSkuMapper; - @Test - public void testCreateSku_success() { - // 准备参数 - ProductSkuCreateOrUpdateReqVO reqVO = randomPojo(ProductSkuCreateOrUpdateReqVO.class); - - // 调用 - Long skuId = ProductSkuService.createSku(reqVO); - // 断言 - assertNotNull(skuId); - // 校验记录的属性是否正确 - ProductSkuDO sku = ProductSkuMapper.selectById(skuId); - assertPojoEquals(reqVO, sku); - } - - @Test - public void testUpdateSku_success() { - // mock 数据 - ProductSkuDO dbSku = randomPojo(ProductSkuDO.class); - ProductSkuMapper.insert(dbSku);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ProductSkuUpdateReqVO reqVO = randomPojo(ProductSkuUpdateReqVO.class, o -> { - o.setId(dbSku.getId()); // 设置更新的 ID - }); - - // 调用 - ProductSkuService.updateSku(reqVO); - // 校验是否更新正确 - ProductSkuDO sku = ProductSkuMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, sku); - } - - @Test - public void testUpdateSku_notExists() { - // 准备参数 - ProductSkuUpdateReqVO reqVO = randomPojo(ProductSkuUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> ProductSkuService.updateSku(reqVO), SKU_NOT_EXISTS); - } - @Test public void testDeleteSku_success() { // mock 数据 @@ -97,58 +50,4 @@ public class SkuServiceImplTest extends BaseDbUnitTest { assertServiceException(() -> ProductSkuService.deleteSku(id), SKU_NOT_EXISTS); } - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetSkuPage() { - // mock 数据 - ProductSkuDO dbSku = randomPojo(ProductSkuDO.class, o -> { // 等会查询到 - o.setSpuId(null); - o.setProperties(null); - o.setPrice(null); -// o.setOriginalPrice(null); -// o.setCostPrice(null); - o.setBarCode(null); - o.setPicUrl(null); - o.setStatus(null); - o.setCreateTime(null); - }); - ProductSkuMapper.insert(dbSku); - // 测试 spuId 不匹配 - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null))); - // 测试 properties 不匹配 - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setProperties(null))); - // 测试 price 不匹配 - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null))); - // 测试 originalPrice 不匹配 -// ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setOriginalPrice(null))); - // 测试 costPrice 不匹配 -// ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCostPrice(null))); - // 测试 barCode 不匹配 - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null))); - // 测试 picUrl 不匹配 - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPicUrl(null))); - // 测试 status 不匹配 - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setStatus(null))); - // 测试 createTime 不匹配 - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null))); - // 准备参数 - ProductSkuPageReqVO reqVO = new ProductSkuPageReqVO(); - reqVO.setSpuId(null); - reqVO.setProperties(null); - reqVO.setPrice(null); - reqVO.setOriginalPrice(null); - reqVO.setCostPrice(null); - reqVO.setBarCode(null); - reqVO.setPicUrl(null); - reqVO.setStatus(null); - reqVO.setCreateTime(null); - - // 调用 - PageResult pageResult = ProductSkuService.getSkuPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSku, pageResult.getList().get(0)); - } - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java index 57b7fdfeb1..bb0fa9d328 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java +++ b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java @@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.product.service.spu; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; @@ -139,7 +139,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { // 测试 createTime 不匹配 ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null))); // 准备参数 - SpuPageReqVO reqVO = new SpuPageReqVO(); + ProductSpuPageReqVO reqVO = new ProductSpuPageReqVO(); reqVO.setName(null); reqVO.setSellPoint(null); reqVO.setDescription(null); @@ -153,7 +153,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { reqVO.setCreateTime(null); // 调用 - PageResult pageResult = spuService.getSpuPage(reqVO); + PageResult pageResult = spuService.getSpuPage(reqVO); // 断言 assertEquals(1, pageResult.getTotal()); assertEquals(1, pageResult.getList().size());