product:完善 rpc api 的注解
parent
df7d49a8b1
commit
ec49751f25
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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; // 正数:增加库存;负数:扣减库存
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
// ========== 分销相关字段 =========
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
/**
|
||||
* 根据属性项编号,活的属性值数量
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue