product:完善 rpc api 的注解

pull/58/head
YunaiV 2023-10-22 21:43:37 +08:00
parent df7d49a8b1
commit ec49751f25
22 changed files with 173 additions and 469 deletions

View File

@ -1,20 +1,25 @@
package cn.iocoder.yudao.module.product.api.category;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
/**
* API
*
* @author owen
*/
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 商品分类")
public interface ProductCategoryApi {
/**
*
* 1.
* 2.
*
* @param ids
*/
void validateCategoryList(Collection<Long> ids);
String PREFIX = ApiConstants.PREFIX + "/category";
@GetMapping(PREFIX + "/valid")
@Operation(summary = "校验部门是否合法")
@Parameter(name = "ids", description = "商品分类编号数组", example = "1,2", required = true)
CommonResult<Boolean> validateCategoryList(@RequestParam("ids") Collection<Long> ids);
}

View File

@ -1,20 +1,24 @@
package cn.iocoder.yudao.module.product.api.comment;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
import cn.iocoder.yudao.module.product.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* API
*
* @author HUIHUI
*/
import javax.validation.Valid;
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 产品评论")
public interface ProductCommentApi {
/**
*
*
* @param createReqDTO
* @return id
*/
Long createComment(ProductCommentCreateReqDTO createReqDTO);
String PREFIX = ApiConstants.PREFIX + "/comment";
@PostMapping(PREFIX + "/create")
@Operation(summary = "创建评论")
CommonResult<Long> createComment(@RequestBody @Valid ProductCommentCreateReqDTO createReqDTO);
}

View File

@ -1,59 +1,40 @@
package cn.iocoder.yudao.module.product.api.comment.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* DTO
*
* @author HUIHUI
*/
@Schema(description = "RPC 服务 - 商品评论创建 Request DTO")
@Data
public class ProductCommentCreateReqDTO {
/**
* SKU
*/
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "商品 SKU 编号不能为空")
private Long skuId;
/**
*
*/
@Schema(description = "订单编号", example = "223")
private Long orderId;
/**
*
*/
@Schema(description = "交易订单项编号", example = "666")
private Long orderItemId;
/**
* 1-5
*/
private Integer scores;
/**
* 1-5
*/
@Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
@NotNull(message = "描述星级不能为空")
private Integer descriptionScores;
/**
* 1-5
*/
@Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
@NotNull(message = "服务星级不能为空")
private Integer benefitScores;
/**
*
*/
@Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "好评")
@NotNull(message = "评论内容不能为空")
private String content;
/**
* 9
*/
@Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", example = "https://www.iocoder.cn/xxx.jpg,http://www.iocoder.cn/yyy.jpg")
private List<String> picUrls;
/**
*
*/
@Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "是否匿名不能为空")
private Boolean anonymous;
/**
*
*/
@Schema(description = "评价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "888")
@NotNull(message = "评价人不能为空")
private Long userId;
}

View File

@ -1,23 +0,0 @@
package cn.iocoder.yudao.module.product.api.property;
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
import java.util.Collection;
import java.util.List;
/**
* API
*
* @author
*/
public interface ProductPropertyValueApi {
/**
*
*
* @param ids
* @return
*/
List<ProductPropertyValueDetailRespDTO> getPropertyValueDetailList(Collection<Long> ids);
}

View File

@ -1,33 +1,20 @@
package cn.iocoder.yudao.module.product.api.property.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* Response DTO
*
* @author
*/
@Schema(description = "RPC 服务 - 商品属性项的明细 Response DTO")
@Data
public class ProductPropertyValueDetailRespDTO {
/**
*
*/
@Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long propertyId;
/**
*
*/
@Schema(description = "属性的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色")
private String propertyName;
/**
*
*/
@Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
private Long valueId;
/**
*
*/
@Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色")
private String valueName;
}

View File

