Commit a778c25075bd694ecb49fd08b553f9797bf4a398
1 parent
728308cb
product:优化代码实现,简化重复判空
Showing
13 changed files
with
13 additions
and
245 deletions
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.api.comment.dto; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.api.comment.dto; | ||
| 2 | 2 | ||
| 3 | import lombok.Data; | 3 | import lombok.Data; |
| 4 | 4 | ||
| 5 | +import javax.validation.constraints.NotNull; | ||
| 5 | import java.util.List; | 6 | import java.util.List; |
| 6 | 7 | ||
| 7 | /** | 8 | /** |
| @@ -15,6 +16,7 @@ public class ProductCommentCreateReqDTO { | @@ -15,6 +16,7 @@ public class ProductCommentCreateReqDTO { | ||
| 15 | /** | 16 | /** |
| 16 | * 商品 SKU 编号 | 17 | * 商品 SKU 编号 |
| 17 | */ | 18 | */ |
| 19 | + @NotNull(message = "商品 SKU 编号不能为空") | ||
| 18 | private Long skuId; | 20 | private Long skuId; |
| 19 | /** | 21 | /** |
| 20 | * 订单编号 | 22 | * 订单编号 |
| @@ -26,20 +28,19 @@ public class ProductCommentCreateReqDTO { | @@ -26,20 +28,19 @@ public class ProductCommentCreateReqDTO { | ||
| 26 | private Long orderItemId; | 28 | private Long orderItemId; |
| 27 | 29 | ||
| 28 | /** | 30 | /** |
| 29 | - * 评分星级 1-5 分 | ||
| 30 | - */ | ||
| 31 | - private Integer scores; | ||
| 32 | - /** | ||
| 33 | * 描述星级 1-5 分 | 31 | * 描述星级 1-5 分 |
| 34 | */ | 32 | */ |
| 33 | + @NotNull(message = "描述星级不能为空") | ||
| 35 | private Integer descriptionScores; | 34 | private Integer descriptionScores; |
| 36 | /** | 35 | /** |
| 37 | * 服务星级 1-5 分 | 36 | * 服务星级 1-5 分 |
| 38 | */ | 37 | */ |
| 38 | + @NotNull(message = "服务星级不能为空") | ||
| 39 | private Integer benefitScores; | 39 | private Integer benefitScores; |
| 40 | /** | 40 | /** |
| 41 | * 评论内容 | 41 | * 评论内容 |
| 42 | */ | 42 | */ |
| 43 | + @NotNull(message = "评论内容不能为空") | ||
| 43 | private String content; | 44 | private String content; |
| 44 | /** | 45 | /** |
| 45 | * 评论图片地址数组,以逗号分隔最多上传 9 张 | 46 | * 评论图片地址数组,以逗号分隔最多上传 9 张 |
| @@ -49,11 +50,12 @@ public class ProductCommentCreateReqDTO { | @@ -49,11 +50,12 @@ public class ProductCommentCreateReqDTO { | ||
| 49 | /** | 50 | /** |
| 50 | * 是否匿名 | 51 | * 是否匿名 |
| 51 | */ | 52 | */ |
| 53 | + @NotNull(message = "是否匿名不能为空") | ||
| 52 | private Boolean anonymous; | 54 | private Boolean anonymous; |
| 53 | /** | 55 | /** |
| 54 | * 评价人 | 56 | * 评价人 |
| 55 | */ | 57 | */ |
| 58 | + @NotNull(message = "评价人不能为空") | ||
| 56 | private Long userId; | 59 | private Long userId; |
| 57 | 60 | ||
| 58 | - | ||
| 59 | } | 61 | } |
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApi.java deleted
| 1 | -package cn.iocoder.yudao.module.product.api.property; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; | ||
| 4 | - | ||
| 5 | -import java.util.Collection; | ||
| 6 | -import java.util.List; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 商品属性值 API 接口 | ||
| 10 | - * | ||
| 11 | - * @author 芋道源码 | ||
| 12 | - */ | ||
| 13 | -public interface ProductPropertyValueApi { | ||
| 14 | - | ||
| 15 | - /** | ||
| 16 | - * 根据编号数组,获得属性值列表 | ||
| 17 | - * | ||
| 18 | - * @param ids 编号数组 | ||
| 19 | - * @return 属性值明细列表 | ||
| 20 | - */ | ||
| 21 | - List<ProductPropertyValueDetailRespDTO> getPropertyValueDetailList(Collection<Long> ids); | ||
| 22 | - | ||
| 23 | -} |
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java
| @@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.product.api.spu.dto; | @@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.product.api.spu.dto; | ||
| 3 | import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; | 3 | import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | -import java.util.List; | ||
| 7 | - | ||
| 8 | // TODO @LeeYan9: ProductSpuRespDTO | 6 | // TODO @LeeYan9: ProductSpuRespDTO |
| 9 | /** | 7 | /** |
| 10 | * 商品 SPU 信息 Response DTO | 8 | * 商品 SPU 信息 Response DTO |
| @@ -27,55 +25,22 @@ public class ProductSpuRespDTO { | @@ -27,55 +25,22 @@ public class ProductSpuRespDTO { | ||
| 27 | */ | 25 | */ |
| 28 | private String name; | 26 | private String name; |
| 29 | /** | 27 | /** |
| 30 | - * 关键字 | ||
| 31 | - */ | ||
| 32 | - private String keyword; | ||
| 33 | - /** | ||
| 34 | * 单位 | 28 | * 单位 |
| 35 | * | 29 | * |
| 36 | * 对应 product_unit 数据字典 | 30 | * 对应 product_unit 数据字典 |
| 37 | */ | 31 | */ |
| 38 | private Integer unit; | 32 | private Integer unit; |
| 39 | - /** | ||
| 40 | - * 商品简介 | ||
| 41 | - */ | ||
| 42 | - private String introduction; | ||
| 43 | - /** | ||
| 44 | - * 商品详情 | ||
| 45 | - */ | ||
| 46 | - private String description; | ||
| 47 | - // TODO @芋艿:是不是要删除 | ||
| 48 | - /** | ||
| 49 | - * 商品条码(一维码) | ||
| 50 | - */ | ||
| 51 | - private String barCode; | ||
| 52 | 33 | ||
| 53 | /** | 34 | /** |
| 54 | * 商品分类编号 | 35 | * 商品分类编号 |
| 55 | */ | 36 | */ |
| 56 | private Long categoryId; | 37 | private Long categoryId; |
| 57 | /** | 38 | /** |
| 58 | - * 商品品牌编号 | ||
| 59 | - */ | ||
| 60 | - private Long brandId; | ||
| 61 | - /** | ||
| 62 | * 商品封面图 | 39 | * 商品封面图 |
| 63 | */ | 40 | */ |
| 64 | private String picUrl; | 41 | private String picUrl; |
| 65 | - /** | ||
| 66 | - * 商品轮播图 | ||
| 67 | - */ | ||
| 68 | - private List<String> sliderPicUrls; | ||
| 69 | - /** | ||
| 70 | - * 商品视频 | ||
| 71 | - */ | ||
| 72 | - private String videoUrl; | ||
| 73 | 42 | ||
| 74 | /** | 43 | /** |
| 75 | - * 排序字段 | ||
| 76 | - */ | ||
| 77 | - private Integer sort; | ||
| 78 | - /** | ||
| 79 | * 商品状态 | 44 | * 商品状态 |
| 80 | * <p> | 45 | * <p> |
| 81 | * 枚举 {@link ProductSpuStatusEnum} | 46 | * 枚举 {@link ProductSpuStatusEnum} |
| @@ -124,22 +89,6 @@ public class ProductSpuRespDTO { | @@ -124,22 +89,6 @@ public class ProductSpuRespDTO { | ||
| 124 | */ | 89 | */ |
| 125 | private Integer giveIntegral; | 90 | private Integer giveIntegral; |
| 126 | 91 | ||
| 127 | - // ========== 统计相关字段 ========= | ||
| 128 | - | ||
| 129 | - /** | ||
| 130 | - * 商品销量 | ||
| 131 | - */ | ||
| 132 | - private Integer salesCount; | ||
| 133 | - /** | ||
| 134 | - * 虚拟销量 | ||
| 135 | - */ | ||
| 136 | - private Integer virtualSalesCount; | ||
| 137 | - /** | ||
| 138 | - * 商品点击量 | ||
| 139 | - */ | ||
| 140 | - private Integer clickCount; | ||
| 141 | - | ||
| 142 | - | ||
| 143 | // ========== 分销相关字段 ========= | 92 | // ========== 分销相关字段 ========= |
| 144 | 93 | ||
| 145 | /** | 94 | /** |
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/group/ProductGroupStyleEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.product.enums.group; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
| 4 | -import lombok.AllArgsConstructor; | ||
| 5 | -import lombok.Getter; | ||
| 6 | - | ||
| 7 | -import java.util.Arrays; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 商品分组的样式枚举 | ||
| 11 | - * | ||
| 12 | - * @author 芋道源码 | ||
| 13 | - */ | ||
| 14 | -@Getter | ||
| 15 | -@AllArgsConstructor | ||
| 16 | -public enum ProductGroupStyleEnum implements IntArrayValuable { | ||
| 17 | - | ||
| 18 | - ONE(1, "每列一个"), | ||
| 19 | - TWO(2, "每列两个"), | ||
| 20 | - THREE(2, "每列三个"),; | ||
| 21 | - | ||
| 22 | - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductGroupStyleEnum::getStyle).toArray(); | ||
| 23 | - | ||
| 24 | - /** | ||
| 25 | - * 列表样式 | ||
| 26 | - */ | ||
| 27 | - private final Integer style; | ||
| 28 | - /** | ||
| 29 | - * 状态名 | ||
| 30 | - */ | ||
| 31 | - private final String name; | ||
| 32 | - | ||
| 33 | - @Override | ||
| 34 | - public int[] array() { | ||
| 35 | - return ARRAYS; | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApiImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.product.api.property; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; | ||
| 4 | -import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert; | ||
| 5 | -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; | ||
| 6 | -import org.springframework.stereotype.Service; | ||
| 7 | -import org.springframework.validation.annotation.Validated; | ||
| 8 | - | ||
| 9 | -import javax.annotation.Resource; | ||
| 10 | -import java.util.Collection; | ||
| 11 | -import java.util.List; | ||
| 12 | - | ||
| 13 | -/** | ||
| 14 | - * 商品属性值 API 实现类 | ||
| 15 | - * | ||
| 16 | - * @author 芋道源码 | ||
| 17 | - */ | ||
| 18 | -@Service | ||
| 19 | -@Validated | ||
| 20 | -public class ProductPropertyValueApiImpl implements ProductPropertyValueApi { | ||
| 21 | - | ||
| 22 | - @Resource | ||
| 23 | - private ProductPropertyValueService productPropertyValueService; | ||
| 24 | - | ||
| 25 | - @Override | ||
| 26 | - public List<ProductPropertyValueDetailRespDTO> getPropertyValueDetailList(Collection<Long> ids) { | ||
| 27 | - return ProductPropertyValueConvert.INSTANCE.convertList02( | ||
| 28 | - productPropertyValueService.getPropertyValueDetailList(ids)); | ||
| 29 | - } | ||
| 30 | - | ||
| 31 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java
| 1 | package cn.iocoder.yudao.module.product.api.sku; | 1 | package cn.iocoder.yudao.module.product.api.sku; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.collection.CollUtil; | ||
| 4 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | 3 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 5 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; | 4 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 6 | import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; | 5 | import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; |
| @@ -11,7 +10,6 @@ import org.springframework.validation.annotation.Validated; | @@ -11,7 +10,6 @@ import org.springframework.validation.annotation.Validated; | ||
| 11 | 10 | ||
| 12 | import javax.annotation.Resource; | 11 | import javax.annotation.Resource; |
| 13 | import java.util.Collection; | 12 | import java.util.Collection; |
| 14 | -import java.util.Collections; | ||
| 15 | import java.util.List; | 13 | import java.util.List; |
| 16 | 14 | ||
| 17 | /** | 15 | /** |
| @@ -35,18 +33,12 @@ public class ProductSkuApiImpl implements ProductSkuApi { | @@ -35,18 +33,12 @@ public class ProductSkuApiImpl implements ProductSkuApi { | ||
| 35 | 33 | ||
| 36 | @Override | 34 | @Override |
| 37 | public List<ProductSkuRespDTO> getSkuList(Collection<Long> ids) { | 35 | public List<ProductSkuRespDTO> getSkuList(Collection<Long> ids) { |
| 38 | - if (CollUtil.isEmpty(ids)) { | ||
| 39 | - return Collections.emptyList(); | ||
| 40 | - } | ||
| 41 | List<ProductSkuDO> skus = productSkuService.getSkuList(ids); | 36 | List<ProductSkuDO> skus = productSkuService.getSkuList(ids); |
| 42 | return ProductSkuConvert.INSTANCE.convertList04(skus); | 37 | return ProductSkuConvert.INSTANCE.convertList04(skus); |
| 43 | } | 38 | } |
| 44 | 39 | ||
| 45 | @Override | 40 | @Override |
| 46 | public List<ProductSkuRespDTO> getSkuListBySpuId(Collection<Long> spuIds) { | 41 | public List<ProductSkuRespDTO> getSkuListBySpuId(Collection<Long> spuIds) { |
| 47 | - if (CollUtil.isEmpty(spuIds)) { | ||
| 48 | - return Collections.emptyList(); | ||
| 49 | - } | ||
| 50 | List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spuIds); | 42 | List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spuIds); |
| 51 | return ProductSkuConvert.INSTANCE.convertList04(skus); | 43 | return ProductSkuConvert.INSTANCE.convertList04(skus); |
| 52 | } | 44 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java
| @@ -27,9 +27,6 @@ public class ProductSpuApiImpl implements ProductSpuApi { | @@ -27,9 +27,6 @@ public class ProductSpuApiImpl implements ProductSpuApi { | ||
| 27 | 27 | ||
| 28 | @Override | 28 | @Override |
| 29 | public List<ProductSpuRespDTO> getSpuList(Collection<Long> ids) { | 29 | public List<ProductSpuRespDTO> getSpuList(Collection<Long> ids) { |
| 30 | - if (CollectionUtil.isEmpty(ids)) { | ||
| 31 | - return Collections.emptyList(); | ||
| 32 | - } | ||
| 33 | return ProductSpuConvert.INSTANCE.convertList2(spuService.getSpuList(ids)); | 30 | return ProductSpuConvert.INSTANCE.convertList2(spuService.getSpuList(ids)); |
| 34 | } | 31 | } |
| 35 | 32 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyValueConvert.java
| 1 | package cn.iocoder.yudao.module.product.convert.property; | 1 | package cn.iocoder.yudao.module.product.convert.property; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 5 | -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | ||
| 6 | -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; | ||
| 7 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; | 4 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; |
| 8 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; | 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; |
| 9 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; |
| 10 | -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; | ||
| 11 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; | 7 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; |
| 12 | -import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; | ||
| 13 | import org.mapstruct.Mapper; | 8 | import org.mapstruct.Mapper; |
| 14 | import org.mapstruct.factory.Mappers; | 9 | import org.mapstruct.factory.Mappers; |
| 15 | 10 | ||
| 16 | import java.util.List; | 11 | import java.util.List; |
| 17 | -import java.util.Map; | ||
| 18 | - | ||
| 19 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 20 | 12 | ||
| 21 | /** | 13 | /** |
| 22 | * 属性值 Convert | 14 | * 属性值 Convert |
| @@ -38,18 +30,4 @@ public interface ProductPropertyValueConvert { | @@ -38,18 +30,4 @@ public interface ProductPropertyValueConvert { | ||
| 38 | 30 | ||
| 39 | PageResult<ProductPropertyValueRespVO> convertPage(PageResult<ProductPropertyValueDO> page); | 31 | PageResult<ProductPropertyValueRespVO> convertPage(PageResult<ProductPropertyValueDO> page); |
| 40 | 32 | ||
| 41 | - default List<ProductPropertyValueDetailRespBO> convertList(List<ProductPropertyValueDO> values, List<ProductPropertyDO> keys) { | ||
| 42 | - Map<Long, ProductPropertyDO> keyMap = convertMap(keys, ProductPropertyDO::getId); | ||
| 43 | - return CollectionUtils.convertList(values, value -> { | ||
| 44 | - ProductPropertyValueDetailRespBO valueDetail = new ProductPropertyValueDetailRespBO() | ||
| 45 | - .setValueId(value.getId()).setValueName(value.getName()); | ||
| 46 | - // 设置属性项 | ||
| 47 | - MapUtils.findAndThen(keyMap, value.getPropertyId(), | ||
| 48 | - key -> valueDetail.setPropertyId(key.getId()).setPropertyName(key.getName())); | ||
| 49 | - return valueDetail; | ||
| 50 | - }); | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - List<ProductPropertyValueDetailRespDTO> convertList02(List<ProductPropertyValueDetailRespBO> list); | ||
| 54 | - | ||
| 55 | } | 33 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java
| @@ -5,7 +5,6 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.Produc | @@ -5,7 +5,6 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.Produc | ||
| 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; | 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; |
| 7 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; | 7 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; |
| 8 | -import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; | ||
| 9 | 8 | ||
| 10 | import java.util.Collection; | 9 | import java.util.Collection; |
| 11 | import java.util.List; | 10 | import java.util.List; |
| @@ -57,14 +56,6 @@ public interface ProductPropertyValueService { | @@ -57,14 +56,6 @@ public interface ProductPropertyValueService { | ||
| 57 | List<ProductPropertyValueDO> getPropertyValueListByPropertyId(Collection<Long> propertyIds); | 56 | List<ProductPropertyValueDO> getPropertyValueListByPropertyId(Collection<Long> propertyIds); |
| 58 | 57 | ||
| 59 | /** | 58 | /** |
| 60 | - * 根据编号数组,获得属性值列表 | ||
| 61 | - * | ||
| 62 | - * @param ids 编号数组 | ||
| 63 | - * @return 属性值明细列表 | ||
| 64 | - */ | ||
| 65 | - List<ProductPropertyValueDetailRespBO> getPropertyValueDetailList(Collection<Long> ids); | ||
| 66 | - | ||
| 67 | - /** | ||
| 68 | * 根据属性项编号,活的属性值数量 | 59 | * 根据属性项编号,活的属性值数量 |
| 69 | * | 60 | * |
| 70 | * @param propertyId 属性项编号数 | 61 | * @param propertyId 属性项编号数 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java
| 1 | package cn.iocoder.yudao.module.product.service.property; | 1 | package cn.iocoder.yudao.module.product.service.property; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.collection.CollUtil; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; | 4 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; | 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; |
| 7 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; |
| 8 | import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert; | 7 | import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert; |
| 9 | -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; | ||
| 10 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; | 8 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; |
| 11 | import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper; | 9 | import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper; |
| 12 | -import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; | ||
| 13 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; | 10 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; |
| 14 | import org.springframework.context.annotation.Lazy; | 11 | import org.springframework.context.annotation.Lazy; |
| 15 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| @@ -17,11 +14,9 @@ import org.springframework.validation.annotation.Validated; | @@ -17,11 +14,9 @@ import org.springframework.validation.annotation.Validated; | ||
| 17 | 14 | ||
| 18 | import javax.annotation.Resource; | 15 | import javax.annotation.Resource; |
| 19 | import java.util.Collection; | 16 | import java.util.Collection; |
| 20 | -import java.util.Collections; | ||
| 21 | import java.util.List; | 17 | import java.util.List; |
| 22 | 18 | ||
| 23 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 24 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 25 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS; | 20 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS; |
| 26 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_NOT_EXISTS; | 21 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_NOT_EXISTS; |
| 27 | 22 | ||
| @@ -100,23 +95,6 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ | @@ -100,23 +95,6 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ | ||
| 100 | } | 95 | } |
| 101 | 96 | ||
| 102 | @Override | 97 | @Override |
| 103 | - public List<ProductPropertyValueDetailRespBO> getPropertyValueDetailList(Collection<Long> ids) { | ||
| 104 | - // 获得属性值列表 | ||
| 105 | - if (CollUtil.isEmpty(ids)) { | ||
| 106 | - return Collections.emptyList(); | ||
| 107 | - } | ||
| 108 | - List<ProductPropertyValueDO> values = productPropertyValueMapper.selectBatchIds(ids); | ||
| 109 | - if (CollUtil.isEmpty(values)) { | ||
| 110 | - return Collections.emptyList(); | ||
| 111 | - } | ||
| 112 | - // 获得属性项列表 | ||
| 113 | - List<ProductPropertyDO> keys = productPropertyService.getPropertyList( | ||
| 114 | - convertSet(values, ProductPropertyValueDO::getPropertyId)); | ||
| 115 | - // 组装明细 | ||
| 116 | - return ProductPropertyValueConvert.INSTANCE.convertList(values, keys); | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - @Override | ||
| 120 | public Integer getPropertyValueCountByPropertyId(Long propertyId) { | 98 | public Integer getPropertyValueCountByPropertyId(Long propertyId) { |
| 121 | return productPropertyValueMapper.selectCountByPropertyId(propertyId); | 99 | return productPropertyValueMapper.selectCountByPropertyId(propertyId); |
| 122 | } | 100 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/bo/ProductPropertyValueDetailRespBO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.service.property.bo; | ||
| 2 | - | ||
| 3 | -import lombok.Data; | ||
| 4 | - | ||
| 5 | -/** | ||
| 6 | - * 商品属性项的明细 Response BO | ||
| 7 | - * | ||
| 8 | - * @author 芋道源码 | ||
| 9 | - */ | ||
| 10 | -@Data | ||
| 11 | -public class ProductPropertyValueDetailRespBO { | ||
| 12 | - | ||
| 13 | - /** | ||
| 14 | - * 属性的编号 | ||
| 15 | - */ | ||
| 16 | - private Long propertyId; | ||
| 17 | - | ||
| 18 | - /** | ||
| 19 | - * 属性的名称 | ||
| 20 | - */ | ||
| 21 | - private String propertyName; | ||
| 22 | - | ||
| 23 | - /** | ||
| 24 | - * 属性值的编号 | ||
| 25 | - */ | ||
| 26 | - private Long valueId; | ||
| 27 | - | ||
| 28 | - /** | ||
| 29 | - * 属性值的名称 | ||
| 30 | - */ | ||
| 31 | - private String valueName; | ||
| 32 | - | ||
| 33 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
| @@ -153,6 +153,9 @@ public class ProductSkuServiceImpl implements ProductSkuService { | @@ -153,6 +153,9 @@ public class ProductSkuServiceImpl implements ProductSkuService { | ||
| 153 | 153 | ||
| 154 | @Override | 154 | @Override |
| 155 | public List<ProductSkuDO> getSkuListBySpuId(Collection<Long> spuIds) { | 155 | public List<ProductSkuDO> getSkuListBySpuId(Collection<Long> spuIds) { |
| 156 | + if (CollUtil.isEmpty(spuIds)) { | ||
| 157 | + return Collections.emptyList(); | ||
| 158 | + } | ||
| 156 | return productSkuMapper.selectListBySpuId(spuIds); | 159 | return productSkuMapper.selectListBySpuId(spuIds); |
| 157 | } | 160 | } |
| 158 | 161 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| @@ -216,6 +216,9 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -216,6 +216,9 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 216 | 216 | ||
| 217 | @Override | 217 | @Override |
| 218 | public List<ProductSpuDO> getSpuList(Collection<Long> ids) { | 218 | public List<ProductSpuDO> getSpuList(Collection<Long> ids) { |
| 219 | + if (CollUtil.isEmpty(ids)) { | ||
| 220 | + return Collections.emptyList(); | ||
| 221 | + } | ||
| 219 | return productSpuMapper.selectBatchIds(ids); | 222 | return productSpuMapper.selectBatchIds(ids); |
| 220 | } | 223 | } |
| 221 | 224 |