Commit 412c017f210358d60d766e1f9c6a03944be5c973

Authored by YunaiV
1 parent 69c87f8b

code review 商品模块

yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java
@@ -55,9 +55,11 @@ public class ProductSpuDetailRespVO extends ProductSpuBaseVO { @@ -55,9 +55,11 @@ public class ProductSpuDetailRespVO extends ProductSpuBaseVO {
55 55
56 } 56 }
57 57
  58 + // TODO @luowenfeng: categoryIds => categoryId,example 也要改下哈
58 @ApiModelProperty(value = "分类 id 数组,一直递归到一级父节点", example = "[1,2,4]") 59 @ApiModelProperty(value = "分类 id 数组,一直递归到一级父节点", example = "[1,2,4]")
59 private Long categoryIds; 60 private Long categoryIds;
60 61
  62 + // TODO @芋艿:在瞅瞅~
61 @ApiModelProperty(value = "规格属性修改和详情展示组合", example = "[{\"propertyId\":2,\"name\":\"内存\",\"propertyValues\":[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]},{\"propertyId\":3,\"name\":\"尺寸\",\"propertyValues\":[{\"v1\":16,\"v2\":\"6.1\"},{\"v1\":15,\"v2\":\"5.7\"}]}]") 63 @ApiModelProperty(value = "规格属性修改和详情展示组合", example = "[{\"propertyId\":2,\"name\":\"内存\",\"propertyValues\":[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]},{\"propertyId\":3,\"name\":\"尺寸\",\"propertyValues\":[{\"v1\":16,\"v2\":\"6.1\"},{\"v1\":15,\"v2\":\"5.7\"}]}]")
62 private List<ProductPropertyViewRespVO> productPropertyViews; 64 private List<ProductPropertyViewRespVO> productPropertyViews;
63 65
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java
@@ -26,8 +26,8 @@ public interface ProductPropertyConvert { @@ -26,8 +26,8 @@ public interface ProductPropertyConvert {
26 ProductPropertyDO convert(ProductPropertyCreateReqVO bean); 26 ProductPropertyDO convert(ProductPropertyCreateReqVO bean);
27 27
28 ProductPropertyDO convert(ProductPropertyUpdateReqVO bean); 28 ProductPropertyDO convert(ProductPropertyUpdateReqVO bean);
29 - ProductPropertyAndValueRespVO convert(ProductPropertyRespVO bean);  
30 29
  30 + ProductPropertyAndValueRespVO convert(ProductPropertyRespVO bean);
31 31
32 ProductPropertyRespVO convert(ProductPropertyDO bean); 32 ProductPropertyRespVO convert(ProductPropertyDO bean);
33 33
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java
@@ -25,6 +25,7 @@ public interface ProductPropertyMapper extends BaseMapperX&lt;ProductPropertyDO&gt; { @@ -25,6 +25,7 @@ public interface ProductPropertyMapper extends BaseMapperX&lt;ProductPropertyDO&gt; {
25 .orderByDesc(ProductPropertyDO::getId)); 25 .orderByDesc(ProductPropertyDO::getId));
26 } 26 }
27 27
  28 + // TODO @luowenfeng: selectByNameLike,这样更清晰哈。
