From 412c017f210358d60d766e1f9c6a03944be5c973 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 23 Oct 2022 22:15:26 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=20=E5=95=86=E5=93=81=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/spu/vo/ProductSpuDetailRespVO.java | 2 ++ .../product/convert/property/ProductPropertyConvert.java | 2 +- .../product/dal/mysql/property/ProductPropertyMapper.java | 1 + .../dal/mysql/property/ProductPropertyValueMapper.java | 1 + .../yudao/module/product/dal/mysql/sku/ProductSkuMapper.java | 3 +++ .../product/service/category/ProductCategoryServiceImpl.java | 1 + .../product/service/property/ProductPropertyService.java | 1 + .../product/service/property/ProductPropertyServiceImpl.java | 5 +++-- .../service/property/ProductPropertyValueServiceImpl.java | 5 ++--- .../product/service/spu/ProductSpuServiceImplTest.java | 1 + 10 files changed, 16 insertions(+), 6 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java index 40696455a..d7c43b90f 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java +++ b/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 { } + // TODO @luowenfeng: categoryIds => categoryId,example 也要改下哈 @ApiModelProperty(value = "分类 id 数组,一直递归到一级父节点", example = "[1,2,4]") private Long categoryIds; + // TODO @芋艿:在瞅瞅~ @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\"}]}]") private List productPropertyViews; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java index f780f72c7..91f811ad6 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java +++ b/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 { ProductPropertyDO convert(ProductPropertyCreateReqVO bean); ProductPropertyDO convert(ProductPropertyUpdateReqVO bean); - ProductPropertyAndValueRespVO convert(ProductPropertyRespVO bean); + ProductPropertyAndValueRespVO convert(ProductPropertyRespVO bean); ProductPropertyRespVO convert(ProductPropertyDO bean); diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java index 1b58a88e7..697beb22d 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java +++ b/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 { .orderByDesc(ProductPropertyDO::getId)); } + // TODO @luowenfeng: selectByNameLike,这样更清晰哈。 default ProductPropertyDO selectByName(String name) { return selectOne(new LambdaQueryWrapperX() .likeIfPresent(ProductPropertyDO::getName, name)); diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java index c392bb81d..4853afeae 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java +++ b/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; @Mapper public interface ProductPropertyValueMapper extends BaseMapperX { + // TODO @luowenfeng: selectListByPropertyId 是不是就可以啦 default List selectListByPropertyValueListByPropertyId(List propertyIds) { return selectList(new LambdaQueryWrapperX() .inIfPresent(ProductPropertyValueDO::getPropertyId, propertyIds)); diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java index f74f04b92..6698007c6 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java +++ b/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 { this.update(null, lambdaUpdateWrapper); } } + + // TODO @luowenfeng: selectListByRemind,虽然不是很好,但是感觉会更清晰一些 default List selectRemindSpuIds(){ return selectList(new QueryWrapper().apply("stock <= warn_stock")); } + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java index f9c18758f..ffe55e9bf 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java +++ b/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 { @Override public void validateCategoryLevel(Long id) { + // TODO @芋艿:在看看,杂能优化下 Long parentId = id; int i = 2; for (; i >= 0; --i) { diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java index 2d991a861..8780c7865 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java +++ b/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 { PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO); /** + * 获得指定编号的规格名称 * * @param id 编号 * @return 规格名称 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java index 9bc34bbd7..17e38fc98 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java +++ b/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 { @Transactional(rollbackFor = Exception.class) public Long createProperty(ProductPropertyCreateReqVO createReqVO) { // 校验存在 - if(productPropertyMapper.selectByName(createReqVO.getName()) != null){ + if (productPropertyMapper.selectByName(createReqVO.getName()) != null) { throw exception(PROPERTY_EXISTS); } // 插入 @@ -58,7 +58,8 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) { // 校验存在 this.validatePropertyExists(updateReqVO.getId()); - if(productPropertyMapper.selectByName(updateReqVO.getName()) != null){ + // TODO @luowenfeng:如果是自己的情况下,名字相同也是 ok 的呀~ + if (productPropertyMapper.selectByName(updateReqVO.getName()) != null) { throw exception(PROPERTY_EXISTS); } // 更新 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java index f954d763a..551fb00e3 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java +++ b/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 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS; /** - *

- * 规格值 Service 实现类 - *

+ * 规格值 Service 实现类 * * @author LuoWenFeng */ @@ -44,6 +42,7 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ @Override public void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO) { + // TODO @luowenfeng:如果是自己的情况下,名字相同也是 ok 的呀~ if (productPropertyValueMapper.selectByName(updateReqVO.getPropertyId(), updateReqVO.getName()) != null) { throw exception(PROPERTY_VALUE_EXISTS); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java index 899138f72..0bddf59ce 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java +++ b/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; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +// TODO @芋艿:review 下单元测试 /** * {@link ProductSpuServiceImpl} 的单元测试类 *