product:完善 rpc api 的注解

This commit is contained in:
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;
}
}