code review 商品模块

This commit is contained in:
YunaiV 2022-10-23 22:15:26 +08:00
parent 69c87f8b24
commit 412c017f21
10 changed files with 16 additions and 6 deletions

View File

@ -55,9 +55,11 @@ public class ProductSpuDetailRespVO extends ProductSpuBaseVO {
}
// TODO @luowenfeng: categoryIds => categoryIdexample 也要改下哈
@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<ProductPropertyViewRespVO> productPropertyViews;

View File

@ -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);

View File

@ -25,6 +25,7 @@ public interface ProductPropertyMapper extends BaseMapperX<ProductPropertyDO> {
.orderByDesc(ProductPropertyDO::getId));
}
// TODO @luowenfeng: selectByNameLike这样更清晰哈
default ProductPropertyDO selectByName(String name) {
return selectOne(new LambdaQueryWrapperX<ProductPropertyDO>()
.likeIfPresent(ProductPropertyDO::getName, name));

View File

@ -17,6 +17,7 @@ import java.util.List;
@Mapper
public interface ProductPropertyValueMapper extends BaseMapperX<ProductPropertyValueDO> {
// TODO @luowenfeng: selectListByPropertyId 是不是就可以啦
default List<ProductPropertyValueDO> selectListByPropertyValueListByPropertyId(List<Long> propertyIds) {
return selectList(new LambdaQueryWrapperX<ProductPropertyValueDO>()
.inIfPresent(ProductPropertyValueDO::getPropertyId, propertyIds));

View File

@ -39,7 +39,10 @@ public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
this.update(null, lambdaUpdateWrapper);
}
}
// TODO @luowenfeng: selectListByRemind虽然不是很好但是感觉会更清晰一些
default List<ProductSkuDO> selectRemindSpuIds(){
return selectList(new QueryWrapper<ProductSkuDO>().apply("stock <= warn_stock"));
}
}

View File

@ -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) {

View File

@ -54,6 +54,7 @@ public interface ProductPropertyService {
PageResult<ProductPropertyRespVO> getPropertyPage(ProductPropertyPageReqVO pageReqVO);
/**
* 获得指定编号的规格名称
*
* @param id 编号
* @return 规格名称

View File

@ -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);
}
// 更新

View File

@ -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;
/**
* <p>
* 规格值 Service 实现类
* </p>
* 规格值 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);
}

View File

@ -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} 的单元测试类
*