@ -1,48 +1,45 @@
package cn.iocoder.yudao.module.product.api.sku;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
import cn.iocoder.yudao.module.product.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
/**
* SKU API
*
* @author LeeYan9
* @since 2022-08-26
*/
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 商品 SKU")
public interface ProductSkuApi {
/**
* SKU
*
* @param id SKU
* @return SKU
*/
ProductSkuRespDTO getSku(Long id);
String PREFIX = ApiConstants.PREFIX + "/sku";
/**
* SKU
*
* @param ids SKU
* @return SKU
*/
List<ProductSkuRespDTO> getSkuList(Collection<Long> ids);
@GetMapping(PREFIX + "/get")
@Operation(summary = "查询 SKU 信息")
@Parameter(name = "id", description = "SKU 编号", required = true, example = "1024")
CommonResult<ProductSkuRespDTO> getSku(@RequestParam("id") Long id);
/**
* SKU
*
* @param spuIds SPU
* @return SKU
*/
List<ProductSkuRespDTO> getSkuListBySpuId(Collection<Long> spuIds);
@GetMapping(PREFIX + "/list")
@Operation(summary = "批量查询 SKU 信息")
@Parameter(name = "ids", description = "SKU 编号列表", required = true, example = "1024,2048")
CommonResult<List<ProductSkuRespDTO>> getSkuList(@RequestParam("ids") Collection<Long> ids);
/**
* SKU or
*
* @param updateStockReqDTO
*/
void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO);
@GetMapping(PREFIX + "/list-by-spu-id")
@Operation(summary = "批量查询 SKU 信息")
@Parameter(name = "spuIds", description = "SPU 编号列表", required = true, example = "1024,2048")
CommonResult<List<ProductSkuRespDTO>> getSkuListBySpuId(@RequestParam("spuIds") Collection<Long> spuIds);
@PostMapping(PREFIX + "/update-stock")
@Operation(summary = "更新 SKU 库存(增加 or 减少)")
CommonResult<Boolean> updateSkuStock(@RequestBody @Valid ProductSkuUpdateStockReqDTO updateStockReqDTO);
}

View File

