Commit 8c4e3db32b0769034ccb0a7e8ecd4809d953881c

Authored by luowenfeng
1 parent 2bd2cb56

feature(商城): 商城review改

yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java
... ... @@ -12,6 +12,6 @@ public class ProductPropertyValueUpdateReqVO extends ProductPropertyValueBaseVO
12 12  
13 13 @ApiModelProperty(value = "主键", required = true, example = "1024")
14 14 @NotNull(message = "主键不能为空")
15   - private Integer id;
  15 + private Long id;
16 16  
17 17 }
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java
... ... @@ -55,9 +55,8 @@ public class ProductSpuDetailRespVO extends ProductSpuBaseVO {
55 55  
56 56 }
57 57  
58   - // TODO @luowenfeng: categoryIds => categoryId,example 也要改下哈
59   - @ApiModelProperty(value = "分类 id 数组,一直递归到一级父节点", example = "[1,2,4]")
60   - private Long categoryIds;
  58 + @ApiModelProperty(value = "分类 id 数组,一直递归到一级父节点", example = "4")
  59 + private Long categoryId;
61 60  
62 61 // TODO @芋艿:在瞅瞅~
63 62 @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\"}]}]")
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java
... ... @@ -25,10 +25,9 @@ public interface ProductPropertyMapper extends BaseMapperX<ProductPropertyDO> {
25 25 .orderByDesc(ProductPropertyDO::getId));
26 26 }
27 27  
28   - // TODO @luowenfeng: selectByNameLike,这样更清晰哈。
29 28 default ProductPropertyDO selectByName(String name) {
30 29 return selectOne(new LambdaQueryWrapperX<ProductPropertyDO>()
31   - .likeIfPresent(ProductPropertyDO::getName, name));
  30 + .eqIfPresent(ProductPropertyDO::getName, name));
32 31 }
33 32  
34 33 }
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java
... ... @@ -17,8 +17,7 @@ import java.util.List;
17 17 @Mapper
18 18 public interface ProductPropertyValueMapper extends BaseMapperX<ProductPropertyValueDO> {
19 19  
20   - // TODO @luowenfeng: selectListByPropertyId 是不是就可以啦
21   - default List<ProductPropertyValueDO> selectListByPropertyValueListByPropertyId(List<Long> propertyIds) {
  20 + default List<ProductPropertyValueDO> selectListByPropertyId(List<Long> propertyIds) {
22 21 return selectList(new LambdaQueryWrapperX<ProductPropertyValueDO>()
23 22 .inIfPresent(ProductPropertyValueDO::getPropertyId, propertyIds));
24 23 }
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java
... ... @@ -40,8 +40,7 @@ public interface ProductSkuMapper extends BaseMapperX&lt;ProductSkuDO&gt; {
40 40 }
41 41 }
42 42  
43   - // TODO @luowenfeng: selectListByRemind,虽然不是很好,但是感觉会更清晰一些
44   - default List<ProductSkuDO> selectRemindSpuIds(){
  43 + default List<ProductSkuDO> selectListByRemind(){
45 44 return selectList(new QueryWrapper<ProductSkuDO>().apply("stock <= warn_stock"));
46 45 }
47 46  
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java
... ... @@ -19,6 +19,7 @@ import javax.annotation.Resource;
19 19 import java.util.Collection;
20 20 import java.util.List;
21 21 import java.util.Map;
  22 +import java.util.Objects;
22 23  
23 24 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
24 25 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_EXISTS;
... ... @@ -58,8 +59,8 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
58 59 public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) {
59 60 // 校验存在
60 61 this.validatePropertyExists(updateReqVO.getId());
61   - // TODO @luowenfeng:如果是自己的情况下,名字相同也是 ok 的呀~
62   - if (productPropertyMapper.selectByName(updateReqVO.getName()) != null) {
  62 + ProductPropertyDO productPropertyDO = productPropertyMapper.selectByName(updateReqVO.getName());
  63 + if (productPropertyDO != null && !productPropertyDO.getId().equals(updateReqVO.getId())) {
63 64 throw exception(PROPERTY_EXISTS);
64 65 }
65 66 // 更新
... ... @@ -97,10 +98,6 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
97 98 return ProductPropertyConvert.INSTANCE.convertPage(pageResult);
98 99 }
99 100  
100   - private List<ProductPropertyValueDO> getPropertyValueListByPropertyId(List<Long> propertyIds) {
101   - return productPropertyValueMapper.selectListByPropertyValueListByPropertyId(propertyIds);
102   - }
103   -
104 101 @Override
105 102 public ProductPropertyRespVO getProperty(Long id) {
106 103 ProductPropertyDO property = productPropertyMapper.selectById(id);
... ... @@ -117,7 +114,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
117 114 List<ProductPropertyRespVO> propertyList = getPropertyList(listReqVO);
118 115  
119 116 // 查询属性值
120   - List<ProductPropertyValueDO> valueDOList = productPropertyValueMapper.selectListByPropertyValueListByPropertyId(CollectionUtils.convertList(propertyList, ProductPropertyRespVO::getId));
  117 + List<ProductPropertyValueDO> valueDOList = productPropertyValueMapper.selectListByPropertyId(CollectionUtils.convertList(propertyList, ProductPropertyRespVO::getId));
121 118 Map<Long, List<ProductPropertyValueDO>> valueDOMap = CollectionUtils.convertMultiMap(valueDOList, ProductPropertyValueDO::getPropertyId);
122 119 return CollectionUtils.convertList(propertyList, m -> {
123 120 ProductPropertyAndValueRespVO productPropertyAndValueRespVO = ProductPropertyConvert.INSTANCE.convert(m);
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java
... ... @@ -14,6 +14,7 @@ import org.springframework.validation.annotation.Validated;
14 14  
15 15 import javax.annotation.Resource;
16 16 import java.util.List;
  17 +import java.util.Objects;
17 18  
18 19 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
19 20 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS;
... ... @@ -42,8 +43,8 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
42 43  
43 44 @Override
44 45 public void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO) {
45   - // TODO @luowenfeng:如果是自己的情况下,名字相同也是 ok 的呀~
46   - if (productPropertyValueMapper.selectByName(updateReqVO.getPropertyId(), updateReqVO.getName()) != null) {
  46 + ProductPropertyValueDO productPropertyValueDO = productPropertyValueMapper.selectByName(updateReqVO.getPropertyId(), updateReqVO.getName());
  47 + if (productPropertyValueDO != null && !productPropertyValueDO.getId().equals(updateReqVO.getId())) {
47 48 throw exception(PROPERTY_VALUE_EXISTS);
48 49 }
49 50 ProductPropertyValueDO convert = ProductPropertyValueConvert.INSTANCE.convert(updateReqVO);
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
... ... @@ -139,7 +139,7 @@ public class ProductSkuServiceImpl implements ProductSkuService {
139 139  
140 140 @Override
141 141 public List<ProductSkuDO> getRemindSpuIds() {
142   - return productSkuMapper.selectRemindSpuIds();
  142 + return productSkuMapper.selectListByRemind();
143 143 }
144 144  
145 145 @Override
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
... ... @@ -164,7 +164,6 @@ public class ProductSpuServiceImpl implements ProductSpuService {
164 164 });
165 165 respVO.setProductPropertyViews(productPropertyViews);
166 166 }
167   - respVO.setCategoryIds(respVO.getCategoryId());
168 167 }
169 168 return respVO;
170 169 }
... ...