Commit c06077e3a6be384fabc0877f9905a1af6a96d33e
1 parent
2cc60deb
mall:code review 商品的代码
Showing
27 changed files
with
126 additions
and
485 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java
| 1 | 1 | package cn.iocoder.yudao.module.product.controller.admin.sku; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | |
| 6 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; | |
| 8 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; | |
| 9 | -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; | |
| 10 | -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | |
| 11 | -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; | |
| 12 | 3 | import io.swagger.annotations.Api; |
| 13 | -import io.swagger.annotations.ApiImplicitParam; | |
| 14 | -import io.swagger.annotations.ApiOperation; | |
| 15 | -import org.springframework.security.access.prepost.PreAuthorize; | |
| 16 | 4 | import org.springframework.validation.annotation.Validated; |
| 17 | -import org.springframework.web.bind.annotation.*; | |
| 18 | - | |
| 19 | -import javax.annotation.Resource; | |
| 20 | -import javax.validation.Valid; | |
| 21 | -import java.util.Collection; | |
| 22 | -import java.util.List; | |
| 23 | - | |
| 24 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 5 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 6 | +import org.springframework.web.bind.annotation.RestController; | |
| 25 | 7 | |
| 26 | 8 | @Api(tags = "管理后台 - 商品 sku") |
| 27 | 9 | @RestController |
| ... | ... | @@ -29,57 +11,4 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 29 | 11 | @Validated |
| 30 | 12 | public class ProductSkuController { |
| 31 | 13 | |
| 32 | - @Resource | |
| 33 | - private ProductSkuService ProductSkuService; | |
| 34 | - | |
| 35 | - @PostMapping("/create") | |
| 36 | - @ApiOperation("创建商品sku") | |
| 37 | - @PreAuthorize("@ss.hasPermission('product:sku:create')") | |
| 38 | - public CommonResult<Long> createSku(@Valid @RequestBody ProductSkuCreateOrUpdateReqVO createReqVO) { | |
| 39 | - return success(ProductSkuService.createSku(createReqVO)); | |
| 40 | - } | |
| 41 | - | |
| 42 | - @PutMapping("/update") | |
| 43 | - @ApiOperation("更新商品sku") | |
| 44 | - @PreAuthorize("@ss.hasPermission('product:sku:update')") | |
| 45 | - public CommonResult<Boolean> updateSku(@Valid @RequestBody ProductSkuUpdateReqVO updateReqVO) { | |
| 46 | - ProductSkuService.updateSku(updateReqVO); | |
| 47 | - return success(true); | |
| 48 | - } | |
| 49 | - | |
| 50 | - @DeleteMapping("/delete") | |
| 51 | - @ApiOperation("删除商品sku") | |
| 52 | - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | |
| 53 | - @PreAuthorize("@ss.hasPermission('product:sku:delete')") | |
| 54 | - public CommonResult<Boolean> deleteSku(@RequestParam("id") Long id) { | |
| 55 | - ProductSkuService.deleteSku(id); | |
| 56 | - return success(true); | |
| 57 | - } | |
| 58 | - | |
| 59 | - @GetMapping("/get") | |
| 60 | - @ApiOperation("获得商品sku") | |
| 61 | - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | |
| 62 | - @PreAuthorize("@ss.hasPermission('product:sku:query')") | |
| 63 | - public CommonResult<ProductSkuRespVO> getSku(@RequestParam("id") Long id) { | |
| 64 | - ProductSkuDO sku = ProductSkuService.getSku(id); | |
| 65 | - return success(ProductSkuConvert.INSTANCE.convert(sku)); | |
| 66 | - } | |
| 67 | - | |
| 68 | - @GetMapping("/list") | |
| 69 | - @ApiOperation("获得商品sku列表") | |
| 70 | - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | |
| 71 | - @PreAuthorize("@ss.hasPermission('product:sku:query')") | |
| 72 | - public CommonResult<List<ProductSkuRespVO>> getSkuList(@RequestParam("ids") Collection<Long> ids) { | |
| 73 | - List<ProductSkuDO> list = ProductSkuService.getSkuList(ids); | |
| 74 | - return success(ProductSkuConvert.INSTANCE.convertList(list)); | |
| 75 | - } | |
| 76 | - | |
| 77 | - @GetMapping("/page") | |
| 78 | - @ApiOperation("获得商品sku分页") | |
| 79 | - @PreAuthorize("@ss.hasPermission('product:sku:query')") | |
| 80 | - public CommonResult<PageResult<ProductSkuRespVO>> getSkuPage(@Valid ProductSkuPageReqVO pageVO) { | |
| 81 | - PageResult<ProductSkuDO> pageResult = ProductSkuService.getSkuPage(pageVO); | |
| 82 | - return success(ProductSkuConvert.INSTANCE.convertPage(pageResult)); | |
| 83 | - } | |
| 84 | - | |
| 85 | 14 | } | ... | ... |
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; |
| 8 | 8 | |
| 9 | 9 | import javax.validation.constraints.NotEmpty; |
| 10 | 10 | import javax.validation.constraints.NotNull; |
| 11 | -import java.util.List; | |
| 12 | 11 | |
| 13 | 12 | /** |
| 14 | 13 | * 商品 SKU Base VO,提供给添加、修改、详细的子 VO 使用 |
| ... | ... | @@ -21,11 +20,6 @@ public class ProductSkuBaseVO { |
| 21 | 20 | @NotEmpty(message = "商品 SKU 名字不能为空") |
| 22 | 21 | private String name; |
| 23 | 22 | |
| 24 | - /** | |
| 25 | - * 规格值数组 | |
| 26 | - */ | |
| 27 | - private List<Property> properties; | |
| 28 | - | |
| 29 | 23 | @ApiModelProperty(value = "销售价格,单位:分", required = true, example = "1024", notes = "单位:分") |
| 30 | 24 | @NotNull(message = "销售价格,单位:分不能为空") |
| 31 | 25 | private Integer price; | ... | ... |
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; |
| 6 | 6 | import lombok.EqualsAndHashCode; |
| 7 | 7 | import lombok.ToString; |
| 8 | 8 | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 9 | 11 | @ApiModel("管理后台 - 商品 SKU 创建/更新 Request VO") |
| 10 | 12 | @Data |
| 11 | 13 | @EqualsAndHashCode(callSuper = true) |
| ... | ... | @@ -16,4 +18,9 @@ public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO { |
| 16 | 18 | @ApiModelProperty(value = "商品 id 更新时须有", example = "1") |
| 17 | 19 | private Long id; |
| 18 | 20 | |
| 21 | + /** | |
| 22 | + * 规格值数组 | |
| 23 | + */ | |
| 24 | + private List<Property> properties; | |
| 25 | + | |
| 19 | 26 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; | |
| 2 | - | |
| 3 | -import com.alibaba.excel.annotation.ExcelProperty; | |
| 4 | -import lombok.Data; | |
| 5 | - | |
| 6 | -import java.util.Date; | |
| 7 | -import java.util.List; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * 商品sku Excel VO | |
| 11 | - * | |
| 12 | - * @author 芋道源码 | |
| 13 | - */ | |
| 14 | -@Data | |
| 15 | -public class ProductSkuExcelVO { | |
| 16 | - | |
| 17 | - @ExcelProperty("主键") | |
| 18 | - private Long id; | |
| 19 | - | |
| 20 | - @ExcelProperty("spu编号") | |
| 21 | - private Long spuId; | |
| 22 | - | |
| 23 | - // TODO @franky:这个单元格,可能会有点展示的问题 | |
| 24 | - @ExcelProperty("规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]") | |
| 25 | - private List<Property> properties; | |
| 26 | - | |
| 27 | - @ExcelProperty("销售价格,单位:分") | |
| 28 | - private Integer price; | |
| 29 | - | |
| 30 | - @ExcelProperty("原价, 单位: 分") | |
| 31 | - private Integer originalPrice; | |
| 32 | - | |
| 33 | - @ExcelProperty("成本价,单位: 分") | |
| 34 | - private Integer costPrice; | |
| 35 | - | |
| 36 | - @ExcelProperty("条形码") | |
| 37 | - private String barCode; | |
| 38 | - | |
| 39 | - @ExcelProperty("图片地址") | |
| 40 | - private String picUrl; | |
| 41 | - | |
| 42 | - @ExcelProperty("状态: 0-正常 1-禁用") | |
| 43 | - private Integer status; | |
| 44 | - | |
| 45 | - @ExcelProperty("创建时间") | |
| 46 | - private Date createTime; | |
| 47 | - | |
| 48 | - @Data | |
| 49 | - public static class Property { | |
| 50 | - private Integer propertyId; | |
| 51 | - private Integer valueId; | |
| 52 | - } | |
| 53 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExportReqVO.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 cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | - | |
| 9 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | - | |
| 11 | -@ApiModel(value = "管理后台 - 商品sku Excel 导出 Request VO", description = "参数和 SkuPageReqVO 是一致的") | |
| 12 | -@Data | |
| 13 | -public class ProductSkuExportReqVO { | |
| 14 | - | |
| 15 | - @ApiModelProperty(value = "spu编号") | |
| 16 | - private Long spuId; | |
| 17 | - | |
| 18 | - @ApiModelProperty(value = "规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]") | |
| 19 | - private String properties; | |
| 20 | - | |
| 21 | - @ApiModelProperty(value = "销售价格,单位:分") | |
| 22 | - private Integer price; | |
| 23 | - | |
| 24 | - @ApiModelProperty(value = "原价, 单位: 分") | |
| 25 | - private Integer originalPrice; | |
| 26 | - | |
| 27 | - @ApiModelProperty(value = "成本价,单位: 分") | |
| 28 | - private Integer costPrice; | |
| 29 | - | |
| 30 | - @ApiModelProperty(value = "条形码") | |
| 31 | - private String barCode; | |
| 32 | - | |
| 33 | - @ApiModelProperty(value = "图片地址") | |
| 34 | - private String picUrl; | |
| 35 | - | |
| 36 | - @ApiModelProperty(value = "状态: 0-正常 1-禁用") | |
| 37 | - private Integer status; | |
| 38 | - | |
| 39 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 40 | - @ApiModelProperty(value = "创建时间") | |
| 41 | - private Date[] createTime; | |
| 42 | - | |
| 43 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuPageReqVO.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 cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | - | |
| 9 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | - | |
| 11 | -@ApiModel("管理后台 - 商品sku分页 Request VO") | |
| 12 | -@Data | |
| 13 | -@EqualsAndHashCode(callSuper = true) | |
| 14 | -@ToString(callSuper = true) | |
| 15 | -public class ProductSkuPageReqVO extends PageParam { | |
| 16 | - | |
| 17 | - @ApiModelProperty(value = "spu编号") | |
| 18 | - private Long spuId; | |
| 19 | - | |
| 20 | - @ApiModelProperty(value = "规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]") | |
| 21 | - private String properties; | |
| 22 | - | |
| 23 | - @ApiModelProperty(value = "销售价格,单位:分") | |
| 24 | - private Integer price; | |
| 25 | - | |
| 26 | - @ApiModelProperty(value = "原价, 单位: 分") | |
| 27 | - private Integer originalPrice; | |
| 28 | - | |
| 29 | - @ApiModelProperty(value = "成本价,单位: 分") | |
| 30 | - private Integer costPrice; | |
| 31 | - | |
| 32 | - @ApiModelProperty(value = "条形码") | |
| 33 | - private String barCode; | |
| 34 | - | |
| 35 | - @ApiModelProperty(value = "图片地址") | |
| 36 | - private String picUrl; | |
| 37 | - | |
| 38 | - @ApiModelProperty(value = "状态: 0-正常 1-禁用") | |
| 39 | - private Integer status; | |
| 40 | - | |
| 41 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 42 | - @ApiModelProperty(value = "创建时间") | |
| 43 | - private Date[] createTime; | |
| 44 | - | |
| 45 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java
| 1 | 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.*; | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | + | |
| 9 | +import java.util.Date; | |
| 10 | +import java.util.List; | |
| 6 | 11 | |
| 7 | 12 | @ApiModel("管理后台 - 商品sku Response VO") |
| 8 | 13 | @Data |
| ... | ... | @@ -10,10 +15,15 @@ import io.swagger.annotations.*; |
| 10 | 15 | @ToString(callSuper = true) |
| 11 | 16 | public class ProductSkuRespVO extends ProductSkuBaseVO { |
| 12 | 17 | |
| 13 | - @ApiModelProperty(value = "主键", required = true) | |
| 18 | + @ApiModelProperty(value = "主键", required = true, example = "1024") | |
| 14 | 19 | private Long id; |
| 15 | 20 | |
| 16 | 21 | @ApiModelProperty(value = "创建时间") |
| 17 | 22 | private Date createTime; |
| 18 | 23 | |
| 24 | + /** | |
| 25 | + * 规格值数组 | |
| 26 | + */ | |
| 27 | + private List<Property> properties; | |
| 28 | + | |
| 19 | 29 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuUpdateReqVO.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 ProductSkuUpdateReqVO extends ProductSkuBaseVO { | |
| 13 | - | |
| 14 | - @ApiModelProperty(value = "主键", required = true) | |
| 15 | - @NotNull(message = "主键不能为空") | |
| 16 | - private Long id; | |
| 17 | - | |
| 18 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java
| ... | ... | @@ -3,9 +3,9 @@ package cn.iocoder.yudao.module.product.controller.admin.spu; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; |
| 6 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; | |
| 6 | 7 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; |
| 7 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; | |
| 8 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; | |
| 8 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; | |
| 9 | 9 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; |
| 10 | 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 11 | 11 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| ... | ... | @@ -48,7 +48,7 @@ public class ProductSpuController { |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | @DeleteMapping("/delete") |
| 51 | - @ApiOperation("删除商品spu") | |
| 51 | + @ApiOperation("删除商品 SPU") | |
| 52 | 52 | @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) |
| 53 | 53 | @PreAuthorize("@ss.hasPermission('product:spu:delete')") |
| 54 | 54 | public CommonResult<Boolean> deleteSpu(@RequestParam("id") Long id) { |
| ... | ... | @@ -57,26 +57,28 @@ public class ProductSpuController { |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | @GetMapping("/get") |
| 60 | - @ApiOperation("获得商品spu") | |
| 60 | + @ApiOperation("获得商品 SPU") | |
| 61 | 61 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) |
| 62 | 62 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 63 | - public CommonResult<SpuRespVO> getSpu(@RequestParam("id") Long id) { | |
| 63 | + public CommonResult<ProductSpuRespVO> getSpu(@RequestParam("id") Long id) { | |
| 64 | 64 | return success(spuService.getSpu(id)); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | + // TODO @luowenfeng:新增 get-detail,返回 SpuDetailRespVO | |
| 68 | + | |
| 67 | 69 | @GetMapping("/list") |
| 68 | - @ApiOperation("获得商品spu列表") | |
| 70 | + @ApiOperation("获得商品 SPU 列表") | |
| 69 | 71 | @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) |
| 70 | 72 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 71 | - public CommonResult<List<SpuRespVO>> getSpuList(@RequestParam("ids") Collection<Long> ids) { | |
| 73 | + public CommonResult<List<ProductSpuRespVO>> getSpuList(@RequestParam("ids") Collection<Long> ids) { | |
| 72 | 74 | List<ProductSpuDO> list = spuService.getSpuList(ids); |
| 73 | 75 | return success(ProductSpuConvert.INSTANCE.convertList(list)); |
| 74 | 76 | } |
| 75 | 77 | |
| 76 | 78 | @GetMapping("/page") |
| 77 | - @ApiOperation("获得商品spu分页") | |
| 79 | + @ApiOperation("获得商品 SPU 分页") | |
| 78 | 80 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 79 | - public CommonResult<PageResult<SpuRespVO>> getSpuPage(@Valid SpuPageReqVO pageVO) { | |
| 81 | + public CommonResult<PageResult<ProductSpuRespVO>> getSpuPage(@Valid ProductSpuPageReqVO pageVO) { | |
| 80 | 82 | return success(spuService.getSpuPage(pageVO)); |
| 81 | 83 | } |
| 82 | 84 | ... | ... |
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 { |
| 35 | 35 | @NotNull(message = "商品分类编号不能为空") |
| 36 | 36 | private Long categoryId; |
| 37 | 37 | |
| 38 | - @ApiModelProperty(value = "商品品牌编号", required = true, example = "1") | |
| 39 | -// @NotNull(message = "商品品牌编号不能为空") | |
| 38 | + @ApiModelProperty(value = "商品品牌编号", example = "1") | |
| 40 | 39 | private Long brandId; |
| 41 | 40 | |
| 42 | 41 | @ApiModelProperty(value = "商品图片的数组", required = true) | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; | |
| 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 java.util.Date; | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +@ApiModel(value = "管理后台 - 商品 SPU 详细 Response VO", description = "包括关联的 SKU 等信息") | |
| 14 | +@Data | |
| 15 | +@EqualsAndHashCode(callSuper = true) | |
| 16 | +@ToString(callSuper = true) | |
| 17 | +public class ProductSpuDetailRespVO extends ProductSpuBaseVO { | |
| 18 | + | |
| 19 | + @ApiModelProperty(value = "主键", required = true, example = "1") | |
| 20 | + private Long id; | |
| 21 | + | |
| 22 | + @ApiModelProperty(value = "创建时间") | |
| 23 | + private Date createTime; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * SKU 数组 | |
| 27 | + */ | |
| 28 | + private List<Sku> skus; | |
| 29 | + | |
| 30 | + @ApiModel(value = "管理后台 - 商品 SKU 详细 Response VO") | |
| 31 | + @Data | |
| 32 | + @EqualsAndHashCode(callSuper = true) | |
| 33 | + @ToString(callSuper = true) | |
| 34 | + public static class Sku extends ProductSkuBaseVO { | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 规格的数组 | |
| 38 | + */ | |
| 39 | + private List<ProductSpuDetailRespVO.Property> properties; | |
| 40 | + | |
| 41 | + } | |
| 42 | + | |
| 43 | + @ApiModel(value = "管理后台 - 商品规格的详细 Response VO") | |
| 44 | + @Data | |
| 45 | + @EqualsAndHashCode(callSuper = true) | |
| 46 | + @ToString(callSuper = true) | |
| 47 | + public static class Property extends ProductSkuBaseVO.Property { | |
| 48 | + | |
| 49 | + @ApiModelProperty(value = "规格的名字", required = true, example = "颜色") | |
| 50 | + private String propertyName; | |
| 51 | + | |
| 52 | + @ApiModelProperty(value = "规格值的名字", required = true, example = "蓝色") | |
| 53 | + private String valueName; | |
| 54 | + | |
| 55 | + } | |
| 56 | + | |
| 57 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuPageReqVO.java renamed to 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; |
| 8 | 8 | |
| 9 | 9 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 10 | 10 | |
| 11 | -@ApiModel("管理后台 - 商品spu分页 Request VO") | |
| 11 | +@ApiModel("管理后台 - 商品 SPU 分页 Request VO") | |
| 12 | 12 | @Data |
| 13 | 13 | @EqualsAndHashCode(callSuper = true) |
| 14 | 14 | @ToString(callSuper = true) |
| 15 | -public class SpuPageReqVO extends PageParam { | |
| 15 | +public class ProductSpuPageReqVO extends PageParam { | |
| 16 | 16 | |
| 17 | 17 | @ApiModelProperty(value = "商品名称") |
| 18 | 18 | private String name; | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuRespVO.java renamed to 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; |
| 9 | 9 | import lombok.ToString; |
| 10 | 10 | |
| 11 | 11 | import java.util.Date; |
| 12 | -import java.util.LinkedList; | |
| 13 | 12 | import java.util.List; |
| 14 | 13 | |
| 15 | -@ApiModel("管理后台 - 商品spu Response VO") | |
| 14 | +// TODO @Luowenfeng:这个类只返回 SPU 相关的信息,删除 skus、categoryIds、productPropertyViews;明细使用 SpuDetailRespVO 替代 | |
| 15 | +@ApiModel("管理后台 - 商品 SPU Response VO") | |
| 16 | 16 | @Data |
| 17 | 17 | @EqualsAndHashCode(callSuper = true) |
| 18 | 18 | @ToString(callSuper = true) |
| 19 | -public class SpuRespVO extends ProductSpuBaseVO { | |
| 20 | - | |
| 21 | - // TODO @franky:注解要完整 | |
| 19 | +public class ProductSpuRespVO extends ProductSpuBaseVO { | |
| 22 | 20 | |
| 23 | 21 | @ApiModelProperty(value = "主键", required = true, example = "1") |
| 24 | 22 | private Long id; |
| ... | ... | @@ -33,7 +31,7 @@ public class SpuRespVO extends ProductSpuBaseVO { |
| 33 | 31 | private List<ProductSkuRespVO> skus; |
| 34 | 32 | |
| 35 | 33 | @ApiModelProperty(value = "分类id数组,一直递归到一级父节点", example = "[1,2,4]") |
| 36 | - private LinkedList<Long> categoryIds; | |
| 34 | + private List<Long> categoryIds; | |
| 37 | 35 | |
| 38 | 36 | // TODO @芋艿:再琢磨下 这个 VO 类,其实变成 SpuRespVO 内嵌的 VO 类会更好一点;然后把 SpuRespVO 改成 SpuDetailSpuVO |
| 39 | 37 | ... | ... |
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; |
| 3 | 3 | import cn.hutool.core.bean.BeanUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; | |
| 7 | 6 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; |
| 8 | 7 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; |
| 9 | 8 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuRespVO; | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.product.controller.app.spu.vo; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; | |
| 3 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; | |
| 4 | 4 | import io.swagger.annotations.ApiModel; |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | import lombok.EqualsAndHashCode; |
| 7 | -import lombok.ToString; | |
| 8 | 7 | |
| 9 | 8 | /** |
| 10 | 9 | * <p> |
| ... | ... | @@ -16,7 +15,7 @@ import lombok.ToString; |
| 16 | 15 | @ApiModel("App - 商品spu Response VO") |
| 17 | 16 | @Data |
| 18 | 17 | @EqualsAndHashCode(callSuper = true) |
| 19 | -public class AppSpuRespVO extends SpuRespVO { | |
| 18 | +public class AppSpuRespVO extends ProductSpuRespVO { | |
| 20 | 19 | |
| 21 | 20 | |
| 22 | 21 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.product.convert.property; |
| 2 | 2 | |
| 3 | -import java.util.*; | |
| 4 | - | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | - | |
| 7 | 4 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyAndValueRespVO; |
| 8 | 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyCreateReqVO; |
| 9 | -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyExcelVO; | |
| 10 | 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyUpdateReqVO; |
| 11 | 7 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; |
| 12 | 8 | import org.mapstruct.Mapper; |
| 13 | 9 | import org.mapstruct.factory.Mappers; |
| 14 | 10 | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 15 | 13 | /** |
| 16 | 14 | * 规格名称 Convert |
| 17 | 15 | * |
| ... | ... | @@ -32,6 +30,4 @@ public interface ProductPropertyConvert { |
| 32 | 30 | |
| 33 | 31 | PageResult<ProductPropertyAndValueRespVO> convertPage(PageResult<ProductPropertyDO> page); |
| 34 | 32 | |
| 35 | - List<ProductPropertyExcelVO> convertList02(List<ProductPropertyDO> list); | |
| 36 | - | |
| 37 | 33 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.product.convert.sku; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 3 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 5 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuExcelVO; | |
| 6 | 4 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; |
| 7 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; | |
| 8 | 5 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 9 | 6 | import org.mapstruct.Mapper; |
| 10 | 7 | import org.mapstruct.Mapping; |
| ... | ... | @@ -24,8 +21,6 @@ public interface ProductSkuConvert { |
| 24 | 21 | |
| 25 | 22 | ProductSkuDO convert(ProductSkuCreateOrUpdateReqVO bean); |
| 26 | 23 | |
| 27 | - ProductSkuDO convert(ProductSkuUpdateReqVO bean); | |
| 28 | - | |
| 29 | 24 | @Mapping(source = "properties", target = "properties") |
| 30 | 25 | ProductSkuRespVO convert(ProductSkuDO bean); |
| 31 | 26 | |
| ... | ... | @@ -33,8 +28,4 @@ public interface ProductSkuConvert { |
| 33 | 28 | |
| 34 | 29 | List<ProductSkuDO> convertSkuDOList(List<ProductSkuCreateOrUpdateReqVO> list); |
| 35 | 30 | |
| 36 | - PageResult<ProductSkuRespVO> convertPage(PageResult<ProductSkuDO> page); | |
| 37 | - | |
| 38 | - List<ProductSkuExcelVO> convertList02(List<ProductSkuDO> list); | |
| 39 | - | |
| 40 | 31 | } | ... | ... |
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 { |
| 24 | 24 | |
| 25 | 25 | ProductSpuDO convert(ProductSpuUpdateReqVO bean); |
| 26 | 26 | |
| 27 | - SpuRespVO convert(ProductSpuDO bean); | |
| 27 | + ProductSpuRespVO convert(ProductSpuDO bean); | |
| 28 | 28 | |
| 29 | - List<SpuRespVO> convertList(List<ProductSpuDO> list); | |
| 29 | + List<ProductSpuRespVO> convertList(List<ProductSpuDO> list); | |
| 30 | 30 | |
| 31 | - PageResult<SpuRespVO> convertPage(PageResult<ProductSpuDO> page); | |
| 31 | + PageResult<ProductSpuRespVO> convertPage(PageResult<ProductSpuDO> page); | |
| 32 | 32 | |
| 33 | - SpuPageReqVO convert(AppSpuPageReqVO bean); | |
| 33 | + ProductSpuPageReqVO convert(AppSpuPageReqVO bean); | |
| 34 | 34 | |
| 35 | 35 | AppSpuPageRespVO convertAppResp(ProductSpuDO list); |
| 36 | 36 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.product.dal.mysql.property; |
| 2 | 2 | |
| 3 | -import java.util.*; | |
| 4 | - | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 8 | -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyExportReqVO; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 9 | 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; |
| 10 | 7 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; |
| 11 | 8 | import org.apache.ibatis.annotations.Mapper; |
| ... | ... | @@ -26,12 +23,4 @@ public interface ProductPropertyMapper extends BaseMapperX<ProductPropertyDO> { |
| 26 | 23 | .orderByDesc(ProductPropertyDO::getId)); |
| 27 | 24 | } |
| 28 | 25 | |
| 29 | - default List<ProductPropertyDO> selectList(ProductPropertyExportReqVO reqVO) { | |
| 30 | - return selectList(new LambdaQueryWrapperX<ProductPropertyDO>() | |
| 31 | - .likeIfPresent(ProductPropertyDO::getName, reqVO.getName()) | |
| 32 | - .eqIfPresent(ProductPropertyDO::getStatus, reqVO.getStatus()) | |
| 33 | - .betweenIfPresent(ProductPropertyDO::getCreateTime, reqVO.getCreateTime()) | |
| 34 | - .orderByDesc(ProductPropertyDO::getId)); | |
| 35 | - } | |
| 36 | - | |
| 37 | 26 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.product.dal.mysql.sku; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; | |
| 7 | 5 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 8 | 6 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 7 | |
| 10 | 8 | import java.util.List; |
| 11 | 9 | |
| 12 | 10 | /** |
| 13 | - * 商品sku Mapper | |
| 11 | + * 商品 SKU Mapper | |
| 14 | 12 | * |
| 15 | 13 | * @author 芋道源码 |
| 16 | 14 | */ |
| 17 | 15 | @Mapper |
| 18 | 16 | public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> { |
| 19 | 17 | |
| 20 | - default PageResult<ProductSkuDO> selectPage(ProductSkuPageReqVO reqVO) { | |
| 21 | - return selectPage(reqVO, new LambdaQueryWrapperX<ProductSkuDO>() | |
| 22 | - .eqIfPresent(ProductSkuDO::getSpuId, reqVO.getSpuId()) | |
| 23 | - .eqIfPresent(ProductSkuDO::getProperties, reqVO.getProperties()) | |
| 24 | - .eqIfPresent(ProductSkuDO::getPrice, reqVO.getPrice()) | |
| 25 | -// .eqIfPresent(ProductSkuDO::getOriginalPrice, reqVO.getOriginalPrice()) | |
| 26 | -// .eqIfPresent(ProductSkuDO::getCostPrice, reqVO.getCostPrice()) | |
| 27 | - .eqIfPresent(ProductSkuDO::getBarCode, reqVO.getBarCode()) | |
| 28 | - .eqIfPresent(ProductSkuDO::getPicUrl, reqVO.getPicUrl()) | |
| 29 | - .eqIfPresent(ProductSkuDO::getStatus, reqVO.getStatus()) | |
| 30 | - .betweenIfPresent(ProductSkuDO::getCreateTime, reqVO.getCreateTime()) | |
| 31 | - .orderByDesc(ProductSkuDO::getId)); | |
| 32 | - } | |
| 33 | - | |
| 34 | - | |
| 35 | 18 | // TODO @franky:方法名 selectList; 可以直接调用 selectList |
| 36 | 19 | default List<ProductSkuDO> selectListBySpuIds(List<Long> spuIds) { |
| 37 | 20 | return selectList(ProductSkuDO::getSpuId, spuIds); | ... | ... |
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; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; | |
| 7 | 7 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 8 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 9 | |
| ... | ... | @@ -15,7 +15,7 @@ import org.apache.ibatis.annotations.Mapper; |
| 15 | 15 | @Mapper |
| 16 | 16 | public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> { |
| 17 | 17 | |
| 18 | - default PageResult<ProductSpuDO> selectPage(SpuPageReqVO reqVO) { | |
| 18 | + default PageResult<ProductSpuDO> selectPage(ProductSpuPageReqVO reqVO) { | |
| 19 | 19 | return selectPage(reqVO, new LambdaQueryWrapperX<ProductSpuDO>() |
| 20 | 20 | .likeIfPresent(ProductSpuDO::getName, reqVO.getName()) |
| 21 | 21 | .eqIfPresent(ProductSpuDO::getSellPoint, reqVO.getSellPoint()) | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java
| 1 | 1 | package cn.iocoder.yudao.module.product.service.sku; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 3 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 5 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; | |
| 6 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; | |
| 7 | 4 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 8 | 5 | |
| 9 | 6 | import javax.validation.Valid; |
| ... | ... | @@ -18,21 +15,6 @@ import java.util.List; |
| 18 | 15 | public interface ProductSkuService { |
| 19 | 16 | |
| 20 | 17 | /** |
| 21 | - * 创建商品 SKU | |
| 22 | - * | |
| 23 | - * @param createReqVO 创建信息 | |
| 24 | - * @return 编号 | |
| 25 | - */ | |
| 26 | - Long createSku(@Valid ProductSkuCreateOrUpdateReqVO createReqVO); | |
| 27 | - | |
| 28 | - /** | |
| 29 | - * 更新商品sku | |
| 30 | - * | |
| 31 | - * @param updateReqVO 更新信息 | |
| 32 | - */ | |
| 33 | - void updateSku(@Valid ProductSkuUpdateReqVO updateReqVO); | |
| 34 | - | |
| 35 | - /** | |
| 36 | 18 | * 删除商品sku |
| 37 | 19 | * |
| 38 | 20 | * @param id 编号 |
| ... | ... | @@ -56,14 +38,6 @@ public interface ProductSkuService { |
| 56 | 38 | List<ProductSkuDO> getSkuList(Collection<Long> ids); |
| 57 | 39 | |
| 58 | 40 | /** |
| 59 | - * 获得商品sku分页 | |
| 60 | - * | |
| 61 | - * @param pageReqVO 分页查询 | |
| 62 | - * @return 商品sku分页 | |
| 63 | - */ | |
| 64 | - PageResult<ProductSkuDO> getSkuPage(ProductSkuPageReqVO pageReqVO); | |
| 65 | - | |
| 66 | - /** | |
| 67 | 41 | * 对 sku 的组合的属性等进行合法性校验 |
| 68 | 42 | * |
| 69 | 43 | * @param list sku组合的集合 | ... | ... |
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; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollectionUtil; |
| 4 | 4 | import cn.hutool.core.util.ObjectUtil; |
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | 5 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 7 | 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyAndValueRespVO; |
| 8 | 7 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; |
| 9 | 8 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; |
| 10 | 9 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 11 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; | |
| 12 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; | |
| 13 | 10 | import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; |
| 14 | 11 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 15 | 12 | import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; |
| ... | ... | @@ -43,24 +40,6 @@ public class ProductSkuServiceImpl implements ProductSkuService { |
| 43 | 40 | private ProductPropertyService productPropertyService; |
| 44 | 41 | |
| 45 | 42 | @Override |
| 46 | - public Long createSku(ProductSkuCreateOrUpdateReqVO createReqVO) { | |
| 47 | - // 插入 | |
| 48 | - ProductSkuDO sku = ProductSkuConvert.INSTANCE.convert(createReqVO); | |
| 49 | - productSkuMapper.insert(sku); | |
| 50 | - // 返回 | |
| 51 | - return sku.getId(); | |
| 52 | - } | |
| 53 | - | |
| 54 | - @Override | |
| 55 | - public void updateSku(ProductSkuUpdateReqVO updateReqVO) { | |
| 56 | - // 校验存在 | |
| 57 | - this.validateSkuExists(updateReqVO.getId()); | |
| 58 | - // 更新 | |
| 59 | - ProductSkuDO updateObj = ProductSkuConvert.INSTANCE.convert(updateReqVO); | |
| 60 | - productSkuMapper.updateById(updateObj); | |
| 61 | - } | |
| 62 | - | |
| 63 | - @Override | |
| 64 | 43 | public void deleteSku(Long id) { |
| 65 | 44 | // 校验存在 |
| 66 | 45 | this.validateSkuExists(id); |
| ... | ... | @@ -85,11 +64,6 @@ public class ProductSkuServiceImpl implements ProductSkuService { |
| 85 | 64 | } |
| 86 | 65 | |
| 87 | 66 | @Override |
| 88 | - public PageResult<ProductSkuDO> getSkuPage(ProductSkuPageReqVO pageReqVO) { | |
| 89 | - return productSkuMapper.selectPage(pageReqVO); | |
| 90 | - } | |
| 91 | - | |
| 92 | - @Override | |
| 93 | 67 | public void validateSkus(List<ProductSkuCreateOrUpdateReqVO> skus, Integer specType) { |
| 94 | 68 | // 非多规格,不需要校验 |
| 95 | 69 | if (ObjectUtil.notEqual(specType, ProductSpuSpecTypeEnum.DISABLE.getType())) { | ... | ... |
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 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; |
| 5 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; | |
| 5 | 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.SpuRespVO; | |
| 7 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; |
| 9 | 9 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; |
| 10 | 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| ... | ... | @@ -48,7 +48,7 @@ public interface ProductSpuService { |
| 48 | 48 | * @param id 编号 |
| 49 | 49 | * @return 商品spu |
| 50 | 50 | */ |
| 51 | - SpuRespVO getSpu(Long id); | |
| 51 | + ProductSpuRespVO getSpu(Long id); | |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * 获得商品spu列表 |
| ... | ... | @@ -64,7 +64,7 @@ public interface ProductSpuService { |
| 64 | 64 | * @param pageReqVO 分页查询 |
| 65 | 65 | * @return 商品spu分页 |
| 66 | 66 | */ |
| 67 | - PageResult<SpuRespVO> getSpuPage(SpuPageReqVO pageReqVO); | |
| 67 | + PageResult<ProductSpuRespVO> getSpuPage(ProductSpuPageReqVO pageReqVO); | |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * 获得商品spu分页 | ... | ... |
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; |
| 9 | 9 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 10 | 10 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; |
| 11 | 11 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; |
| 12 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; | |
| 13 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; | |
| 12 | 14 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; |
| 13 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; | |
| 14 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; | |
| 15 | 15 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; |
| 16 | 16 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; |
| 17 | 17 | import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; |
| ... | ... | @@ -125,9 +125,9 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 125 | 125 | |
| 126 | 126 | @Override |
| 127 | 127 | // TODO @芋艿:需要再 review 下 |
| 128 | - public SpuRespVO getSpu(Long id) { | |
| 128 | + public ProductSpuRespVO getSpu(Long id) { | |
| 129 | 129 | ProductSpuDO spu = ProductSpuMapper.selectById(id); |
| 130 | - SpuRespVO spuVO = ProductSpuConvert.INSTANCE.convert(spu); | |
| 130 | + ProductSpuRespVO spuVO = ProductSpuConvert.INSTANCE.convert(spu); | |
| 131 | 131 | if (null != spuVO) { |
| 132 | 132 | List<ProductSkuRespVO> skuReqs = ProductSkuConvert.INSTANCE.convertList(productSkuService.getSkusBySpuId(id)); |
| 133 | 133 | spuVO.setSkus(skuReqs); |
| ... | ... | @@ -179,10 +179,10 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | @Override |
| 182 | - public PageResult<SpuRespVO> getSpuPage(SpuPageReqVO pageReqVO) { | |
| 183 | - PageResult<SpuRespVO> spuVOs = ProductSpuConvert.INSTANCE.convertPage(ProductSpuMapper.selectPage(pageReqVO)); | |
| 182 | + public PageResult<ProductSpuRespVO> getSpuPage(ProductSpuPageReqVO pageReqVO) { | |
| 183 | + PageResult<ProductSpuRespVO> spuVOs = ProductSpuConvert.INSTANCE.convertPage(ProductSpuMapper.selectPage(pageReqVO)); | |
| 184 | 184 | // 查询 sku 的信息 |
| 185 | - List<Long> spuIds = spuVOs.getList().stream().map(SpuRespVO::getId).collect(Collectors.toList()); | |
| 185 | + List<Long> spuIds = spuVOs.getList().stream().map(ProductSpuRespVO::getId).collect(Collectors.toList()); | |
| 186 | 186 | List<ProductSkuRespVO> skus = ProductSkuConvert.INSTANCE.convertList(productSkuService.getSkusBySpuIds(spuIds)); |
| 187 | 187 | // TODO @franky:使用 CollUtil 里的方法替代哈 |
| 188 | 188 | // TODO 芋艿:临时注释 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java
| 1 | 1 | package cn.iocoder.yudao.module.product.service.sku; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 3 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | |
| 6 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO; | |
| 8 | 4 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 9 | 5 | import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; |
| 10 | -import org.junit.jupiter.api.Disabled; | |
| 11 | 6 | import org.junit.jupiter.api.Test; |
| 12 | 7 | import org.springframework.context.annotation.Import; |
| 13 | 8 | |
| 14 | 9 | import javax.annotation.Resource; |
| 15 | 10 | |
| 16 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 17 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 18 | 11 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; |
| 19 | 12 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| 20 | 13 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; |
| 21 | -import static org.junit.jupiter.api.Assertions.*; | |
| 14 | +import static org.junit.jupiter.api.Assertions.assertNull; | |
| 22 | 15 | |
| 23 | 16 | /** |
| 24 | 17 | * {@link ProductSkuServiceImpl} 的单元测试类 |
| ... | ... | @@ -35,46 +28,6 @@ public class SkuServiceImplTest extends BaseDbUnitTest { |
| 35 | 28 | private ProductSkuMapper ProductSkuMapper; |
| 36 | 29 | |
| 37 | 30 | @Test |
| 38 | - public void testCreateSku_success() { | |
| 39 | - // 准备参数 | |
| 40 | - ProductSkuCreateOrUpdateReqVO reqVO = randomPojo(ProductSkuCreateOrUpdateReqVO.class); | |
| 41 | - | |
| 42 | - // 调用 | |
| 43 | - Long skuId = ProductSkuService.createSku(reqVO); | |
| 44 | - // 断言 | |
| 45 | - assertNotNull(skuId); | |
| 46 | - // 校验记录的属性是否正确 | |
| 47 | - ProductSkuDO sku = ProductSkuMapper.selectById(skuId); | |
| 48 | - assertPojoEquals(reqVO, sku); | |
| 49 | - } | |
| 50 | - | |
| 51 | - @Test | |
| 52 | - public void testUpdateSku_success() { | |
| 53 | - // mock 数据 | |
| 54 | - ProductSkuDO dbSku = randomPojo(ProductSkuDO.class); | |
| 55 | - ProductSkuMapper.insert(dbSku);// @Sql: 先插入出一条存在的数据 | |
| 56 | - // 准备参数 | |
| 57 | - ProductSkuUpdateReqVO reqVO = randomPojo(ProductSkuUpdateReqVO.class, o -> { | |
| 58 | - o.setId(dbSku.getId()); // 设置更新的 ID | |
| 59 | - }); | |
| 60 | - | |
| 61 | - // 调用 | |
| 62 | - ProductSkuService.updateSku(reqVO); | |
| 63 | - // 校验是否更新正确 | |
| 64 | - ProductSkuDO sku = ProductSkuMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 65 | - assertPojoEquals(reqVO, sku); | |
| 66 | - } | |
| 67 | - | |
| 68 | - @Test | |
| 69 | - public void testUpdateSku_notExists() { | |
| 70 | - // 准备参数 | |
| 71 | - ProductSkuUpdateReqVO reqVO = randomPojo(ProductSkuUpdateReqVO.class); | |
| 72 | - | |
| 73 | - // 调用, 并断言异常 | |
| 74 | - assertServiceException(() -> ProductSkuService.updateSku(reqVO), SKU_NOT_EXISTS); | |
| 75 | - } | |
| 76 | - | |
| 77 | - @Test | |
| 78 | 31 | public void testDeleteSku_success() { |
| 79 | 32 | // mock 数据 |
| 80 | 33 | ProductSkuDO dbSku = randomPojo(ProductSkuDO.class); |
| ... | ... | @@ -97,58 +50,4 @@ public class SkuServiceImplTest extends BaseDbUnitTest { |
| 97 | 50 | assertServiceException(() -> ProductSkuService.deleteSku(id), SKU_NOT_EXISTS); |
| 98 | 51 | } |
| 99 | 52 | |
| 100 | - @Test | |
| 101 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 102 | - public void testGetSkuPage() { | |
| 103 | - // mock 数据 | |
| 104 | - ProductSkuDO dbSku = randomPojo(ProductSkuDO.class, o -> { // 等会查询到 | |
| 105 | - o.setSpuId(null); | |
| 106 | - o.setProperties(null); | |
| 107 | - o.setPrice(null); | |
| 108 | -// o.setOriginalPrice(null); | |
| 109 | -// o.setCostPrice(null); | |
| 110 | - o.setBarCode(null); | |
| 111 | - o.setPicUrl(null); | |
| 112 | - o.setStatus(null); | |
| 113 | - o.setCreateTime(null); | |
| 114 | - }); | |
| 115 | - ProductSkuMapper.insert(dbSku); | |
| 116 | - // 测试 spuId 不匹配 | |
| 117 | - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null))); | |
| 118 | - // 测试 properties 不匹配 | |
| 119 | - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setProperties(null))); | |
| 120 | - // 测试 price 不匹配 | |
| 121 | - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null))); | |
| 122 | - // 测试 originalPrice 不匹配 | |
| 123 | -// ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setOriginalPrice(null))); | |
| 124 | - // 测试 costPrice 不匹配 | |
| 125 | -// ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCostPrice(null))); | |
| 126 | - // 测试 barCode 不匹配 | |
| 127 | - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null))); | |
| 128 | - // 测试 picUrl 不匹配 | |
| 129 | - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPicUrl(null))); | |
| 130 | - // 测试 status 不匹配 | |
| 131 | - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setStatus(null))); | |
| 132 | - // 测试 createTime 不匹配 | |
| 133 | - ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null))); | |
| 134 | - // 准备参数 | |
| 135 | - ProductSkuPageReqVO reqVO = new ProductSkuPageReqVO(); | |
| 136 | - reqVO.setSpuId(null); | |
| 137 | - reqVO.setProperties(null); | |
| 138 | - reqVO.setPrice(null); | |
| 139 | - reqVO.setOriginalPrice(null); | |
| 140 | - reqVO.setCostPrice(null); | |
| 141 | - reqVO.setBarCode(null); | |
| 142 | - reqVO.setPicUrl(null); | |
| 143 | - reqVO.setStatus(null); | |
| 144 | - reqVO.setCreateTime(null); | |
| 145 | - | |
| 146 | - // 调用 | |
| 147 | - PageResult<ProductSkuDO> pageResult = ProductSkuService.getSkuPage(reqVO); | |
| 148 | - // 断言 | |
| 149 | - assertEquals(1, pageResult.getTotal()); | |
| 150 | - assertEquals(1, pageResult.getList().size()); | |
| 151 | - assertPojoEquals(dbSku, pageResult.getList().get(0)); | |
| 152 | - } | |
| 153 | - | |
| 154 | 53 | } | ... | ... |
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; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | 5 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; |
| 6 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; | |
| 6 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; |
| 9 | 9 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 10 | 10 | import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; |
| ... | ... | @@ -139,7 +139,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { |
| 139 | 139 | // 测试 createTime 不匹配 |
| 140 | 140 | ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null))); |
| 141 | 141 | // 准备参数 |
| 142 | - SpuPageReqVO reqVO = new SpuPageReqVO(); | |
| 142 | + ProductSpuPageReqVO reqVO = new ProductSpuPageReqVO(); | |
| 143 | 143 | reqVO.setName(null); |
| 144 | 144 | reqVO.setSellPoint(null); |
| 145 | 145 | reqVO.setDescription(null); |
| ... | ... | @@ -153,7 +153,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { |
| 153 | 153 | reqVO.setCreateTime(null); |
| 154 | 154 | |
| 155 | 155 | // 调用 |
| 156 | - PageResult<SpuRespVO> pageResult = spuService.getSpuPage(reqVO); | |
| 156 | + PageResult<ProductSpuRespVO> pageResult = spuService.getSpuPage(reqVO); | |
| 157 | 157 | // 断言 |
| 158 | 158 | assertEquals(1, pageResult.getTotal()); |
| 159 | 159 | assertEquals(1, pageResult.getList().size()); | ... | ... |