@ -1,71 +1,44 @@
package cn.iocoder.yudao.module.product.api.sku.dto;
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* SKU Response DTO
*
* @author LeeYan9
* @since 2022-08-26
*/
@Schema(description = "RPC 服务 - 商品 SKU 信息 Response DTO")
@Data
public class ProductSkuRespDTO {
/**
* SKU
*/
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
/**
* SPU
*/
@Schema(description = "SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
private Long spuId;
/**
*
*/
@Schema(description = "属性数组", requiredMode = Schema.RequiredMode.REQUIRED)
private List<ProductPropertyValueDetailRespDTO> properties;
/**
*
*/
@Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer price;
/**
*
*/
@Schema(description = "市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200")
private Integer marketPrice;
/**
*
*/
@Schema(description = "成本价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "300")
private Integer costPrice;
/**
* SKU
*/
@Schema(description = "SKU 的条形码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456789")
private String barCode;
/**
*
*/
@Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg")
private String picUrl;
/**
*
*/
@Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer stock;
/**
* kg
*/
@Schema(description = "商品重量单位kg 千克", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.5")
private Double weight;
/**
* m^3
*/
@Schema(description = "商品体积单位m^3 平米", requiredMode = Schema.RequiredMode.REQUIRED, example = "3.0")
private Double volume;
/**
*
*/
@Schema(description = "一级分销的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "550")
private Integer firstBrokeragePrice;
/**
*
*/
@Schema(description = "二级分销的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "250")
private Integer secondBrokeragePrice;
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.product.api.sku.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -7,40 +8,26 @@ import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* SKU Request DTO
*
* @author LeeYan9
* @since 2022-08-26
*/
@Schema(description = "RPC 服务 - 商品 SKU 更新库存 Request DTO")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProductSkuUpdateStockReqDTO {
/**
* SKU
*/
@Schema(description = "商品 SKU 数组", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "商品 SKU 不能为空")
private List<Item> items;
@Data
public static class Item {
/**
* SKU
*/
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "商品 SKU 编号不能为空")
private Long id;
/**
*
*
*
*
*/
@Schema(description = "库存变化数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
@NotNull(message = "库存变化数量不能为空")
private Integer incrCount;
private Integer incrCount; // 正数:增加库存;负数:扣减库存
}

View File

@ -1,43 +1,37 @@
package cn.iocoder.yudao.module.product.api.spu;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
import cn.iocoder.yudao.module.product.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
import java.util.List;
/**
* SPU API
*
* @author LeeYan9
* @since 2022-08-26
*/
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 商品 SPU")
public interface ProductSpuApi {
/**
* SPU
*
* @param ids SPU
* @return SPU
*/
List<ProductSpuRespDTO> getSpuList(Collection<Long> ids);
String PREFIX = ApiConstants.PREFIX + "/spu";
/**
* SPU SPU
*
*
* 1.
* 2.
*
* @param ids SPU
* @return SPU
*/
List<ProductSpuRespDTO> validateSpuList(Collection<Long> ids);
@GetMapping(PREFIX + "/list")
@Schema(description = "批量查询 SPU 数组")
@Parameter(name = "ids", description = "SPU 编号列表", required = true, example = "1,3,5")
CommonResult<List<ProductSpuRespDTO>> getSpuList(@RequestParam("ids") Collection<Long> ids);
/**
* SPU
*
* @return SPU
*/
ProductSpuRespDTO getSpu(Long id);
@GetMapping(PREFIX + "/valid")
@Schema(description = "批量查询 SPU 数组,并且校验是否 SPU 是否有效")
@Parameter(name = "ids", description = "SPU 编号列表", required = true, example = "1,3,5")
CommonResult<List<ProductSpuRespDTO>> validateSpuList(@RequestParam("ids") Collection<Long> ids);
@GetMapping(PREFIX + "/get")
@Schema(description = "获得 SPU")
@Parameter(name = "id", description = "SPU 编号", required = true, example = "1")
CommonResult<ProductSpuRespDTO> getSpu(@RequestParam("id") Long id);
}

View File

@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.product.api.spu.dto;
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
import lombok.Data;
import java.util.List;
// TODO @LeeYan9: ProductSpuRespDTO
/**
* SPU Response DTO
@ -25,55 +25,22 @@ public class ProductSpuRespDTO {
*
*/
private String name;
/**
*
*/
private String keyword;
/**
*
*
* product_unit
*/
private Integer unit;
/**
*
*/
private String introduction;
/**
*
*/
private String description;
// TODO @芋艿:是不是要删除
/**
*
*/
private String barCode;
/**
*
*/
private Long categoryId;
/**
*
*/
private Long brandId;
/**
*
*/
private String picUrl;
/**
*
*/
private List<String> sliderPicUrls;
/**
*
*/
private String videoUrl;
/**
*
*/
private Integer sort;
/**
*
* <p>
@ -123,22 +90,6 @@ public class ProductSpuRespDTO {
*/
private Integer giveIntegral;
// ========== 统计相关字段 =========
/**
*
*/
private Integer salesCount;
/**
*
*/
private Integer virtualSalesCount;
/**
*
*/
private Integer clickCount;
// ========== 分销相关字段 =========
/**

View File

@ -1,38 +0,0 @@
package cn.iocoder.yudao.module.product.enums.group;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
*
*
* @author
*/
@Getter
@AllArgsConstructor
public enum ProductGroupStyleEnum implements IntArrayValuable {
ONE(1, "每列一个"),
TWO(2, "每列两个"),
THREE(2, "每列三个"),;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductGroupStyleEnum::getStyle).toArray();
/**
*
*/
private final Integer style;
/**
*
*/
private final String name;
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.product.api.category;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -7,6 +8,8 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* API
*
@ -20,8 +23,9 @@ public class ProductCategoryApiImpl implements ProductCategoryApi {
private ProductCategoryService productCategoryService;
@Override
public void validateCategoryList(Collection<Long> ids) {
public CommonResult<Boolean> validateCategoryList(Collection<Long> ids) {
productCategoryService.validateCategoryList(ids);
return success(true);
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.product.api.comment;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
import cn.iocoder.yudao.module.product.service.comment.ProductCommentService;
import org.springframework.stereotype.Service;
@ -7,6 +8,8 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* API
*
@ -20,8 +23,8 @@ public class ProductCommentApiImpl implements ProductCommentApi {
private ProductCommentService productCommentService;
@Override
public Long createComment(ProductCommentCreateReqDTO createReqDTO) {
return productCommentService.createComment(createReqDTO);
public CommonResult<Long> createComment(ProductCommentCreateReqDTO createReqDTO) {
return success(productCommentService.createComment(createReqDTO));
}
}

View File

@ -1,31 +0,0 @@
package cn.iocoder.yudao.module.product.api.property;
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
/**
* API
*
* @author
*/
@Service
@Validated
public class ProductPropertyValueApiImpl implements ProductPropertyValueApi {
@Resource
private ProductPropertyValueService productPropertyValueService;
@Override
public List<ProductPropertyValueDetailRespDTO> getPropertyValueDetailList(Collection<Long> ids) {
return ProductPropertyValueConvert.INSTANCE.convertList02(
productPropertyValueService.getPropertyValueDetailList(ids));
}
}

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.product.api.sku;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
@ -11,9 +11,10 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* SKU API
*
@ -28,32 +29,27 @@ public class ProductSkuApiImpl implements ProductSkuApi {
private ProductSkuService productSkuService;
@Override
public ProductSkuRespDTO getSku(Long id) {
public CommonResult<ProductSkuRespDTO> getSku(Long id) {
ProductSkuDO sku = productSkuService.getSku(id);
return ProductSkuConvert.INSTANCE.convert02(sku);
return success(ProductSkuConvert.INSTANCE.convert02(sku));
}
@Override
public List<ProductSkuRespDTO> getSkuList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
public CommonResult<List<ProductSkuRespDTO>> getSkuList(Collection<Long> ids) {
List<ProductSkuDO> skus = productSkuService.getSkuList(ids);
return ProductSkuConvert.INSTANCE.convertList04(skus);
return success(ProductSkuConvert.INSTANCE.convertList04(skus));
}
@Override
public List<ProductSkuRespDTO> getSkuListBySpuId(Collection<Long> spuIds) {
if (CollUtil.isEmpty(spuIds)) {
return Collections.emptyList();
}
public CommonResult<List<ProductSkuRespDTO>> getSkuListBySpuId(Collection<Long> spuIds) {
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spuIds);
return ProductSkuConvert.INSTANCE.convertList04(skus);
return success(ProductSkuConvert.INSTANCE.convertList04(skus));
}
@Override
public void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO) {
public CommonResult<Boolean> updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO) {
productSkuService.updateSkuStock(updateStockReqDTO);
return success(true);
}
}

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.product.api.spu;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
@ -9,9 +9,10 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* SPU API
*
@ -26,21 +27,18 @@ public class ProductSpuApiImpl implements ProductSpuApi {
private ProductSpuService spuService;
@Override
public List<ProductSpuRespDTO> getSpuList(Collection<Long> ids) {
if (CollectionUtil.isEmpty(ids)) {
return Collections.emptyList();
}
return ProductSpuConvert.INSTANCE.convertList2(spuService.getSpuList(ids));
public CommonResult<List<ProductSpuRespDTO>> getSpuList(Collection<Long> ids) {
return success(ProductSpuConvert.INSTANCE.convertList2(spuService.getSpuList(ids)));
}
@Override
public List<ProductSpuRespDTO> validateSpuList(Collection<Long> ids) {
return ProductSpuConvert.INSTANCE.convertList2(spuService.validateSpuList(ids));
public CommonResult<List<ProductSpuRespDTO>> validateSpuList(Collection<Long> ids) {
return success(ProductSpuConvert.INSTANCE.convertList2(spuService.validateSpuList(ids)));
}
@Override
public ProductSpuRespDTO getSpu(Long id) {
return ProductSpuConvert.INSTANCE.convert02(spuService.getSpu(id));
public CommonResult<ProductSpuRespDTO> getSpu(Long id) {
return success(ProductSpuConvert.INSTANCE.convert02(spuService.getSpu(id)));
}
}

View File

@ -1,22 +1,14 @@
package cn.iocoder.yudao.module.product.convert.property;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
/**
* Convert
@ -38,18 +30,4 @@ public interface ProductPropertyValueConvert {
PageResult<ProductPropertyValueRespVO> convertPage(PageResult<ProductPropertyValueDO> page);
default List<ProductPropertyValueDetailRespBO> convertList(List<ProductPropertyValueDO> values, List<ProductPropertyDO> keys) {
Map<Long, ProductPropertyDO> keyMap = convertMap(keys, ProductPropertyDO::getId);
return CollectionUtils.convertList(values, value -> {
ProductPropertyValueDetailRespBO valueDetail = new ProductPropertyValueDetailRespBO()
.setValueId(value.getId()).setValueName(value.getName());
// 设置属性项
MapUtils.findAndThen(keyMap, value.getPropertyId(),
key -> valueDetail.setPropertyId(key.getId()).setPropertyName(key.getName()));
return valueDetail;
});
}
List<ProductPropertyValueDetailRespDTO> convertList02(List<ProductPropertyValueDetailRespBO> list);
}

View File

@ -5,7 +5,6 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.Produc
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO;
import java.util.Collection;
import java.util.List;
@ -56,14 +55,6 @@ public interface ProductPropertyValueService {
*/
List<ProductPropertyValueDO> getPropertyValueListByPropertyId(Collection<Long> propertyIds);
/**
*
*
* @param ids
* @return
*/
List<ProductPropertyValueDetailRespBO> getPropertyValueDetailList(Collection<Long> ids);
/**
*
*

View File

@ -1,15 +1,12 @@
package cn.iocoder.yudao.module.product.service.property;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper;
import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -17,11 +14,9 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_NOT_EXISTS;
@ -37,10 +32,6 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
@Resource
private ProductPropertyValueMapper productPropertyValueMapper;
@Resource
@Lazy // 延迟加载,避免循环依赖
private ProductPropertyService productPropertyService;
@Resource
@Lazy // 延迟加载,避免循环依赖
private ProductSkuService productSkuService;
@ -99,23 +90,6 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
return productPropertyValueMapper.selectListByPropertyId(propertyIds);
}
@Override
public List<ProductPropertyValueDetailRespBO> getPropertyValueDetailList(Collection<Long> ids) {
// 获得属性值列表
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
List<ProductPropertyValueDO> values = productPropertyValueMapper.selectBatchIds(ids);
if (CollUtil.isEmpty(values)) {
return Collections.emptyList();
}
// 获得属性项列表
List<ProductPropertyDO> keys = productPropertyService.getPropertyList(
convertSet(values, ProductPropertyValueDO::getPropertyId));
// 组装明细
return ProductPropertyValueConvert.INSTANCE.convertList(values, keys);
}
@Override
public Integer getPropertyValueCountByPropertyId(Long propertyId) {
return productPropertyValueMapper.selectCountByPropertyId(propertyId);

View File

@ -1,33 +0,0 @@
package cn.iocoder.yudao.module.product.service.property.bo;
import lombok.Data;
/**
* Response BO
*
* @author
*/
@Data
public class ProductPropertyValueDetailRespBO {
/**
*
*/
private Long propertyId;
/**
*
*/
private String propertyName;
/**
*
*/
private Long valueId;
/**
*
*/
private String valueName;
}

View File

@ -153,6 +153,9 @@ public class ProductSkuServiceImpl implements ProductSkuService {
@Override
public List<ProductSkuDO> getSkuListBySpuId(Collection<Long> spuIds) {
if (CollUtil.isEmpty(spuIds)) {
return Collections.emptyList();
}
return productSkuMapper.selectListBySpuId(spuIds);
}

View File

@ -213,6 +213,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
@Override
public List<ProductSpuDO> getSpuList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
return productSpuMapper.selectBatchIds(ids);
}