Commit bf966cd61012d79c31e444e306782bcab723ac2f

Authored by YunaiV
1 parent f6c8159d

✨ MALL:简化 SPU 属性 的 VO 转化

Showing 18 changed files with 81 additions and 255 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java
@@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.product.controller.admin.property; @@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.product.controller.admin.property;
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.property.vo.property.*;  
6 -import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert; 5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  6 +import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO;
  7 +import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO;
  8 +import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertySaveReqVO;
  9 +import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
7 import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; 10 import cn.iocoder.yudao.module.product.service.property.ProductPropertyService;
8 import io.swagger.v3.oas.annotations.Operation; 11 import io.swagger.v3.oas.annotations.Operation;
9 import io.swagger.v3.oas.annotations.Parameter; 12 import io.swagger.v3.oas.annotations.Parameter;
@@ -14,8 +17,6 @@ import org.springframework.security.access.prepost.PreAuthorize; @@ -14,8 +17,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
14 import org.springframework.validation.annotation.Validated; 17 import org.springframework.validation.annotation.Validated;
15 import org.springframework.web.bind.annotation.*; 18 import org.springframework.web.bind.annotation.*;
16 19
17 -import java.util.List;  
18 -  
19 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 20 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
20 21
21 @Tag(name = "管理后台 - 商品属性项") 22 @Tag(name = "管理后台 - 商品属性项")
@@ -30,14 +31,14 @@ public class ProductPropertyController { @@ -30,14 +31,14 @@ public class ProductPropertyController {
30 @PostMapping("/create") 31 @PostMapping("/create")
31 @Operation(summary = "创建属性项") 32 @Operation(summary = "创建属性项")
32 @PreAuthorize("@ss.hasPermission('product:property:create')") 33 @PreAuthorize("@ss.hasPermission('product:property:create')")
33 - public CommonResult<Long> createProperty(@Valid @RequestBody ProductPropertyCreateReqVO createReqVO) { 34 + public CommonResult<Long> createProperty(@Valid @RequestBody ProductPropertySaveReqVO createReqVO) {
34 return success(productPropertyService.createProperty(createReqVO)); 35 return success(productPropertyService.createProperty(createReqVO));
35 } 36 }
36 37
37 @PutMapping("/update") 38 @PutMapping("/update")
38 @Operation(summary = "更新属性项") 39 @Operation(summary = "更新属性项")
39 @PreAuthorize("@ss.hasPermission('product:property:update')") 40 @PreAuthorize("@ss.hasPermission('product:property:update')")
40 - public CommonResult<Boolean> updateProperty(@Valid @RequestBody ProductPropertyUpdateReqVO updateReqVO) { 41 + public CommonResult<Boolean> updateProperty(@Valid @RequestBody ProductPropertySaveReqVO updateReqVO) {
41 productPropertyService.updateProperty(updateReqVO); 42 productPropertyService.updateProperty(updateReqVO);
42 return success(true); 43 return success(true);
43 } 44 }
@@ -56,21 +57,16 @@ public class ProductPropertyController { @@ -56,21 +57,16 @@ public class ProductPropertyController {
56 @Parameter(name = "id", description = "编号", required = true, example = "1024") 57 @Parameter(name = "id", description = "编号", required = true, example = "1024")
57 @PreAuthorize("@ss.hasPermission('product:property:query')") 58 @PreAuthorize("@ss.hasPermission('product:property:query')")
58 public CommonResult<ProductPropertyRespVO> getProperty(@RequestParam("id") Long id) { 59 public CommonResult<ProductPropertyRespVO> getProperty(@RequestParam("id") Long id) {
59 - return success(ProductPropertyConvert.INSTANCE.convert(productPropertyService.getProperty(id)));  
60 - }  
61 -  
62 - @GetMapping("/list")  
63 - @Operation(summary = "获得属性项列表")  
64 - @PreAuthorize("@ss.hasPermission('product:property:query')")  
65 - public CommonResult<List<ProductPropertyRespVO>> getPropertyList(@Valid ProductPropertyListReqVO listReqVO) {  
66 - return success(ProductPropertyConvert.INSTANCE.convertList(productPropertyService.getPropertyList(listReqVO))); 60 + ProductPropertyDO property = productPropertyService.getProperty(id);
  61 + return success(BeanUtils.toBean(property, ProductPropertyRespVO.class));
67 } 62 }
68 63
69 @GetMapping("/page") 64 @GetMapping("/page")
70 @Operation(summary = "获得属性项分页") 65 @Operation(summary = "获得属性项分页")
71 @PreAuthorize("@ss.hasPermission('product:property:query')") 66 @PreAuthorize("@ss.hasPermission('product:property:query')")
72 public CommonResult<PageResult<ProductPropertyRespVO>> getPropertyPage(@Valid ProductPropertyPageReqVO pageVO) { 67 public CommonResult<PageResult<ProductPropertyRespVO>> getPropertyPage(@Valid ProductPropertyPageReqVO pageVO) {
73 - return success(ProductPropertyConvert.INSTANCE.convertPage(productPropertyService.getPropertyPage(pageVO))); 68 + PageResult<ProductPropertyDO> pageResult = productPropertyService.getPropertyPage(pageVO);
  69 + return success(BeanUtils.toBean(pageResult, ProductPropertyRespVO.class));
74 } 70 }
75 71
76 } 72 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java
@@ -2,22 +2,21 @@ package cn.iocoder.yudao.module.product.controller.admin.property; @@ -2,22 +2,21 @@ package cn.iocoder.yudao.module.product.controller.admin.property;
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.property.vo.value.ProductPropertyValueCreateReqVO; 5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
6 import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; 6 import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
7 import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; 7 import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
8 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;  
9 -import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert; 8 +import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueSaveReqVO;
  9 +import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
10 import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; 10 import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
11 import io.swagger.v3.oas.annotations.Operation; 11 import io.swagger.v3.oas.annotations.Operation;
12 import io.swagger.v3.oas.annotations.Parameter; 12 import io.swagger.v3.oas.annotations.Parameter;
13 import io.swagger.v3.oas.annotations.tags.Tag; 13 import io.swagger.v3.oas.annotations.tags.Tag;
  14 +import jakarta.annotation.Resource;
  15 +import jakarta.validation.Valid;
14 import org.springframework.security.access.prepost.PreAuthorize; 16 import org.springframework.security.access.prepost.PreAuthorize;
15 import org.springframework.validation.annotation.Validated; 17 import org.springframework.validation.annotation.Validated;
16 import org.springframework.web.bind.annotation.*; 18 import org.springframework.web.bind.annotation.*;
17 19
18 -import jakarta.annotation.Resource;  
19 -import jakarta.validation.Valid;  
20 -  
21 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 20 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
22 21
23 @Tag(name = "管理后台 - 商品属性值") 22 @Tag(name = "管理后台 - 商品属性值")
@@ -32,14 +31,14 @@ public class ProductPropertyValueController { @@ -32,14 +31,14 @@ public class ProductPropertyValueController {
32 @PostMapping("/create") 31 @PostMapping("/create")
33 @Operation(summary = "创建属性值") 32 @Operation(summary = "创建属性值")
34 @PreAuthorize("@ss.hasPermission('product:property:create')") 33 @PreAuthorize("@ss.hasPermission('product:property:create')")
35 - public CommonResult<Long> createPropertyValue(@Valid @RequestBody ProductPropertyValueCreateReqVO createReqVO) { 34 + public CommonResult<Long> createPropertyValue(@Valid @RequestBody ProductPropertyValueSaveReqVO createReqVO) {
36 return success(productPropertyValueService.createPropertyValue(createReqVO)); 35 return success(productPropertyValueService.createPropertyValue(createReqVO));
37 } 36 }
38 37
39 @PutMapping("/update") 38 @PutMapping("/update")
40 @Operation(summary = "更新属性值") 39 @Operation(summary = "更新属性值")
41 @PreAuthorize("@ss.hasPermission('product:property:update')") 40 @PreAuthorize("@ss.hasPermission('product:property:update')")
42 - public CommonResult<Boolean> updatePropertyValue(@Valid @RequestBody ProductPropertyValueUpdateReqVO updateReqVO) { 41 + public CommonResult<Boolean> updatePropertyValue(@Valid @RequestBody ProductPropertyValueSaveReqVO updateReqVO) {
43 productPropertyValueService.updatePropertyValue(updateReqVO); 42 productPropertyValueService.updatePropertyValue(updateReqVO);
44 return success(true); 43 return success(true);
45 } 44 }
@@ -58,13 +57,16 @@ public class ProductPropertyValueController { @@ -58,13 +57,16 @@ public class ProductPropertyValueController {
58 @Parameter(name = "id", description = "编号", required = true, example = "1024") 57 @Parameter(name = "id", description = "编号", required = true, example = "1024")
59 @PreAuthorize("@ss.hasPermission('product:property:query')") 58 @PreAuthorize("@ss.hasPermission('product:property:query')")
60 public CommonResult<ProductPropertyValueRespVO> getPropertyValue(@RequestParam("id") Long id) { 59 public CommonResult<ProductPropertyValueRespVO> getPropertyValue(@RequestParam("id") Long id) {
61 - return success(ProductPropertyValueConvert.INSTANCE.convert(productPropertyValueService.getPropertyValue(id))); 60 + ProductPropertyValueDO value = productPropertyValueService.getPropertyValue(id);
  61 + return success(BeanUtils.toBean(value, ProductPropertyValueRespVO.class));
62 } 62 }
63 63
64 @GetMapping("/page") 64 @GetMapping("/page")
65 @Operation(summary = "获得属性值分页") 65 @Operation(summary = "获得属性值分页")
66 @PreAuthorize("@ss.hasPermission('product:property:query')") 66 @PreAuthorize("@ss.hasPermission('product:property:query')")
67 public CommonResult<PageResult<ProductPropertyValueRespVO>> getPropertyValuePage(@Valid ProductPropertyValuePageReqVO pageVO) { 67 public CommonResult<PageResult<ProductPropertyValueRespVO>> getPropertyValuePage(@Valid ProductPropertyValuePageReqVO pageVO) {
68 - return success(ProductPropertyValueConvert.INSTANCE.convertPage(productPropertyValueService.getPropertyValuePage(pageVO))); 68 + PageResult<ProductPropertyValueDO> pageResult = productPropertyValueService.getPropertyValuePage(pageVO);
  69 + return success(BeanUtils.toBean(pageResult, ProductPropertyValueRespVO.class));
69 } 70 }
  71 +
70 } 72 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyCreateReqVO.java deleted
1 -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 -  
8 -@Schema(description = "管理后台 - 属性项创建 Request VO")  
9 -@Data  
10 -@EqualsAndHashCode(callSuper = true)  
11 -@ToString(callSuper = true)  
12 -public class ProductPropertyCreateReqVO extends ProductPropertyBaseVO {  
13 -  
14 -  
15 -}  
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyListReqVO.java deleted
1 -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.ToString;  
6 -  
7 -import java.util.List;  
8 -  
9 -@Schema(description = "管理后台 - 属性项 List Request VO")  
10 -@Data  
11 -@ToString(callSuper = true)  
12 -public class ProductPropertyListReqVO {  
13 -  
14 - @Schema(description = "属性名称", example = "颜色")  
15 - private String name;  
16 -  
17 -}  
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java
@@ -2,20 +2,22 @@ package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; @@ -2,20 +2,22 @@ package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 4 import lombok.Data;
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 5
8 import java.time.LocalDateTime; 6 import java.time.LocalDateTime;
9 7
10 @Schema(description = "管理后台 - 属性项 Response VO") 8 @Schema(description = "管理后台 - 属性项 Response VO")
11 @Data 9 @Data
12 -@EqualsAndHashCode(callSuper = true)  
13 -@ToString(callSuper = true)  
14 -public class ProductPropertyRespVO extends ProductPropertyBaseVO { 10 +public class ProductPropertyRespVO {
15 11
16 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") 12 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
17 private Long id; 13 private Long id;
18 14
  15 + @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色")
  16 + private String name;
  17 +
  18 + @Schema(description = "备注", example = "颜色")
  19 + private String remark;
  20 +
19 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) 21 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
20 private LocalDateTime createTime; 22 private LocalDateTime createTime;
21 23
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyBaseVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertySaveReqVO.java
1 package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; 1 package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 -import lombok.Data;  
5 -  
6 import jakarta.validation.constraints.NotBlank; 4 import jakarta.validation.constraints.NotBlank;
  5 +import lombok.Data;
7 6
8 -/**  
9 - * 商品属性项 Base VO,提供给添加、修改、详细的子 VO 使用  
10 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成  
11 - */ 7 +@Schema(description = "管理后台 - 属性项新增/更新 Request VO")
12 @Data 8 @Data
13 -public class ProductPropertyBaseVO { 9 +public class ProductPropertySaveReqVO {
  10 +
  11 + @Schema(description = "主键", example = "1")
  12 + private Long id;
14 13
15 @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") 14 @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色")
16 @NotBlank(message = "名称不能为空") 15 @NotBlank(message = "名称不能为空")
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java deleted
1 -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 -  
8 -import jakarta.validation.constraints.NotNull;  
9 -  
10 -@Schema(description = "管理后台 - 属性项更新 Request VO")  
11 -@Data  
12 -@EqualsAndHashCode(callSuper = true)  
13 -@ToString(callSuper = true)  
14 -public class ProductPropertyUpdateReqVO extends ProductPropertyBaseVO {  
15 -  
16 - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")  
17 - @NotNull(message = "主键不能为空")  
18 - private Long id;  
19 -  
20 -}  
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueCreateReqVO.java deleted
1 -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 -  
8 -@Schema(description = "管理后台 - 商品属性值创建 Request VO")  
9 -@Data  
10 -@EqualsAndHashCode(callSuper = true)  
11 -@ToString(callSuper = true)  
12 -public class ProductPropertyValueCreateReqVO extends ProductPropertyValueBaseVO {  
13 -  
14 -}  
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java
1 package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; 1 package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
  4 +import jakarta.validation.constraints.NotEmpty;
  5 +import jakarta.validation.constraints.NotNull;
4 import lombok.Data; 6 import lombok.Data;
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 7
8 import java.time.LocalDateTime; 8 import java.time.LocalDateTime;
9 9
10 @Schema(description = "管理后台 - 商品属性值 Response VO") 10 @Schema(description = "管理后台 - 商品属性值 Response VO")
11 @Data 11 @Data
12 -@EqualsAndHashCode(callSuper = true)  
13 -@ToString(callSuper = true)  
14 -public class ProductPropertyValueRespVO extends ProductPropertyValueBaseVO { 12 +public class ProductPropertyValueRespVO {
15 13
16 - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") 14 + @Schema(description = "主键", example = "1024")
17 private Long id; 15 private Long id;
18 16
  17 + @Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  18 + @NotNull(message = "属性项的编号不能为空")
  19 + private Long propertyId;
  20 +
  21 + @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色")
  22 + @NotEmpty(message = "名称名字不能为空")
  23 + private String name;
  24 +
  25 + @Schema(description = "备注", example = "颜色")
  26 + private String remark;
  27 +
19 @Schema(description = "创建时间") 28 @Schema(description = "创建时间")
20 private LocalDateTime createTime; 29 private LocalDateTime createTime;
21 30
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueSaveReqVO.java
1 package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; 1 package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 -import lombok.Data;  
5 -  
6 import jakarta.validation.constraints.NotEmpty; 4 import jakarta.validation.constraints.NotEmpty;
7 import jakarta.validation.constraints.NotNull; 5 import jakarta.validation.constraints.NotNull;
  6 +import lombok.Data;
8 7
9 -/**  
10 -* 属性值 Base VO,提供给添加、修改、详细的子 VO 使用  
11 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成  
12 -*/ 8 +@Schema(description = "管理后台 - 商品属性值新增/更新 Request VO")
13 @Data 9 @Data
14 -public class ProductPropertyValueBaseVO { 10 +public class ProductPropertyValueSaveReqVO {
  11 +
  12 + @Schema(description = "主键", example = "1024")
  13 + private Long id;
15 14
16 @Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") 15 @Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
17 @NotNull(message = "属性项的编号不能为空") 16 @NotNull(message = "属性项的编号不能为空")
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java deleted
1 -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 -  
8 -import jakarta.validation.constraints.NotNull;  
9 -  
10 -@Schema(description = "管理后台 - 商品属性值更新 Request VO")  
11 -@Data  
12 -@EqualsAndHashCode(callSuper = true)  
13 -@ToString(callSuper = true)  
14 -public class ProductPropertyValueUpdateReqVO extends ProductPropertyValueBaseVO {  
15 -  
16 - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")  
17 - @NotNull(message = "主键不能为空")  
18 - private Long id;  
19 -  
20 -}  
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java deleted
1 -package cn.iocoder.yudao.module.product.convert.property;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
4 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyCreateReqVO;  
5 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO;  
6 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyUpdateReqVO;  
7 -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;  
8 -import org.mapstruct.Mapper;  
9 -import org.mapstruct.factory.Mappers;  
10 -  
11 -import java.util.List;  
12 -  
13 -/**  
14 - * 属性项 Convert  
15 - *  
16 - * @author 芋道源码  
17 - */  
18 -@Mapper  
19 -public interface ProductPropertyConvert {  
20 -  
21 - ProductPropertyConvert INSTANCE = Mappers.getMapper(ProductPropertyConvert.class);  
22 -  
23 - ProductPropertyDO convert(ProductPropertyCreateReqVO bean);  
24 -  
25 - ProductPropertyDO convert(ProductPropertyUpdateReqVO bean);  
26 -  
27 - ProductPropertyRespVO convert(ProductPropertyDO bean);  
28 -  
29 - List<ProductPropertyRespVO> convertList(List<ProductPropertyDO> list);  
30 -  
31 - PageResult<ProductPropertyRespVO> convertPage(PageResult<ProductPropertyDO> page);  
32 -  
33 -}  
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyValueConvert.java deleted
1 -package cn.iocoder.yudao.module.product.convert.property;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
4 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;  
5 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;  
6 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;  
7 -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;  
8 -import org.mapstruct.Mapper;  
9 -import org.mapstruct.factory.Mappers;  
10 -  
11 -import java.util.List;  
12 -  
13 -/**  
14 - * 属性值 Convert  
15 - *  
16 - * @author 芋道源码  
17 - */  
18 -@Mapper  
19 -public interface ProductPropertyValueConvert {  
20 -  
21 - ProductPropertyValueConvert INSTANCE = Mappers.getMapper(ProductPropertyValueConvert.class);  
22 -  
23 - ProductPropertyValueDO convert(ProductPropertyValueCreateReqVO bean);  
24 -  
25 - ProductPropertyValueDO convert(ProductPropertyValueUpdateReqVO bean);  
26 -  
27 - ProductPropertyValueRespVO convert(ProductPropertyValueDO bean);  
28 -  
29 - List<ProductPropertyValueRespVO> convertList(List<ProductPropertyValueDO> list);  
30 -  
31 - PageResult<ProductPropertyValueRespVO> convertPage(PageResult<ProductPropertyValueDO> page);  
32 -  
33 -}  
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java
@@ -3,13 +3,10 @@ package cn.iocoder.yudao.module.product.dal.mysql.property; @@ -3,13 +3,10 @@ package cn.iocoder.yudao.module.product.dal.mysql.property;
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyListReqVO;  
7 import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; 6 import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO;
8 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; 7 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
9 import org.apache.ibatis.annotations.Mapper; 8 import org.apache.ibatis.annotations.Mapper;
10 9
11 -import java.util.List;  
12 -  
13 @Mapper 10 @Mapper
14 public interface ProductPropertyMapper extends BaseMapperX<ProductPropertyDO> { 11 public interface ProductPropertyMapper extends BaseMapperX<ProductPropertyDO> {
15 12
@@ -24,9 +21,4 @@ public interface ProductPropertyMapper extends BaseMapperX&lt;ProductPropertyDO&gt; { @@ -24,9 +21,4 @@ public interface ProductPropertyMapper extends BaseMapperX&lt;ProductPropertyDO&gt; {
24 return selectOne(ProductPropertyDO::getName, name); 21 return selectOne(ProductPropertyDO::getName, name);
25 } 22 }
26 23
27 - default List<ProductPropertyDO> selectList(ProductPropertyListReqVO listReqVO) {  
28 - return selectList(new LambdaQueryWrapperX<ProductPropertyDO>()  
29 - .eqIfPresent(ProductPropertyDO::getName, listReqVO.getName()));  
30 - }  
31 -  
32 } 24 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java
@@ -22,14 +22,14 @@ public interface ProductPropertyService { @@ -22,14 +22,14 @@ public interface ProductPropertyService {
22 * @param createReqVO 创建信息 22 * @param createReqVO 创建信息
23 * @return 编号 23 * @return 编号
24 */ 24 */
25 - Long createProperty(@Valid ProductPropertyCreateReqVO createReqVO); 25 + Long createProperty(@Valid ProductPropertySaveReqVO createReqVO);
26 26
27 /** 27 /**
28 * 更新属性项 28 * 更新属性项
29 * 29 *
30 * @param updateReqVO 更新信息 30 * @param updateReqVO 更新信息
31 */ 31 */
32 - void updateProperty(@Valid ProductPropertyUpdateReqVO updateReqVO); 32 + void updateProperty(@Valid ProductPropertySaveReqVO updateReqVO);
33 33
34 /** 34 /**
35 * 删除属性项 35 * 删除属性项
@@ -39,14 +39,6 @@ public interface ProductPropertyService { @@ -39,14 +39,6 @@ public interface ProductPropertyService {
39 void deleteProperty(Long id); 39 void deleteProperty(Long id);
40 40
41 /** 41 /**
42 - * 获得属性项列表  
43 - *  
44 - * @param listReqVO 集合查询  
45 - * @return 属性项集合  
46 - */  
47 - List<ProductPropertyDO> getPropertyList(ProductPropertyListReqVO listReqVO);  
48 -  
49 - /**  
50 * 获取属性名称分页 42 * 获取属性名称分页
51 * 43 *
52 * @param pageReqVO 分页条件 44 * @param pageReqVO 分页条件
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java
@@ -2,20 +2,18 @@ package cn.iocoder.yudao.module.product.service.property; @@ -2,20 +2,18 @@ package cn.iocoder.yudao.module.product.service.property;
2 2
3 import cn.hutool.core.util.ObjUtil; 3 import cn.hutool.core.util.ObjUtil;
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.property.vo.property.ProductPropertyCreateReqVO;  
6 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyListReqVO; 5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
7 import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; 6 import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO;
8 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyUpdateReqVO;  
9 -import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert; 7 +import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertySaveReqVO;
10 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; 8 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
11 import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyMapper; 9 import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyMapper;
12 import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; 10 import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
  11 +import jakarta.annotation.Resource;
13 import org.springframework.context.annotation.Lazy; 12 import org.springframework.context.annotation.Lazy;
14 import org.springframework.stereotype.Service; 13 import org.springframework.stereotype.Service;
15 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
16 import org.springframework.validation.annotation.Validated; 15 import org.springframework.validation.annotation.Validated;
17 16
18 -import jakarta.annotation.Resource;  
19 import java.util.Collection; 17 import java.util.Collection;
20 import java.util.List; 18 import java.util.List;
21 19
@@ -43,7 +41,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { @@ -43,7 +41,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
43 41
44 @Override 42 @Override
45 @Transactional(rollbackFor = Exception.class) 43 @Transactional(rollbackFor = Exception.class)
46 - public Long createProperty(ProductPropertyCreateReqVO createReqVO) { 44 + public Long createProperty(ProductPropertySaveReqVO createReqVO) {
47 // 如果已经添加过该属性项,直接返回 45 // 如果已经添加过该属性项,直接返回
48 ProductPropertyDO dbProperty = productPropertyMapper.selectByName(createReqVO.getName()); 46 ProductPropertyDO dbProperty = productPropertyMapper.selectByName(createReqVO.getName());
49 if (dbProperty != null) { 47 if (dbProperty != null) {
@@ -51,7 +49,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { @@ -51,7 +49,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
51 } 49 }
52 50
53 // 插入 51 // 插入
54 - ProductPropertyDO property = ProductPropertyConvert.INSTANCE.convert(createReqVO); 52 + ProductPropertyDO property = BeanUtils.toBean(createReqVO, ProductPropertyDO.class);
55 productPropertyMapper.insert(property); 53 productPropertyMapper.insert(property);
56 // 返回 54 // 返回
57 return property.getId(); 55 return property.getId();
@@ -59,17 +57,17 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { @@ -59,17 +57,17 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
59 57
60 @Override 58 @Override
61 @Transactional(rollbackFor = Exception.class) 59 @Transactional(rollbackFor = Exception.class)
62 - public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) { 60 + public void updateProperty(ProductPropertySaveReqVO updateReqVO) {
63 validatePropertyExists(updateReqVO.getId()); 61 validatePropertyExists(updateReqVO.getId());
64 // 校验名字重复 62 // 校验名字重复
65 - ProductPropertyDO productPropertyDO = productPropertyMapper.selectByName(updateReqVO.getName());  
66 - if (productPropertyDO != null &&  
67 - ObjUtil.notEqual(productPropertyDO.getId(), updateReqVO.getId())) { 63 + ProductPropertyDO property = productPropertyMapper.selectByName(updateReqVO.getName());
  64 + if (property != null &&
  65 + ObjUtil.notEqual(property.getId(), updateReqVO.getId())) {
68 throw exception(PROPERTY_EXISTS); 66 throw exception(PROPERTY_EXISTS);
69 } 67 }
70 68
71 // 更新 69 // 更新
72 - ProductPropertyDO updateObj = ProductPropertyConvert.INSTANCE.convert(updateReqVO); 70 + ProductPropertyDO updateObj = BeanUtils.toBean(updateReqVO, ProductPropertyDO.class);
73 productPropertyMapper.updateById(updateObj); 71 productPropertyMapper.updateById(updateObj);
74 // 更新 sku 相关属性 72 // 更新 sku 相关属性
75 productSkuService.updateSkuProperty(updateObj.getId(), updateObj.getName()); 73 productSkuService.updateSkuProperty(updateObj.getId(), updateObj.getName());
@@ -97,11 +95,6 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { @@ -97,11 +95,6 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
97 } 95 }
98 96
99 @Override 97 @Override
100 - public List<ProductPropertyDO> getPropertyList(ProductPropertyListReqVO listReqVO) {  
101 - return productPropertyMapper.selectList(listReqVO);  
102 - }  
103 -  
104 - @Override  
105 public PageResult<ProductPropertyDO> getPropertyPage(ProductPropertyPageReqVO pageReqVO) { 98 public PageResult<ProductPropertyDO> getPropertyPage(ProductPropertyPageReqVO pageReqVO) {
106 return productPropertyMapper.selectPage(pageReqVO); 99 return productPropertyMapper.selectPage(pageReqVO);
107 } 100 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java
1 package cn.iocoder.yudao.module.product.service.property; 1 package cn.iocoder.yudao.module.product.service.property;
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.property.vo.value.ProductPropertyValueCreateReqVO;  
5 import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; 4 import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
6 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; 5 +import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueSaveReqVO;
7 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; 6 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
8 7
9 import java.util.Collection; 8 import java.util.Collection;
@@ -23,14 +22,14 @@ public interface ProductPropertyValueService { @@ -23,14 +22,14 @@ public interface ProductPropertyValueService {
23 * @param createReqVO 创建信息 22 * @param createReqVO 创建信息
24 * @return 编号 23 * @return 编号
25 */ 24 */
26 - Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO); 25 + Long createPropertyValue(ProductPropertyValueSaveReqVO createReqVO);
27 26
28 /** 27 /**
29 * 更新属性值 28 * 更新属性值
30 * 29 *
31 * @param updateReqVO 更新信息 30 * @param updateReqVO 更新信息
32 */ 31 */
33 - void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO); 32 + void updatePropertyValue(ProductPropertyValueSaveReqVO updateReqVO);
34 33
35 /** 34 /**
36 * 删除属性值 35 * 删除属性值
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java
1 package cn.iocoder.yudao.module.product.service.property; 1 package cn.iocoder.yudao.module.product.service.property;
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.property.vo.value.ProductPropertyValueCreateReqVO; 4 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
5 import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; 5 import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
6 -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;  
7 -import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert; 6 +import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueSaveReqVO;
8 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; 7 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
9 import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper; 8 import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper;
10 import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; 9 import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
  10 +import jakarta.annotation.Resource;
11 import org.springframework.context.annotation.Lazy; 11 import org.springframework.context.annotation.Lazy;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 import org.springframework.validation.annotation.Validated; 13 import org.springframework.validation.annotation.Validated;
14 14
15 -import jakarta.annotation.Resource;  
16 import java.util.Collection; 15 import java.util.Collection;
17 import java.util.List; 16 import java.util.List;
18 17
@@ -34,14 +33,10 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ @@ -34,14 +33,10 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
34 33
35 @Resource 34 @Resource
36 @Lazy // 延迟加载,避免循环依赖 35 @Lazy // 延迟加载,避免循环依赖
37 - private ProductPropertyService productPropertyService;  
38 -  
39 - @Resource  
40 - @Lazy // 延迟加载,避免循环依赖  
41 private ProductSkuService productSkuService; 36 private ProductSkuService productSkuService;
42 37
43 @Override 38 @Override
44 - public Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO) { 39 + public Long createPropertyValue(ProductPropertyValueSaveReqVO createReqVO) {
45 // 如果已经添加过该属性值,直接返回 40 // 如果已经添加过该属性值,直接返回
46 ProductPropertyValueDO dbValue = productPropertyValueMapper.selectByName( 41 ProductPropertyValueDO dbValue = productPropertyValueMapper.selectByName(
47 createReqVO.getPropertyId(), createReqVO.getName()); 42 createReqVO.getPropertyId(), createReqVO.getName());
@@ -50,23 +45,23 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ @@ -50,23 +45,23 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
50 } 45 }
51 46
52 // 新增 47 // 新增
53 - ProductPropertyValueDO value = ProductPropertyValueConvert.INSTANCE.convert(createReqVO); 48 + ProductPropertyValueDO value = BeanUtils.toBean(createReqVO, ProductPropertyValueDO.class);
54 productPropertyValueMapper.insert(value); 49 productPropertyValueMapper.insert(value);
55 return value.getId(); 50 return value.getId();
56 } 51 }
57 52
58 @Override 53 @Override
59 - public void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO) { 54 + public void updatePropertyValue(ProductPropertyValueSaveReqVO updateReqVO) {
60 validatePropertyValueExists(updateReqVO.getId()); 55 validatePropertyValueExists(updateReqVO.getId());
61 // 校验名字唯一 56 // 校验名字唯一
62 - ProductPropertyValueDO productPropertyValueDO = productPropertyValueMapper.selectByName 57 + ProductPropertyValueDO value = productPropertyValueMapper.selectByName
63 (updateReqVO.getPropertyId(), updateReqVO.getName()); 58 (updateReqVO.getPropertyId(), updateReqVO.getName());
64 - if (productPropertyValueDO != null && !productPropertyValueDO.getId().equals(updateReqVO.getId())) { 59 + if (value != null && !value.getId().equals(updateReqVO.getId())) {
65 throw exception(PROPERTY_VALUE_EXISTS); 60 throw exception(PROPERTY_VALUE_EXISTS);
66 } 61 }
67 62
68 // 更新 63 // 更新
69 - ProductPropertyValueDO updateObj = ProductPropertyValueConvert.INSTANCE.convert(updateReqVO); 64 + ProductPropertyValueDO updateObj = BeanUtils.toBean(updateReqVO, ProductPropertyValueDO.class);
70 productPropertyValueMapper.updateById(updateObj); 65 productPropertyValueMapper.updateById(updateObj);
71 // 更新 sku 相关属性 66 // 更新 sku 相关属性
72 productSkuService.updateSkuPropertyValue(updateObj.getId(), updateObj.getName()); 67 productSkuService.updateSkuPropertyValue(updateObj.getId(), updateObj.getName());