Commit f03d679f2cb48d3163621329f5e0d2521d42c1d3
1 parent
405bf497
mall:code review 商品的添加和修改 VO;微调商品的 SPU/SKU 表
Showing
19 changed files
with
184 additions
and
137 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java
| @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.product.controller.admin.sku; | @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.product.controller.admin.sku; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO; | 5 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; |
| 7 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; | 7 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; |
| 8 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; | 8 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; |
| @@ -35,7 +35,7 @@ public class ProductSkuController { | @@ -35,7 +35,7 @@ public class ProductSkuController { | ||
| 35 | @PostMapping("/create") | 35 | @PostMapping("/create") |
| 36 | @ApiOperation("创建商品sku") | 36 | @ApiOperation("创建商品sku") |
| 37 | @PreAuthorize("@ss.hasPermission('product:sku:create')") | 37 | @PreAuthorize("@ss.hasPermission('product:sku:create')") |
| 38 | - public CommonResult<Long> createSku(@Valid @RequestBody ProductSkuCreateReqVO createReqVO) { | 38 | + public CommonResult<Long> createSku(@Valid @RequestBody ProductSkuCreateOrUpdateReqVO createReqVO) { |
| 39 | return success(ProductSkuService.createSku(createReqVO)); | 39 | return success(ProductSkuService.createSku(createReqVO)); |
| 40 | } | 40 | } |
| 41 | 41 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
| 1 | package cn.iocoder.yudao.module.product.controller.admin.sku.vo; | 1 | package cn.iocoder.yudao.module.product.controller.admin.sku.vo; |
| 2 | 2 | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import io.swagger.annotations.*; | ||
| 6 | -import javax.validation.constraints.*; | 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 5 | +import io.swagger.annotations.ApiModel; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | +import javax.validation.constraints.NotEmpty; | ||
| 10 | +import javax.validation.constraints.NotNull; | ||
| 11 | +import java.util.List; | ||
| 7 | 12 | ||
| 8 | /** | 13 | /** |
| 9 | -* 商品sku Base VO,提供给添加、修改、详细的子 VO 使用 | 14 | +* 商品 SKU Base VO,提供给添加、修改、详细的子 VO 使用 |
| 10 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | 15 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
| 11 | */ | 16 | */ |
| 12 | @Data | 17 | @Data |
| 13 | public class ProductSkuBaseVO { | 18 | public class ProductSkuBaseVO { |
| 14 | 19 | ||
| 15 | - // TODO @franky:example 要写哈; | ||
| 16 | - | ||
| 17 | - @ApiModelProperty(value = "spu编号") | ||
| 18 | - private Long spuId; | ||
| 19 | - | ||
| 20 | - // TODO @franky:类似这种字段,有额外说明的。可以写成; @ApiModelProperty(value = "规格值数组", required = true, notes = "json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]") | 20 | + @ApiModelProperty(value = "商品 SKU 名字", required = true, example = "芋道") |
| 21 | + @NotEmpty(message = "商品 SKU 名字不能为空") | ||
| 22 | + private String name; | ||
| 21 | 23 | ||
| 22 | - @ApiModelProperty(value = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]", required = true) | ||
| 23 | - @NotNull(message = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]不能为空") | 24 | + /** |
| 25 | + * 规格值数组 | ||
| 26 | + */ | ||
| 27 | + @NotNull(message = "规格值数组不能为空") | ||
| 24 | private List<Property> properties; | 28 | private List<Property> properties; |
| 25 | 29 | ||
| 26 | - @ApiModelProperty(value = "销售价格,单位:分", required = true) | 30 | + @ApiModelProperty(value = "销售价格,单位:分", required = true, example = "1024", notes = "单位:分") |
| 27 | @NotNull(message = "销售价格,单位:分不能为空") | 31 | @NotNull(message = "销售价格,单位:分不能为空") |
| 28 | private Integer price; | 32 | private Integer price; |
| 29 | 33 | ||
| 30 | - @ApiModelProperty(value = "原价, 单位: 分", required = true) | ||
| 31 | - @NotNull(message = "原价, 单位: 分不能为空") | 34 | + @ApiModelProperty(value = "市场价", example = "1024", notes = "单位:分") |
| 32 | private Integer originalPrice; | 35 | private Integer originalPrice; |
| 33 | 36 | ||
| 34 | - @ApiModelProperty(value = "成本价,单位: 分", required = true) | ||
| 35 | - @NotNull(message = "成本价,单位: 分不能为空") | 37 | + @ApiModelProperty(value = "成本价", example = "1024", notes = "单位:分") |
| 36 | private Integer costPrice; | 38 | private Integer costPrice; |
| 37 | 39 | ||
| 38 | - @ApiModelProperty(value = "条形码", required = true) | 40 | + @ApiModelProperty(value = "条形码", example = "haha") |
| 39 | @NotNull(message = "条形码不能为空") | 41 | @NotNull(message = "条形码不能为空") |
| 40 | private String barCode; | 42 | private String barCode; |
| 41 | 43 | ||
| 42 | - @ApiModelProperty(value = "图片地址", required = true) | 44 | + @ApiModelProperty(value = "图片地址") |
| 43 | @NotNull(message = "图片地址不能为空") | 45 | @NotNull(message = "图片地址不能为空") |
| 44 | private String picUrl; | 46 | private String picUrl; |
| 45 | 47 | ||
| 46 | - @ApiModelProperty(value = "状态: 0-正常 1-禁用") | 48 | + @ApiModelProperty(value = "SKU 状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举") |
| 49 | + @NotNull(message = "SKU 状态不能为空") | ||
| 50 | + @InEnum(CommonStatusEnum.class) | ||
| 47 | private Integer status; | 51 | private Integer status; |
| 48 | 52 | ||
| 49 | - // TODO @franky 要有 swagger 注解 | 53 | + @ApiModelProperty(value = "库存", required = true, example = "1") |
| 54 | + @NotNull(message = "库存不能为空") | ||
| 55 | + private Integer stock; | ||
| 56 | + | ||
| 57 | + @ApiModelProperty(value = "预警预存", example = "1") | ||
| 58 | + private Integer warnStock; | ||
| 59 | + | ||
| 60 | + @ApiModelProperty(value = "商品重量", example = "1", notes = "单位:kg 千克") | ||
| 61 | + private Double weight; | ||
| 62 | + | ||
| 63 | + @ApiModelProperty(value = "商品体积", example = "1024", notes = "单位:m^3 平米") | ||
| 64 | + private Double volume; | ||
| 65 | + | ||
| 66 | + @ApiModel("规格值") | ||
| 50 | @Data | 67 | @Data |
| 51 | public static class Property { | 68 | public static class Property { |
| 52 | - @NotNull(message = "规格属性名id不能为空") | 69 | + |
| 70 | + @ApiModelProperty(value = "属性编号", required = true, example = "1") | ||
| 71 | + @NotNull(message = "属性编号不能为空") | ||
| 53 | private Long propertyId; | 72 | private Long propertyId; |
| 54 | - @NotNull(message = "规格属性值id不能为空") | 73 | + |
| 74 | + @ApiModelProperty(value = "属性值编号", required = true, example = "1024") | ||
| 75 | + @NotNull(message = "属性值编号不能为空") | ||
| 55 | private Long valueId; | 76 | private Long valueId; |
| 77 | + | ||
| 56 | } | 78 | } |
| 57 | 79 | ||
| 58 | } | 80 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.sku.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import lombok.Data; | ||
| 5 | +import lombok.EqualsAndHashCode; | ||
| 6 | +import lombok.ToString; | ||
| 7 | + | ||
| 8 | +@ApiModel("管理后台 - 商品 SKU 创建/更新 Request VO") | ||
| 9 | +@Data | ||
| 10 | +@EqualsAndHashCode(callSuper = true) | ||
| 11 | +@ToString(callSuper = true) | ||
| 12 | +public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO { | ||
| 13 | + | ||
| 14 | +} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import io.swagger.annotations.*; | ||
| 6 | -import javax.validation.constraints.*; | ||
| 7 | - | ||
| 8 | -@ApiModel("管理后台 - 商品sku创建 Request VO") | ||
| 9 | -@Data | ||
| 10 | -@EqualsAndHashCode(callSuper = true) | ||
| 11 | -@ToString(callSuper = true) | ||
| 12 | -public class ProductSkuCreateReqVO extends ProductSkuBaseVO { | ||
| 13 | - | ||
| 14 | -} |
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; | @@ -3,9 +3,9 @@ package cn.iocoder.yudao.module.product.controller.admin.spu; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; | 5 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; |
| 6 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; | ||
| 6 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; | 7 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; |
| 7 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; | 8 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; |
| 8 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuUpdateReqVO; | ||
| 9 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; | 9 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; |
| 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 11 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; | 11 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| @@ -23,7 +23,7 @@ import java.util.List; | @@ -23,7 +23,7 @@ import java.util.List; | ||
| 23 | 23 | ||
| 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 25 | 25 | ||
| 26 | -@Api(tags = "管理后台 - 商品spu") | 26 | +@Api(tags = "管理后台 - 商品 SPU") |
| 27 | @RestController | 27 | @RestController |
| 28 | @RequestMapping("/product/spu") | 28 | @RequestMapping("/product/spu") |
| 29 | @Validated | 29 | @Validated |
| @@ -33,17 +33,16 @@ public class ProductSpuController { | @@ -33,17 +33,16 @@ public class ProductSpuController { | ||
| 33 | private ProductSpuService spuService; | 33 | private ProductSpuService spuService; |
| 34 | 34 | ||
| 35 | @PostMapping("/create") | 35 | @PostMapping("/create") |
| 36 | - @ApiOperation("创建商品spu") | 36 | + @ApiOperation("创建商品 SPU") |
| 37 | @PreAuthorize("@ss.hasPermission('product:spu:create')") | 37 | @PreAuthorize("@ss.hasPermission('product:spu:create')") |
| 38 | public CommonResult<Long> createSpu(@Valid @RequestBody ProductSpuCreateReqVO createReqVO) { | 38 | public CommonResult<Long> createSpu(@Valid @RequestBody ProductSpuCreateReqVO createReqVO) { |
| 39 | return success(spuService.createSpu(createReqVO)); | 39 | return success(spuService.createSpu(createReqVO)); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | - // TODO @franky:SpuUpdateReqVO 缺少前缀 | ||
| 43 | @PutMapping("/update") | 42 | @PutMapping("/update") |
| 44 | - @ApiOperation("更新商品spu") | 43 | + @ApiOperation("更新商品 SPU") |
| 45 | @PreAuthorize("@ss.hasPermission('product:spu:update')") | 44 | @PreAuthorize("@ss.hasPermission('product:spu:update')") |
| 46 | - public CommonResult<Boolean> updateSpu(@Valid @RequestBody SpuUpdateReqVO updateReqVO) { | 45 | + public CommonResult<Boolean> updateSpu(@Valid @RequestBody ProductSpuUpdateReqVO updateReqVO) { |
| 47 | spuService.updateSpu(updateReqVO); | 46 | spuService.updateSpu(updateReqVO); |
| 48 | return success(true); | 47 | return success(true); |
| 49 | } | 48 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java
| 1 | package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | 1 | package cn.iocoder.yudao.module.product.controller.admin.spu.vo; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 4 | +import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum; | ||
| 5 | +import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; | ||
| 3 | import io.swagger.annotations.ApiModelProperty; | 6 | import io.swagger.annotations.ApiModelProperty; |
| 4 | import lombok.Data; | 7 | import lombok.Data; |
| 5 | 8 | ||
| 9 | +import javax.validation.constraints.NotEmpty; | ||
| 6 | import javax.validation.constraints.NotNull; | 10 | import javax.validation.constraints.NotNull; |
| 7 | import java.util.List; | 11 | import java.util.List; |
| 8 | 12 | ||
| 9 | /** | 13 | /** |
| 10 | -* 商品spu Base VO,提供给添加、修改、详细的子 VO 使用 | 14 | +* 商品 SPU Base VO,提供给添加、修改、详细的子 VO 使用 |
| 11 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | 15 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
| 12 | */ | 16 | */ |
| 13 | @Data | 17 | @Data |
| 14 | public class ProductSpuBaseVO { | 18 | public class ProductSpuBaseVO { |
| 15 | 19 | ||
| 16 | - @ApiModelProperty(value = "商品名称") | 20 | + @ApiModelProperty(value = "商品名称", required = true, example = "芋道") |
| 21 | + @NotEmpty(message = "商品名称不能为空") | ||
| 17 | private String name; | 22 | private String name; |
| 18 | 23 | ||
| 19 | - @ApiModelProperty(value = "卖点", required = true) | ||
| 20 | - @NotNull(message = "卖点不能为空") | 24 | + @ApiModelProperty(value = "商品编码", example = "yudaoyuanma") |
| 25 | + private String code; | ||
| 26 | + | ||
| 27 | + @ApiModelProperty(value = "商品卖点", example = "好吃!") | ||
| 21 | private String sellPoint; | 28 | private String sellPoint; |
| 22 | 29 | ||
| 23 | - @ApiModelProperty(value = "描述", required = true) | ||
| 24 | - @NotNull(message = "描述不能为空") | 30 | + @ApiModelProperty(value = "商品详情", required = true, example = "我是商品描述") |
| 31 | + @NotNull(message = "商品详情不能为空") | ||
| 25 | private String description; | 32 | private String description; |
| 26 | 33 | ||
| 27 | - @ApiModelProperty(value = "分类id", required = true) | ||
| 28 | - @NotNull(message = "分类id不能为空") | 34 | + @ApiModelProperty(value = "商品分类编号", required = true, example = "1") |
| 35 | + @NotNull(message = "商品分类编号不能为空") | ||
| 29 | private Long categoryId; | 36 | private Long categoryId; |
| 30 | 37 | ||
| 31 | - @ApiModelProperty(value = "商品主图地址,* 数组,以逗号分隔,最多上传15张", required = true) | ||
| 32 | - @NotNull(message = "商品主图地址,* 数组,以逗号分隔,最多上传15张不能为空") | 38 | + @ApiModelProperty(value = "商品品牌编号", required = true, example = "1") |
| 39 | + @NotNull(message = "商品品牌编号不能为空") | ||
| 40 | + private Long brandId; | ||
| 41 | + | ||
| 42 | + @ApiModelProperty(value = "商品图片的数组", required = true) | ||
| 43 | + @NotNull(message = "商品图片的数组不能为空") | ||
| 33 | private List<String> picUrls; | 44 | private List<String> picUrls; |
| 34 | 45 | ||
| 35 | - @ApiModelProperty(value = "排序字段", required = true) | ||
| 36 | - @NotNull(message = "排序字段不能为空") | 46 | + @ApiModelProperty(value = "商品视频", required = true) |
| 47 | + @NotEmpty(message = "商品视频不能为空") | ||
| 48 | + private String videoUrl; | ||
| 49 | + | ||
| 50 | + @ApiModelProperty(value = "排序字段", required = true, example = "1") | ||
| 37 | private Integer sort; | 51 | private Integer sort; |
| 38 | 52 | ||
| 39 | - @ApiModelProperty(value = "点赞初始人数") | ||
| 40 | - private Integer likeCount; | 53 | + @ApiModelProperty(value = "商品状态", required = true, example = "1", notes = "参见 ProductSpuStatusEnum 枚举类") |
| 54 | + @NotNull(message = "商品状态不能为空") | ||
| 55 | + @InEnum(ProductSpuStatusEnum.class) | ||
| 56 | + private Integer status; | ||
| 41 | 57 | ||
| 42 | - @ApiModelProperty(value = "价格 单位使用:分") | ||
| 43 | - private Integer price; | 58 | + // ========== SKU 相关字段 ========= |
| 44 | 59 | ||
| 45 | - @ApiModelProperty(value = "库存数量") | ||
| 46 | - private Integer quantity; | 60 | + @ApiModelProperty(value = "规格类型", required = true, example = "1", notes = "参见 ProductSpuSpecTypeEnum 枚举类") |
| 61 | + @NotNull(message = "规格类型不能为空") | ||
| 62 | + @InEnum(ProductSpuSpecTypeEnum.class) | ||
| 63 | + private Integer specType; | ||
| 47 | 64 | ||
| 48 | - @ApiModelProperty(value = "上下架状态: 0 上架(开启) 1 下架(禁用)") | ||
| 49 | - private Integer status; | 65 | + @ApiModelProperty(value = "是否展示库存", required = true, example = "true") |
| 66 | + @NotNull(message = "是否展示库存不能为空") | ||
| 67 | + private Boolean showStock; | ||
| 68 | + | ||
| 69 | + // ========== 统计相关字段 ========= | ||
| 70 | + | ||
| 71 | + @ApiModelProperty(value = "虚拟销量", required = true, example = "1024") | ||
| 72 | + @NotNull(message = "虚拟销量不能为空") | ||
| 73 | + private Integer virtualSalesCount; | ||
| 50 | 74 | ||
| 51 | } | 75 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java
| 1 | package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | 1 | package cn.iocoder.yudao.module.product.controller.admin.spu.vo; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO; | 3 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 4 | import io.swagger.annotations.ApiModel; | 4 | import io.swagger.annotations.ApiModel; |
| 5 | -import io.swagger.annotations.ApiModelProperty; | ||
| 6 | import lombok.Data; | 5 | import lombok.Data; |
| 7 | import lombok.EqualsAndHashCode; | 6 | import lombok.EqualsAndHashCode; |
| 8 | import lombok.ToString; | 7 | import lombok.ToString; |
| @@ -10,14 +9,16 @@ import lombok.ToString; | @@ -10,14 +9,16 @@ import lombok.ToString; | ||
| 10 | import javax.validation.Valid; | 9 | import javax.validation.Valid; |
| 11 | import java.util.List; | 10 | import java.util.List; |
| 12 | 11 | ||
| 13 | -@ApiModel("管理后台 - 商品spu创建 Request VO") | 12 | +@ApiModel("管理后台 - 商品 SPU 创建 Request VO") |
| 14 | @Data | 13 | @Data |
| 15 | @EqualsAndHashCode(callSuper = true) | 14 | @EqualsAndHashCode(callSuper = true) |
| 16 | @ToString(callSuper = true) | 15 | @ToString(callSuper = true) |
| 17 | public class ProductSpuCreateReqVO extends ProductSpuBaseVO { | 16 | public class ProductSpuCreateReqVO extends ProductSpuBaseVO { |
| 18 | 17 | ||
| 19 | - @ApiModelProperty(value = "sku组合") | 18 | + /** |
| 19 | + * SKU 数组 | ||
| 20 | + */ | ||
| 20 | @Valid | 21 | @Valid |
| 21 | - List<ProductSkuCreateReqVO> skus; | 22 | + private List<ProductSkuCreateOrUpdateReqVO> skus; |
| 22 | 23 | ||
| 23 | } | 24 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java
0 → 100755
| 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.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import lombok.Data; | ||
| 7 | +import lombok.EqualsAndHashCode; | ||
| 8 | +import lombok.ToString; | ||
| 9 | + | ||
| 10 | +import javax.validation.Valid; | ||
| 11 | +import javax.validation.constraints.NotNull; | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +@ApiModel("管理后台 - 商品 SPU 更新 Request VO") | ||
| 15 | +@Data | ||
| 16 | +@EqualsAndHashCode(callSuper = true) | ||
| 17 | +@ToString(callSuper = true) | ||
| 18 | +public class ProductSpuUpdateReqVO extends ProductSpuBaseVO { | ||
| 19 | + | ||
| 20 | + @ApiModelProperty(value = "商品编号", required = true, example = "1") | ||
| 21 | + @NotNull(message = "商品编号不能为空") | ||
| 22 | + private Long id; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * SKU 数组 | ||
| 26 | + */ | ||
| 27 | + @Valid | ||
| 28 | + private List<ProductSkuCreateOrUpdateReqVO> skus; | ||
| 29 | + | ||
| 30 | +} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuUpdateReqVO.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.ProductSkuCreateReqVO; | ||
| 4 | -import lombok.*; | ||
| 5 | -import java.util.*; | ||
| 6 | -import io.swagger.annotations.*; | ||
| 7 | - | ||
| 8 | -import javax.validation.Valid; | ||
| 9 | -import javax.validation.constraints.*; | ||
| 10 | - | ||
| 11 | -@ApiModel("管理后台 - 商品spu更新 Request VO") | ||
| 12 | -@Data | ||
| 13 | -@EqualsAndHashCode(callSuper = true) | ||
| 14 | -@ToString(callSuper = true) | ||
| 15 | -public class SpuUpdateReqVO extends ProductSpuBaseVO { | ||
| 16 | - | ||
| 17 | - @ApiModelProperty(value = "主键", required = true) | ||
| 18 | - @NotNull(message = "主键不能为空") | ||
| 19 | - private Long id; | ||
| 20 | - | ||
| 21 | - @ApiModelProperty(value = "sku组合") | ||
| 22 | - @Valid | ||
| 23 | - List<ProductSkuCreateReqVO> skus; | ||
| 24 | - | ||
| 25 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java
| 1 | package cn.iocoder.yudao.module.product.convert.sku; | 1 | package cn.iocoder.yudao.module.product.convert.sku; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO; | 4 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 5 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuExcelVO; | 5 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuExcelVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; |
| 7 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; | 7 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; |
| @@ -22,7 +22,7 @@ public interface ProductSkuConvert { | @@ -22,7 +22,7 @@ public interface ProductSkuConvert { | ||
| 22 | 22 | ||
| 23 | ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class); | 23 | ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class); |
| 24 | 24 | ||
| 25 | - ProductSkuDO convert(ProductSkuCreateReqVO bean); | 25 | + ProductSkuDO convert(ProductSkuCreateOrUpdateReqVO bean); |
| 26 | 26 | ||
| 27 | ProductSkuDO convert(ProductSkuUpdateReqVO bean); | 27 | ProductSkuDO convert(ProductSkuUpdateReqVO bean); |
| 28 | 28 | ||
| @@ -31,7 +31,7 @@ public interface ProductSkuConvert { | @@ -31,7 +31,7 @@ public interface ProductSkuConvert { | ||
| 31 | 31 | ||
| 32 | List<ProductSkuRespVO> convertList(List<ProductSkuDO> list); | 32 | List<ProductSkuRespVO> convertList(List<ProductSkuDO> list); |
| 33 | 33 | ||
| 34 | - List<ProductSkuDO> convertSkuDOList(List<ProductSkuCreateReqVO> list); | 34 | + List<ProductSkuDO> convertSkuDOList(List<ProductSkuCreateOrUpdateReqVO> list); |
| 35 | 35 | ||
| 36 | PageResult<ProductSkuRespVO> convertPage(PageResult<ProductSkuDO> page); | 36 | PageResult<ProductSkuRespVO> convertPage(PageResult<ProductSkuDO> page); |
| 37 | 37 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java
| @@ -22,7 +22,7 @@ public interface ProductSpuConvert { | @@ -22,7 +22,7 @@ public interface ProductSpuConvert { | ||
| 22 | 22 | ||
| 23 | ProductSpuDO convert(ProductSpuCreateReqVO bean); | 23 | ProductSpuDO convert(ProductSpuCreateReqVO bean); |
| 24 | 24 | ||
| 25 | - ProductSpuDO convert(SpuUpdateReqVO bean); | 25 | + ProductSpuDO convert(ProductSpuUpdateReqVO bean); |
| 26 | 26 | ||
| 27 | SpuRespVO convert(ProductSpuDO bean); | 27 | SpuRespVO convert(ProductSpuDO bean); |
| 28 | 28 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java
| @@ -80,6 +80,10 @@ public class ProductSkuDO extends BaseDO { | @@ -80,6 +80,10 @@ public class ProductSkuDO extends BaseDO { | ||
| 80 | */ | 80 | */ |
| 81 | private Integer stock; | 81 | private Integer stock; |
| 82 | /** | 82 | /** |
| 83 | + * 预警预存 | ||
| 84 | + */ | ||
| 85 | + private Integer warnStock; | ||
| 86 | + /** | ||
| 83 | * 商品重量,单位:kg 千克 | 87 | * 商品重量,单位:kg 千克 |
| 84 | */ | 88 | */ |
| 85 | private Double weight; | 89 | private Double weight; |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java
| @@ -67,11 +67,11 @@ public class ProductSpuDO extends BaseDO { | @@ -67,11 +67,11 @@ public class ProductSpuDO extends BaseDO { | ||
| 67 | */ | 67 | */ |
| 68 | private Long brandId; | 68 | private Long brandId; |
| 69 | /** | 69 | /** |
| 70 | - * 商品主图 | ||
| 71 | - */ | ||
| 72 | - private String bannerUrl; | ||
| 73 | - /** | ||
| 74 | - * 商品轮播图数组 | 70 | + * 商品图片的数组 |
| 71 | + * | ||
| 72 | + * 1. 第一张图片将作为商品主图,支持同时上传多张图; | ||
| 73 | + * 2. 建议使用尺寸 800x800 像素以上、大小不超过 1M 的正方形图片; | ||
| 74 | + * 3. 至少 1 张,最多上传 10 张 | ||
| 75 | */ | 75 | */ |
| 76 | @TableField(typeHandler = JacksonTypeHandler.class) | 76 | @TableField(typeHandler = JacksonTypeHandler.class) |
| 77 | private List<String> picUrls; | 77 | private List<String> picUrls; |
| @@ -124,10 +124,6 @@ public class ProductSpuDO extends BaseDO { | @@ -124,10 +124,6 @@ public class ProductSpuDO extends BaseDO { | ||
| 124 | */ | 124 | */ |
| 125 | private Integer totalStock; | 125 | private Integer totalStock; |
| 126 | /** | 126 | /** |
| 127 | - * 预警预存 | ||
| 128 | - */ | ||
| 129 | - private Integer warnStock; | ||
| 130 | - /** | ||
| 131 | * 是否展示库存 | 127 | * 是否展示库存 |
| 132 | */ | 128 | */ |
| 133 | private Boolean showStock; | 129 | private Boolean showStock; |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java
| 1 | package cn.iocoder.yudao.module.product.service.sku; | 1 | package cn.iocoder.yudao.module.product.service.sku; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuExportReqVO; | 4 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; | 5 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; |
| 7 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; |
| 8 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | 7 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| @@ -24,7 +23,7 @@ public interface ProductSkuService { | @@ -24,7 +23,7 @@ public interface ProductSkuService { | ||
| 24 | * @param createReqVO 创建信息 | 23 | * @param createReqVO 创建信息 |
| 25 | * @return 编号 | 24 | * @return 编号 |
| 26 | */ | 25 | */ |
| 27 | - Long createSku(@Valid ProductSkuCreateReqVO createReqVO); | 26 | + Long createSku(@Valid ProductSkuCreateOrUpdateReqVO createReqVO); |
| 28 | 27 | ||
| 29 | /** | 28 | /** |
| 30 | * 更新商品sku | 29 | * 更新商品sku |
| @@ -69,7 +68,7 @@ public interface ProductSkuService { | @@ -69,7 +68,7 @@ public interface ProductSkuService { | ||
| 69 | * | 68 | * |
| 70 | * @param list sku组合的集合 | 69 | * @param list sku组合的集合 |
| 71 | */ | 70 | */ |
| 72 | - void validateSkus(List<ProductSkuCreateReqVO> list); | 71 | + void validateSkus(List<ProductSkuCreateOrUpdateReqVO> list); |
| 73 | 72 | ||
| 74 | /** | 73 | /** |
| 75 | * 批量保存 sku | 74 | * 批量保存 sku |
| @@ -107,5 +106,5 @@ public interface ProductSkuService { | @@ -107,5 +106,5 @@ public interface ProductSkuService { | ||
| 107 | * @param spuId spu 编码 | 106 | * @param spuId spu 编码 |
| 108 | * @param skus sku 的集合 | 107 | * @param skus sku 的集合 |
| 109 | */ | 108 | */ |
| 110 | - void updateSkus(Long spuId, List<ProductSkuCreateReqVO> skus); | 109 | + void updateSkus(Long spuId, List<ProductSkuCreateOrUpdateReqVO> skus); |
| 111 | } | 110 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
| @@ -38,7 +38,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { | @@ -38,7 +38,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { | ||
| 38 | private ProductPropertyService productPropertyService; | 38 | private ProductPropertyService productPropertyService; |
| 39 | 39 | ||
| 40 | @Override | 40 | @Override |
| 41 | - public Long createSku(ProductSkuCreateReqVO createReqVO) { | 41 | + public Long createSku(ProductSkuCreateOrUpdateReqVO createReqVO) { |
| 42 | // 插入 | 42 | // 插入 |
| 43 | ProductSkuDO sku = ProductSkuConvert.INSTANCE.convert(createReqVO); | 43 | ProductSkuDO sku = ProductSkuConvert.INSTANCE.convert(createReqVO); |
| 44 | productSkuMapper.insert(sku); | 44 | productSkuMapper.insert(sku); |
| @@ -87,7 +87,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { | @@ -87,7 +87,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { | ||
| 87 | // TODO @franky:这个方法,貌似实现的还是有点问题哈。例如说,throw 异常,后面还执行逻辑~ | 87 | // TODO @franky:这个方法,貌似实现的还是有点问题哈。例如说,throw 异常,后面还执行逻辑~ |
| 88 | // TODO @艿艿 咳咳,throw 那里我是偷懒省略了{},哈哈,我加上,然后我调试下,在优化下 | 88 | // TODO @艿艿 咳咳,throw 那里我是偷懒省略了{},哈哈,我加上,然后我调试下,在优化下 |
| 89 | @Override | 89 | @Override |
| 90 | - public void validateSkus(List<ProductSkuCreateReqVO> list) { | 90 | + public void validateSkus(List<ProductSkuCreateOrUpdateReqVO> list) { |
| 91 | List<ProductSkuBaseVO.Property> skuPropertyList = list.stream().flatMap(p -> p.getProperties().stream()).collect(Collectors.toList()); | 91 | List<ProductSkuBaseVO.Property> skuPropertyList = list.stream().flatMap(p -> p.getProperties().stream()).collect(Collectors.toList()); |
| 92 | // 校验规格属性以及规格值是否存在 | 92 | // 校验规格属性以及规格值是否存在 |
| 93 | List<Long> propertyIds = skuPropertyList.stream().map(ProductSkuBaseVO.Property::getPropertyId).collect(Collectors.toList()); | 93 | List<Long> propertyIds = skuPropertyList.stream().map(ProductSkuBaseVO.Property::getPropertyId).collect(Collectors.toList()); |
| @@ -139,7 +139,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { | @@ -139,7 +139,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { | ||
| 139 | 139 | ||
| 140 | @Override | 140 | @Override |
| 141 | @Transactional | 141 | @Transactional |
| 142 | - public void updateSkus(Long spuId, List<ProductSkuCreateReqVO> skus) { | 142 | + public void updateSkus(Long spuId, List<ProductSkuCreateOrUpdateReqVO> skus) { |
| 143 | List<ProductSkuDO> allUpdateSkus = ProductSkuConvert.INSTANCE.convertSkuDOList(skus); | 143 | List<ProductSkuDO> allUpdateSkus = ProductSkuConvert.INSTANCE.convertSkuDOList(skus); |
| 144 | // 查询 spu 下已经存在的 sku 的集合 | 144 | // 查询 spu 下已经存在的 sku 的集合 |
| 145 | List<ProductSkuDO> existsSkus = productSkuMapper.selectBySpuIds(Collections.singletonList(spuId)); | 145 | List<ProductSkuDO> existsSkus = productSkuMapper.selectBySpuIds(Collections.singletonList(spuId)); |
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; | @@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.product.service.spu; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; | 4 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; |
| 5 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; | ||
| 5 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; | 7 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; |
| 7 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuUpdateReqVO; | ||
| 8 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; | 8 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; |
| 9 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; | 9 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; |
| 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| @@ -14,7 +14,7 @@ import java.util.Collection; | @@ -14,7 +14,7 @@ import java.util.Collection; | ||
| 14 | import java.util.List; | 14 | import java.util.List; |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | - * 商品spu Service 接口 | 17 | + * 商品 SPU Service 接口 |
| 18 | * | 18 | * |
| 19 | * @author 芋道源码 | 19 | * @author 芋道源码 |
| 20 | */ | 20 | */ |
| @@ -33,7 +33,7 @@ public interface ProductSpuService { | @@ -33,7 +33,7 @@ public interface ProductSpuService { | ||
| 33 | * | 33 | * |
| 34 | * @param updateReqVO 更新信息 | 34 | * @param updateReqVO 更新信息 |
| 35 | */ | 35 | */ |
| 36 | - void updateSpu(@Valid SpuUpdateReqVO updateReqVO); | 36 | + void updateSpu(@Valid ProductSpuUpdateReqVO updateReqVO); |
| 37 | 37 | ||
| 38 | /** | 38 | /** |
| 39 | * 删除商品spu | 39 | * 删除商品spu |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| @@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPrope | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPrope | ||
| 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyViewRespVO; | 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyViewRespVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueRespVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueRespVO; |
| 7 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; | 7 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; |
| 8 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO; | 8 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 9 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; | 9 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; |
| 10 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | 10 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 11 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; | 11 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; |
| @@ -30,7 +30,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU | @@ -30,7 +30,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU | ||
| 30 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; | 30 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | - * 商品spu Service 实现类 | 33 | + * 商品 SPU Service 实现类 |
| 34 | * | 34 | * |
| 35 | * @author 芋道源码 | 35 | * @author 芋道源码 |
| 36 | */ | 36 | */ |
| @@ -56,15 +56,11 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -56,15 +56,11 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 56 | // 校验分类 | 56 | // 校验分类 |
| 57 | categoryService.validateProductCategory(createReqVO.getCategoryId()); | 57 | categoryService.validateProductCategory(createReqVO.getCategoryId()); |
| 58 | // 校验SKU | 58 | // 校验SKU |
| 59 | - List<ProductSkuCreateReqVO> skuCreateReqList = createReqVO.getSkus(); | 59 | + List<ProductSkuCreateOrUpdateReqVO> skuCreateReqList = createReqVO.getSkus(); |
| 60 | productSkuService.validateSkus(skuCreateReqList); | 60 | productSkuService.validateSkus(skuCreateReqList); |
| 61 | // 插入SPU | 61 | // 插入SPU |
| 62 | ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); | 62 | ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); |
| 63 | ProductSpuMapper.insert(spu); | 63 | ProductSpuMapper.insert(spu); |
| 64 | - // sku关联SPU属性 | ||
| 65 | - skuCreateReqList.forEach(p -> { | ||
| 66 | - p.setSpuId(spu.getId()); | ||
| 67 | - }); | ||
| 68 | List<ProductSkuDO> skuDOList = ProductSkuConvert.INSTANCE.convertSkuDOList(skuCreateReqList); | 64 | List<ProductSkuDO> skuDOList = ProductSkuConvert.INSTANCE.convertSkuDOList(skuCreateReqList); |
| 69 | // 批量插入sku | 65 | // 批量插入sku |
| 70 | productSkuService.createSkus(skuDOList); | 66 | productSkuService.createSkus(skuDOList); |
| @@ -74,13 +70,13 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -74,13 +70,13 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 74 | 70 | ||
| 75 | @Override | 71 | @Override |
| 76 | @Transactional | 72 | @Transactional |
| 77 | - public void updateSpu(SpuUpdateReqVO updateReqVO) { | 73 | + public void updateSpu(ProductSpuUpdateReqVO updateReqVO) { |
| 78 | // 校验 spu 是否存在 | 74 | // 校验 spu 是否存在 |
| 79 | this.validateSpuExists(updateReqVO.getId()); | 75 | this.validateSpuExists(updateReqVO.getId()); |
| 80 | // 校验分类 | 76 | // 校验分类 |
| 81 | categoryService.validateProductCategory(updateReqVO.getCategoryId()); | 77 | categoryService.validateProductCategory(updateReqVO.getCategoryId()); |
| 82 | // 校验SKU | 78 | // 校验SKU |
| 83 | - List<ProductSkuCreateReqVO> skuCreateReqList = updateReqVO.getSkus(); | 79 | + List<ProductSkuCreateOrUpdateReqVO> skuCreateReqList = updateReqVO.getSkus(); |
| 84 | productSkuService.validateSkus(skuCreateReqList); | 80 | productSkuService.validateSkus(skuCreateReqList); |
| 85 | // 更新 | 81 | // 更新 |
| 86 | ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); | 82 | ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); |
| @@ -165,9 +161,10 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -165,9 +161,10 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 165 | List<Long> spuIds = spuVOs.getList().stream().map(SpuRespVO::getId).collect(Collectors.toList()); | 161 | List<Long> spuIds = spuVOs.getList().stream().map(SpuRespVO::getId).collect(Collectors.toList()); |
| 166 | List<ProductSkuRespVO> skus = ProductSkuConvert.INSTANCE.convertList(productSkuService.getSkusBySpuIds(spuIds)); | 162 | List<ProductSkuRespVO> skus = ProductSkuConvert.INSTANCE.convertList(productSkuService.getSkusBySpuIds(spuIds)); |
| 167 | // TODO @franky:使用 CollUtil 里的方法替代哈 | 163 | // TODO @franky:使用 CollUtil 里的方法替代哈 |
| 168 | - Map<Long, List<ProductSkuRespVO>> skuMap = skus.stream().collect(Collectors.groupingBy(ProductSkuRespVO::getSpuId)); | ||
| 169 | - // 将 spu 和 sku 进行组装 | ||
| 170 | - spuVOs.getList().forEach(p -> p.setSkus(skuMap.get(p.getId()))); | 164 | + // TODO 芋艿:临时注释 |
| 165 | +// Map<Long, List<ProductSkuRespVO>> skuMap = skus.stream().collect(Collectors.groupingBy(ProductSkuRespVO::getSpuId)); | ||
| 166 | +// // 将 spu 和 sku 进行组装 | ||
| 167 | +// spuVOs.getList().forEach(p -> p.setSkus(skuMap.get(p.getId()))); | ||
| 171 | return spuVOs; | 168 | return spuVOs; |
| 172 | } | 169 | } |
| 173 | 170 |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java
| @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.product.service.sku; | @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.product.service.sku; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO; | 5 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; |
| 7 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; | 7 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; |
| 8 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | 8 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| @@ -37,7 +37,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { | @@ -37,7 +37,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { | ||
| 37 | @Test | 37 | @Test |
| 38 | public void testCreateSku_success() { | 38 | public void testCreateSku_success() { |
| 39 | // 准备参数 | 39 | // 准备参数 |
| 40 | - ProductSkuCreateReqVO reqVO = randomPojo(ProductSkuCreateReqVO.class); | 40 | + ProductSkuCreateOrUpdateReqVO reqVO = randomPojo(ProductSkuCreateOrUpdateReqVO.class); |
| 41 | 41 | ||
| 42 | // 调用 | 42 | // 调用 |
| 43 | Long skuId = ProductSkuService.createSku(reqVO); | 43 | Long skuId = ProductSkuService.createSku(reqVO); |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java
| @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 5 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; | 5 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; |
| 7 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; | 7 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; |
| 8 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuUpdateReqVO; | 8 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; |
| 9 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | 9 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 10 | import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; | 10 | import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; |
| 11 | import org.junit.jupiter.api.Disabled; | 11 | import org.junit.jupiter.api.Disabled; |
| @@ -55,7 +55,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | @@ -55,7 +55,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | ||
| 55 | ProductSpuDO dbSpu = randomPojo(ProductSpuDO.class); | 55 | ProductSpuDO dbSpu = randomPojo(ProductSpuDO.class); |
| 56 | ProductSpuMapper.insert(dbSpu);// @Sql: 先插入出一条存在的数据 | 56 | ProductSpuMapper.insert(dbSpu);// @Sql: 先插入出一条存在的数据 |
| 57 | // 准备参数 | 57 | // 准备参数 |
| 58 | - SpuUpdateReqVO reqVO = randomPojo(SpuUpdateReqVO.class, o -> { | 58 | + ProductSpuUpdateReqVO reqVO = randomPojo(ProductSpuUpdateReqVO.class, o -> { |
| 59 | o.setId(dbSpu.getId()); // 设置更新的 ID | 59 | o.setId(dbSpu.getId()); // 设置更新的 ID |
| 60 | }); | 60 | }); |
| 61 | 61 | ||
| @@ -69,7 +69,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | @@ -69,7 +69,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | ||
| 69 | @Test | 69 | @Test |
| 70 | public void testUpdateSpu_notExists() { | 70 | public void testUpdateSpu_notExists() { |
| 71 | // 准备参数 | 71 | // 准备参数 |
| 72 | - SpuUpdateReqVO reqVO = randomPojo(SpuUpdateReqVO.class); | 72 | + ProductSpuUpdateReqVO reqVO = randomPojo(ProductSpuUpdateReqVO.class); |
| 73 | 73 | ||
| 74 | // 调用, 并断言异常 | 74 | // 调用, 并断言异常 |
| 75 | assertServiceException(() -> spuService.updateSpu(reqVO), SPU_NOT_EXISTS); | 75 | assertServiceException(() -> spuService.updateSpu(reqVO), SPU_NOT_EXISTS); |