From c25791047f54ec2426b17434bb2d1df364f5f7de Mon Sep 17 00:00:00 2001 From: "zhijiantianya@gmail.com" Date: Fri, 30 Sep 2022 08:30:04 +0000 Subject: [PATCH] =?UTF-8?q?mall:=20=E5=95=86=E5=93=81=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/property/ProductPropertyRespVO.java | 1 - .../vo/value/ProductPropertyValueBaseVO.java | 1 + .../sku/vo/ProductSkuCreateOrUpdateReqVO.java | 2 +- .../admin/spu/vo/ProductSpuDetailRespVO.java | 3 ++- .../admin/spu/vo/ProductSpuPageReqVO.java | 7 ++++--- .../property/ProductPropertyValueMapper.java | 5 +++-- .../dal/mysql/spu/ProductSpuMapper.java | 2 +- .../category/ProductCategoryServiceImpl.java | 3 ++- .../property/ProductPropertyService.java | 17 ++++++++------- .../property/ProductPropertyServiceImpl.java | 9 +++++--- .../ProductPropertyValueServiceImpl.java | 3 ++- .../service/sku/ProductSkuService.java | 3 ++- .../service/sku/ProductSkuServiceImpl.java | 1 + .../service/spu/ProductSpuService.java | 21 +++++++++---------- .../service/spu/ProductSpuServiceImpl.java | 1 + .../src/views/mall/product/spu/save.vue | 1 + 16 files changed, 46 insertions(+), 34 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java index e42cfaba0..9a64fa90d 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java @@ -20,5 +20,4 @@ public class ProductPropertyRespVO extends ProductPropertyBaseVO { @ApiModelProperty(value = "创建时间", required = true) private Date createTime; - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java index c289e7c61..142a8e6e2 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java @@ -27,4 +27,5 @@ public class ProductPropertyValueBaseVO { @ApiModelProperty(value = "备注", example = "颜色") private String remark; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java index 78967339d..6d5ce024d 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java @@ -14,7 +14,7 @@ import java.util.List; @ToString(callSuper = true) public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO { - @ApiModelProperty(value = "商品 id", example = "1") + @ApiModelProperty(value = "商品 SKU 编号", example = "1") private Long id; /** 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 8986a93c8..b29eb85f4 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,7 +55,8 @@ public class ProductSpuDetailRespVO extends ProductSpuBaseVO { } - @ApiModelProperty(value = "分类id数组,一直递归到一级父节点", example = "[1,2,4]") + // TODO @luowenfeng: 只返回 categoryId 可以么? 如果是为了前端修改时使用, 会拿到下拉列表, 自动选中合适的. 可以微信讨论下, 我也不完全确定哈; + @ApiModelProperty(value = "分类 id 数组,一直递归到一级父节点", example = "[1,2,4]") private List categoryIds; @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\"}]}]") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java index 3edda8b40..f6b966a41 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java @@ -14,19 +14,19 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class ProductSpuPageReqVO extends PageParam { - @ApiModelProperty(value = "商品名称") + @ApiModelProperty(value = "商品名称", example = "yutou") private String name; @ApiModelProperty(value = "商品编码", example = "yudaoyuanma") private String code; - @ApiModelProperty(value = "分类id") + @ApiModelProperty(value = "分类id", example = "1") private Long categoryId; @ApiModelProperty(value = "商品品牌编号", example = "1") private Long brandId; - @ApiModelProperty(value = "上下架状态: 0 上架(开启) 1 下架(禁用)") + @ApiModelProperty(value = "上下架状态", example = "1", notes = "参见 CommonStatusEnum 枚举值") private Integer status; @ApiModelProperty(value = "销量最小值", example = "1") @@ -41,6 +41,7 @@ public class ProductSpuPageReqVO extends PageParam { @ApiModelProperty(value = "市场价最大值", example = "1024") private Integer marketPriceMax; + // TODO @luowenfeng: 这个可以改成前端基于 tab, 传递不同的条件么? @ApiModelProperty(value = "tab 状态 null 全部, 0:销售中(上架) 1:仓库中(下架) 2:预警中", example = "1") private Integer tabStatus; 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 bef38d37a..23f09aa2a 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,7 +17,7 @@ import java.util.List; @Mapper public interface ProductPropertyValueMapper extends BaseMapperX { - // TODO @franky:方法名,selectListByXXX。mapper 的操作都是 crud + // TODO @luowenfeng:方法名,selectListByXXX。mapper 的操作都是 crud default List getPropertyValueListByPropertyId(List propertyIds) { // TODO @franky:调用父类的 selectList return selectList(new LambdaQueryWrapperX() @@ -25,7 +25,7 @@ public interface ProductPropertyValueMapper extends BaseMapperX queryWrapperX = new LambdaQueryWrapperX<>(); queryWrapperX.eq(ProductPropertyValueDO::getPropertyId, propertyId) .eq(ProductPropertyValueDO::getDeleted, false); @@ -39,4 +39,5 @@ public interface ProductPropertyValueMapper extends BaseMapperX { .leIfPresent(ProductSpuDO::getMarketPrice, reqVO.getMarketPriceMax()) .geIfPresent(ProductSpuDO::getMarketPrice, reqVO.getMarketPriceMin()) .orderByDesc(ProductSpuDO::getSort); - + // TODO @芋艿: 需要优化下这里的代码 if(reqVO.getTabStatus()!= null && reqVO.getTabStatus() == 2){ productSpuDOLambdaQueryWrapperX.inIfPresent(ProductSpuDO::getId, spuIds); }else{ 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 ac84f755a..2579acc7e 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 @@ -93,12 +93,13 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { @Override public void validateCategoryLevel(Long id) { Long parentId = id; - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { // TODO @luowenfeng: 建议还是先获得 level; 然后判断 level 是不是满足; 这样逻辑会更清晰一些; if (Objects.equals(parentId, ProductCategoryDO.PARENT_ID_NULL)) { throw exception(CATEGORY_LEVEL_ERROR); } ProductCategoryDO category = productCategoryMapper.selectById(parentId); if (category == null) { + // TODO @luowenfeng: 应该抛出 CATEGORY_LEVEL_ERROR throw exception(CATEGORY_NOT_EXISTS); } parentId = category.getParentId(); 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 03c200d64..aec4b9ed2 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,13 +54,14 @@ public interface ProductPropertyService { List getPropertyList(ProductPropertyListReqVO listReqVO); /** - * 获取属性及属性值列表 分页 - * @param pageReqVO - * @return + * 获取属性名称分页 + * + * @param pageReqVO 分页条件 + * @return 规格名称分页 */ PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO); - + // TODO luowenfeng: getProperty 就可以拉, 不用到 Resp ProductPropertyRespVO getPropertyResp(Long id); /** @@ -71,11 +72,11 @@ public interface ProductPropertyService { */ List getPropertyList(Collection ids); - /** - * 获得规格名称列表 - * @param listReqVO 集合查询 - * @return 规格名称集合 + * 获得规格名称 + 值的列表 + * + * @param listReqVO 列表查询 + * @return 规格名称 + 值的列表 */ List getPropertyAndValueList(ProductPropertyListReqVO listReqVO); 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 9cce0d0b3..e070a7140 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 @@ -46,6 +46,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { @Override @Transactional(rollbackFor = Exception.class) public Long createProperty(ProductPropertyCreateReqVO createReqVO) { + // TODO @luowenfeng: 插入和更新的时候, 要校验 name 的唯一性; // 插入 ProductPropertyDO property = ProductPropertyConvert.INSTANCE.convert(createReqVO); productPropertyMapper.insert(property); @@ -96,6 +97,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { //获取属性列表 PageResult pageResult = productPropertyMapper.selectPage(pageReqVO); PageResult propertyRespVOPageResult = ProductPropertyConvert.INSTANCE.convertPage(pageResult); + // TODO @luofengwen: 下面的代码, 如果不要,可以删除哈; git 可以拿到记录的 // List propertyIds = propertyRespVOPageResult.getList().stream().map(ProductPropertyAndValueRespVO::getId).collect(Collectors.toList()); // // //获取属性值列表 @@ -116,7 +118,6 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { @Override public ProductPropertyRespVO getPropertyResp(Long id) { - //查询规格 ProductPropertyDO property = getProperty(id); return ProductPropertyConvert.INSTANCE.convert(property); } @@ -130,13 +131,15 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { public List getPropertyAndValueList(ProductPropertyListReqVO listReqVO) { List propertyList = getPropertyList(listReqVO); - //查询属性值 + // 查询属性值 List valueDOList = productPropertyValueMapper.getPropertyValueListByPropertyId(CollectionUtils.convertList(propertyList, ProductPropertyRespVO::getId)); +// CollectionUtils.convertMultiMap() // TODO @luofengwen: 可以使用这个方法哈 Map> valueDOMap = valueDOList.stream() .map(ProductPropertyValueConvert.INSTANCE::convert) .collect(Collectors.groupingBy(ProductPropertyValueRespVO::getPropertyId)); - //组装 + // 组装 TODO @luowenfeng: CollectionUtils 转换哈; return propertyList.stream().map(m -> { + // TODO @luowenfeng: 使用 mapstruct convert 哈 ProductPropertyAndValueRespVO productPropertyAndValueRespVO = BeanUtil.copyProperties(m, ProductPropertyAndValueRespVO.class); productPropertyAndValueRespVO.setValues(valueDOMap.get(m.getId())); return productPropertyAndValueRespVO; 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 e62270e8b..db99c2881 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 @@ -16,7 +16,7 @@ import javax.annotation.Resource; import java.util.List; /** - *

+ *

TODO @luowenfeng: 类注释 * *

* @@ -31,6 +31,7 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ @Override public Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO) { + // TODO @luowenfeng: 需要校验下在这个 propertyId, 新增和更新, name 都要唯一 ProductPropertyValueDO convert = ProductPropertyValueConvert.INSTANCE.convert(createReqVO); productPropertyValueMapper.insert(convert); return convert.getId(); diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java index 288e2fbb1..9de133a3f 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java @@ -83,8 +83,9 @@ public interface ProductSkuService { */ void deleteSkuBySpuId(Long spuId); + // TODO @luowenfeng: 可以改成返回 ProductSkuDO 列表; 然后, 上层业务在做处理; /** - * 获得商品预警中的spu集合 + * 获得商品预警中的 SPU 集合 * * @return 商品spuId集合 */ diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java index 373d5884d..ed7cd3493 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java @@ -135,6 +135,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { @Override public List getRemindSpuIds() { + // TODO @luowenfeng: mybatis plus 不能出现在 Service 哈; 把这个查询, 下沉一个方法到 mapper 里 List productSkuDOS = productSkuMapper.selectList(new QueryWrapper().apply("stock <= warn_stock")); return productSkuDOS.stream().map(ProductSkuDO::getSpuId).distinct().collect(Collectors.toList()); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java index 6a12dcb52..6b7c7358b 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java @@ -33,38 +33,38 @@ public interface ProductSpuService { void updateSpu(@Valid ProductSpuUpdateReqVO updateReqVO); /** - * 删除商品spu + * 删除商品 SPU * * @param id 编号 */ void deleteSpu(Long id); /** - * 获得商品spu详情 + * 获得商品 SPU 详情 * * @param id 编号 - * @return 商品spu + * @return 商品 SPU */ ProductSpuDetailRespVO getSpuDetail(Long id); /** - * 获得商品spu + * 获得商品 SPU * * @param id 编号 - * @return 商品spu + * @return 商品 SPU */ ProductSpuRespVO getSpu(Long id); /** - * 获得商品spu列表 + * 获得商品 SPU 列表 * - * @param ids 编号 - * @return 商品spu列表 + * @param ids 编号数组 + * @return 商品 SPU 列表 */ List getSpuList(Collection ids); /** - * 获得商品spu分页 + * 获得商品 SPU 分页 * * @param pageReqVO 分页查询 * @return 商品spu分页 @@ -72,12 +72,11 @@ public interface ProductSpuService { PageResult getSpuPage(ProductSpuPageReqVO pageReqVO); /** - * 获得商品spu分页 + * 获得商品 SPU 分页 // TODO @luowenfeng: 中文和英文之间, 要有一个空格; 这样, 阅读起来会更清晰; 我已经都改啦 * * @param pageReqVO 分页查询 * @return 商品spu分页 */ PageResult getSpuPage(AppSpuPageReqVO pageReqVO); - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java index 3a0a68d3b..d901047d1 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java @@ -192,6 +192,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { public PageResult getSpuPage(ProductSpuPageReqVO pageReqVO) { List remindSpuIds= null; // todo @yunai 预警类型的判断应该可以优化,看下怎么处理 + // TODO @luowenfeng: 先这么简单处理; 性能应该影响不大的; if(pageReqVO.getTabStatus() != null && pageReqVO.getTabStatus() == 2){ remindSpuIds= productSkuService.getRemindSpuIds(); if(remindSpuIds.isEmpty()){ diff --git a/yudao-ui-admin/src/views/mall/product/spu/save.vue b/yudao-ui-admin/src/views/mall/product/spu/save.vue index 72cd833a3..e454da482 100644 --- a/yudao-ui-admin/src/views/mall/product/spu/save.vue +++ b/yudao-ui-admin/src/views/mall/product/spu/save.vue @@ -39,6 +39,7 @@ +