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 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5   -import cn.iocoder.yudao.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 10 import cn.iocoder.yudao.module.product.service.property.ProductPropertyService;
8 11 import io.swagger.v3.oas.annotations.Operation;
9 12 import io.swagger.v3.oas.annotations.Parameter;
... ... @@ -14,8 +17,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
14 17 import org.springframework.validation.annotation.Validated;
15 18 import org.springframework.web.bind.annotation.*;
16 19  
17   -import java.util.List;
18   -
19 20 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
20 21  
21 22 @Tag(name = "管理后台 - 商品属性项")
... ... @@ -30,14 +31,14 @@ public class ProductPropertyController {
30 31 @PostMapping("/create")
31 32 @Operation(summary = "创建属性项")
32 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 35 return success(productPropertyService.createProperty(createReqVO));
35 36 }
36 37  
37 38 @PutMapping("/update")
38 39 @Operation(summary = "更新属性项")
39 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 42 productPropertyService.updateProperty(updateReqVO);
42 43 return success(true);
43 44 }
... ... @@ -56,21 +57,16 @@ public class ProductPropertyController {
56 57 @Parameter(name = "id", description = "编号", required = true, example = "1024")
57 58 @PreAuthorize("@ss.hasPermission('product:property:query')")
58 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 64 @GetMapping("/page")
70 65 @Operation(summary = "获得属性项分页")
71 66 @PreAuthorize("@ss.hasPermission('product:property:query')")
72 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 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5   -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
  5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
6 6 import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
7 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 10 import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
11 11 import io.swagger.v3.oas.annotations.Operation;
12 12 import io.swagger.v3.oas.annotations.Parameter;
13 13 import io.swagger.v3.oas.annotations.tags.Tag;
  14 +import jakarta.annotation.Resource;
  15 +import jakarta.validation.Valid;
14 16 import org.springframework.security.access.prepost.PreAuthorize;
15 17 import org.springframework.validation.annotation.Validated;
16 18 import org.springframework.web.bind.annotation.*;
17 19  
18   -import jakarta.annotation.Resource;
19   -import jakarta.validation.Valid;
20   -
21 20 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
22 21  
23 22 @Tag(name = "管理后台 - 商品属性值")
... ... @@ -32,14 +31,14 @@ public class ProductPropertyValueController {
32 31 @PostMapping("/create")
33 32 @Operation(summary = "创建属性值")
34 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 35 return success(productPropertyValueService.createPropertyValue(createReqVO));
37 36 }
38 37  
39 38 @PutMapping("/update")
40 39 @Operation(summary = "更新属性值")
41 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 42 productPropertyValueService.updatePropertyValue(updateReqVO);
44 43 return success(true);
45 44 }
... ... @@ -58,13 +57,16 @@ public class ProductPropertyValueController {
58 57 @Parameter(name = "id", description = "编号", required = true, example = "1024")
59 58 @PreAuthorize("@ss.hasPermission('product:property:query')")
60 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 64 @GetMapping("/page")
65 65 @Operation(summary = "获得属性值分页")
66 66 @PreAuthorize("@ss.hasPermission('product:property:query')")
67 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 2  
3 3 import io.swagger.v3.oas.annotations.media.Schema;
4 4 import lombok.Data;
5   -import lombok.EqualsAndHashCode;
6   -import lombok.ToString;
7 5  
8 6 import java.time.LocalDateTime;
9 7  
10 8 @Schema(description = "管理后台 - 属性项 Response VO")
11 9 @Data
12   -@EqualsAndHashCode(callSuper = true)
13   -@ToString(callSuper = true)
14   -public class ProductPropertyRespVO extends ProductPropertyBaseVO {
  10 +public class ProductPropertyRespVO {
15 11  
16 12 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
17 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 21 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
20 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 1 package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
2 2  
3 3 import io.swagger.v3.oas.annotations.media.Schema;
4   -import lombok.Data;
5   -
6 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 8 @Data
13   -public class ProductPropertyBaseVO {
  9 +public class ProductPropertySaveReqVO {
  10 +
  11 + @Schema(description = "主键", example = "1")
  12 + private Long id;
14 13  
15 14 @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色")
16 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 1 package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
2 2  
3 3 import io.swagger.v3.oas.annotations.media.Schema;
  4 +import jakarta.validation.constraints.NotEmpty;
  5 +import jakarta.validation.constraints.NotNull;
4 6 import lombok.Data;
5   -import lombok.EqualsAndHashCode;
6   -import lombok.ToString;
7 7  
8 8 import java.time.LocalDateTime;
9 9  
10 10 @Schema(description = "管理后台 - 商品属性值 Response VO")
11 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 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 28 @Schema(description = "创建时间")
20 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 1 package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
2 2  
3 3 import io.swagger.v3.oas.annotations.media.Schema;
4   -import lombok.Data;
5   -
6 4 import jakarta.validation.constraints.NotEmpty;
7 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 9 @Data
14   -public class ProductPropertyValueBaseVO {
  10 +public class ProductPropertyValueSaveReqVO {
  11 +
  12 + @Schema(description = "主键", example = "1024")
  13 + private Long id;
15 14  
16 15 @Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
17 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 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.property.vo.property.ProductPropertyListReqVO;
7 6 import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO;
8 7 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
9 8 import org.apache.ibatis.annotations.Mapper;
10 9  
11   -import java.util.List;
12   -
13 10 @Mapper
14 11 public interface ProductPropertyMapper extends BaseMapperX<ProductPropertyDO> {
15 12  
... ... @@ -24,9 +21,4 @@ public interface ProductPropertyMapper extends BaseMapperX&lt;ProductPropertyDO&gt; {
24 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 22 * @param createReqVO 创建信息
23 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 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 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 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 2  
3 3 import cn.hutool.core.util.ObjUtil;
4 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 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 8 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
11 9 import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyMapper;
12 10 import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
  11 +import jakarta.annotation.Resource;
13 12 import org.springframework.context.annotation.Lazy;
14 13 import org.springframework.stereotype.Service;
15 14 import org.springframework.transaction.annotation.Transactional;
16 15 import org.springframework.validation.annotation.Validated;
17 16  
18   -import jakarta.annotation.Resource;
19 17 import java.util.Collection;
20 18 import java.util.List;
21 19  
... ... @@ -43,7 +41,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
43 41  
44 42 @Override
45 43 @Transactional(rollbackFor = Exception.class)
46   - public Long createProperty(ProductPropertyCreateReqVO createReqVO) {
  44 + public Long createProperty(ProductPropertySaveReqVO createReqVO) {
47 45 // 如果已经添加过该属性项,直接返回
48 46 ProductPropertyDO dbProperty = productPropertyMapper.selectByName(createReqVO.getName());
49 47 if (dbProperty != null) {
... ... @@ -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 53 productPropertyMapper.insert(property);
56 54 // 返回
57 55 return property.getId();
... ... @@ -59,17 +57,17 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
59 57  
60 58 @Override
61 59 @Transactional(rollbackFor = Exception.class)
62   - public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) {
  60 + public void updateProperty(ProductPropertySaveReqVO updateReqVO) {
63 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 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 71 productPropertyMapper.updateById(updateObj);
74 72 // 更新 sku 相关属性
75 73 productSkuService.updateSkuProperty(updateObj.getId(), updateObj.getName());
... ... @@ -97,11 +95,6 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
97 95 }
98 96  
99 97 @Override
100   - public List<ProductPropertyDO> getPropertyList(ProductPropertyListReqVO listReqVO) {
101   - return productPropertyMapper.selectList(listReqVO);
102   - }
103   -
104   - @Override
105 98 public PageResult<ProductPropertyDO> getPropertyPage(ProductPropertyPageReqVO pageReqVO) {
106 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 1 package cn.iocoder.yudao.module.product.service.property;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4   -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
5 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 6 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
8 7  
9 8 import java.util.Collection;
... ... @@ -23,14 +22,14 @@ public interface ProductPropertyValueService {
23 22 * @param createReqVO 创建信息
24 23 * @return 编号
25 24 */
26   - Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO);
  25 + Long createPropertyValue(ProductPropertyValueSaveReqVO createReqVO);
27 26  
28 27 /**
29 28 * 更新属性值
30 29 *
31 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 1 package cn.iocoder.yudao.module.product.service.property;
2 2  
3 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 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 7 import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
9 8 import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper;
10 9 import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
  10 +import jakarta.annotation.Resource;
11 11 import org.springframework.context.annotation.Lazy;
12 12 import org.springframework.stereotype.Service;
13 13 import org.springframework.validation.annotation.Validated;
14 14  
15   -import jakarta.annotation.Resource;
16 15 import java.util.Collection;
17 16 import java.util.List;
18 17  
... ... @@ -34,14 +33,10 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
34 33  
35 34 @Resource
36 35 @Lazy // 延迟加载,避免循环依赖
37   - private ProductPropertyService productPropertyService;
38   -
39   - @Resource
40   - @Lazy // 延迟加载,避免循环依赖
41 36 private ProductSkuService productSkuService;
42 37  
43 38 @Override
44   - public Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO) {
  39 + public Long createPropertyValue(ProductPropertyValueSaveReqVO createReqVO) {
45 40 // 如果已经添加过该属性值,直接返回
46 41 ProductPropertyValueDO dbValue = productPropertyValueMapper.selectByName(
47 42 createReqVO.getPropertyId(), createReqVO.getName());
... ... @@ -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 49 productPropertyValueMapper.insert(value);
55 50 return value.getId();
56 51 }
57 52  
58 53 @Override
59   - public void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO) {
  54 + public void updatePropertyValue(ProductPropertyValueSaveReqVO updateReqVO) {
60 55 validatePropertyValueExists(updateReqVO.getId());
61 56 // 校验名字唯一
62   - ProductPropertyValueDO productPropertyValueDO = productPropertyValueMapper.selectByName
  57 + ProductPropertyValueDO value = productPropertyValueMapper.selectByName
63 58 (updateReqVO.getPropertyId(), updateReqVO.getName());
64   - if (productPropertyValueDO != null && !productPropertyValueDO.getId().equals(updateReqVO.getId())) {
  59 + if (value != null && !value.getId().equals(updateReqVO.getId())) {
65 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 65 productPropertyValueMapper.updateById(updateObj);
71 66 // 更新 sku 相关属性
72 67 productSkuService.updateSkuPropertyValue(updateObj.getId(), updateObj.getName());
... ...