28 default ProductPropertyDO selectByName(String name) { 29 default ProductPropertyDO selectByName(String name) {
29 return selectOne(new LambdaQueryWrapperX<ProductPropertyDO>() 30 return selectOne(new LambdaQueryWrapperX<ProductPropertyDO>()
30 .likeIfPresent(ProductPropertyDO::getName, name)); 31 .likeIfPresent(ProductPropertyDO::getName, name));
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java
@@ -17,6 +17,7 @@ import java.util.List; @@ -17,6 +17,7 @@ import java.util.List;
17 @Mapper 17 @Mapper
18 public interface ProductPropertyValueMapper extends BaseMapperX<ProductPropertyValueDO> { 18 public interface ProductPropertyValueMapper extends BaseMapperX<ProductPropertyValueDO> {
19 19
  20 + // TODO @luowenfeng: selectListByPropertyId 是不是就可以啦
20 default List<ProductPropertyValueDO> selectListByPropertyValueListByPropertyId(List<Long> propertyIds) { 21 default List<ProductPropertyValueDO> selectListByPropertyValueListByPropertyId(List<Long> propertyIds) {
21 return selectList(new LambdaQueryWrapperX<ProductPropertyValueDO>() 22 return selectList(new LambdaQueryWrapperX<ProductPropertyValueDO>()
22 .inIfPresent(ProductPropertyValueDO::getPropertyId, propertyIds)); 23 .inIfPresent(ProductPropertyValueDO::getPropertyId, propertyIds));
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java
@@ -39,7 +39,10 @@ public interface ProductSkuMapper extends BaseMapperX&lt;ProductSkuDO&gt; { @@ -39,7 +39,10 @@ public interface ProductSkuMapper extends BaseMapperX&lt;ProductSkuDO&gt; {
39 this.update(null, lambdaUpdateWrapper); 39 this.update(null, lambdaUpdateWrapper);
40 } 40 }
41 } 41 }
  42 +
  43 + // TODO @luowenfeng: selectListByRemind,虽然不是很好,但是感觉会更清晰一些
42 default List<ProductSkuDO> selectRemindSpuIds(){ 44 default List<ProductSkuDO> selectRemindSpuIds(){
43 return selectList(new QueryWrapper<ProductSkuDO>().apply("stock <= warn_stock")); 45 return selectList(new QueryWrapper<ProductSkuDO>().apply("stock <= warn_stock"));
44 } 46 }
  47 +
45 } 48 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java
@@ -92,6 +92,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { @@ -92,6 +92,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
92 92
93 @Override 93 @Override
94 public void validateCategoryLevel(Long id) { 94 public void validateCategoryLevel(Long id) {
  95 + // TODO @芋艿:在看看,杂能优化下
95 Long parentId = id; 96 Long parentId = id;
96 int i = 2; 97 int i = 2;
97 for (; i >= 0; --i) { 98 for (; i >= 0; --i) {
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java
@@ -54,6 +54,7 @@ public interface ProductPropertyService { @@ -54,6 +54,7 @@ public interface ProductPropertyService {
54 PageResult<ProductPropertyRespVO> getPropertyPage(ProductPropertyPageReqVO pageReqVO); 54 PageResult<ProductPropertyRespVO> getPropertyPage(ProductPropertyPageReqVO pageReqVO);
55 55
56 /** 56 /**
  57 + * 获得指定编号的规格名称
57 * 58 *
58 * @param id 编号 59 * @param id 编号
59 * @return 规格名称 60 * @return 规格名称
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java
@@ -43,7 +43,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { @@ -43,7 +43,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
43 @Transactional(rollbackFor = Exception.class) 43 @Transactional(rollbackFor = Exception.class)
44 public Long createProperty(ProductPropertyCreateReqVO createReqVO) { 44 public Long createProperty(ProductPropertyCreateReqVO createReqVO) {
45 // 校验存在 45 // 校验存在
46 - if(productPropertyMapper.selectByName(createReqVO.getName()) != null){ 46 + if (productPropertyMapper.selectByName(createReqVO.getName()) != null) {
47 throw exception(PROPERTY_EXISTS); 47 throw exception(PROPERTY_EXISTS);
48 } 48 }
49 // 插入 49 // 插入
@@ -58,7 +58,8 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { @@ -58,7 +58,8 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
58 public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) { 58 public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) {
59 // 校验存在 59 // 校验存在
60 this.validatePropertyExists(updateReqVO.getId()); 60 this.validatePropertyExists(updateReqVO.getId());
61 - if(productPropertyMapper.selectByName(updateReqVO.getName()) != null){ 61 + // TODO @luowenfeng:如果是自己的情况下,名字相同也是 ok 的呀~
  62 + if (productPropertyMapper.selectByName(updateReqVO.getName()) != null) {
62 throw exception(PROPERTY_EXISTS); 63 throw exception(PROPERTY_EXISTS);
63 } 64 }
64 // 更新 65 // 更新
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java
@@ -19,9 +19,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU @@ -19,9 +19,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
19 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS; 19 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS;
20 20
21 /** 21 /**
22 - * <p>  
23 - * 规格值 Service 实现类  
24 - * </p> 22 + * 规格值 Service 实现类
25 * 23 *
26 * @author LuoWenFeng 24 * @author LuoWenFeng
27 */ 25 */
@@ -44,6 +42,7 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ @@ -44,6 +42,7 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
44 42
45 @Override 43 @Override
46 public void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO) { 44 public void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO) {
  45 + // TODO @luowenfeng:如果是自己的情况下,名字相同也是 ok 的呀~
47 if (productPropertyValueMapper.selectByName(updateReqVO.getPropertyId(), updateReqVO.getName()) != null) { 46 if (productPropertyValueMapper.selectByName(updateReqVO.getPropertyId(), updateReqVO.getName()) != null) {
48 throw exception(PROPERTY_VALUE_EXISTS); 47 throw exception(PROPERTY_VALUE_EXISTS);
49 } 48 }
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java
@@ -38,6 +38,7 @@ import java.util.stream.Stream; @@ -38,6 +38,7 @@ import java.util.stream.Stream;
38 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; 38 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
39 import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; 39 import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
40 40
  41 +// TODO @芋艿:review 下单元测试
41 /** 42 /**
42 * {@link ProductSpuServiceImpl} 的单元测试类 43 * {@link ProductSpuServiceImpl} 的单元测试类
43 * 44 *