mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	适配 mall 模块的 openapi
This commit is contained in:
		
							
								
								
									
										34
									
								
								yudao-module-mall/yudao-module-product-api/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								yudao-module-mall/yudao-module-product-api/pom.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||||
|          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||
|     <modelVersion>4.0.0</modelVersion> | ||||
|     <parent> | ||||
|         <groupId>cn.iocoder.boot</groupId> | ||||
|         <artifactId>yudao-module-mall</artifactId> | ||||
|         <version>${revision}</version> | ||||
|     </parent> | ||||
|  | ||||
|     <artifactId>yudao-module-product-api</artifactId> | ||||
|     <packaging>jar</packaging> | ||||
|  | ||||
|     <name>${project.artifactId}</name> | ||||
|     <description> | ||||
|         product 模块 API,暴露给其它模块调用 | ||||
|     </description> | ||||
|  | ||||
|     <dependencies> | ||||
|         <dependency> | ||||
|             <groupId>cn.iocoder.boot</groupId> | ||||
|             <artifactId>yudao-common</artifactId> | ||||
|         </dependency> | ||||
|  | ||||
|         <!-- 参数校验 --> | ||||
|         <dependency> | ||||
|             <groupId>org.springframework.boot</groupId> | ||||
|             <artifactId>spring-boot-starter-validation</artifactId> | ||||
|             <optional>true</optional> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
|  | ||||
| </project> | ||||
| @@ -0,0 +1,4 @@ | ||||
| /** | ||||
|  * 占位 | ||||
|  */ | ||||
| package cn.iocoder.yudao.module.product.api; | ||||
| @@ -0,0 +1,23 @@ | ||||
| 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); | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,33 @@ | ||||
| package cn.iocoder.yudao.module.product.api.property.dto; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| /** | ||||
|  * 商品属性项的明细 Response DTO | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Data | ||||
| public class ProductPropertyValueDetailRespDTO { | ||||
|  | ||||
|     /** | ||||
|      * 属性的编号 | ||||
|      */ | ||||
|     private Long propertyId; | ||||
|  | ||||
|     /** | ||||
|      * 属性的名称 | ||||
|      */ | ||||
|     private String propertyName; | ||||
|  | ||||
|     /** | ||||
|      * 属性值的编号 | ||||
|      */ | ||||
|     private Long valueId; | ||||
|  | ||||
|     /** | ||||
|      * 属性值的名称 | ||||
|      */ | ||||
|     private String valueName; | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,40 @@ | ||||
| package cn.iocoder.yudao.module.product.api.sku; | ||||
|  | ||||
| import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; | ||||
| import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 商品 SKU API 接口 | ||||
|  * | ||||
|  * @author LeeYan9 | ||||
|  * @since 2022-08-26 | ||||
|  */ | ||||
| public interface ProductSkuApi { | ||||
|  | ||||
|     /** | ||||
|      * 查询 SKU 信息 | ||||
|      * | ||||
|      * @param id SKU 编号 | ||||
|      * @return SKU 信息 | ||||
|      */ | ||||
|     ProductSkuRespDTO getSku(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 批量查询 SKU 数组 | ||||
|      * | ||||
|      * @param ids SKU 编号列表 | ||||
|      * @return SKU 数组 | ||||
|      */ | ||||
|     List<ProductSkuRespDTO> getSkuList(Collection<Long> ids); | ||||
|  | ||||
|     /** | ||||
|      * 更新 SKU 库存 | ||||
|      * | ||||
|      * @param updateStockReqDTO 更新请求 | ||||
|      */ | ||||
|     void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO); | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,95 @@ | ||||
| package cn.iocoder.yudao.module.product.api.sku.dto; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 商品 SKU 信息 Response DTO | ||||
|  * | ||||
|  * @author LeeYan9 | ||||
|  * @since 2022-08-26 | ||||
|  */ | ||||
| @Data | ||||
| public class ProductSkuRespDTO { | ||||
|  | ||||
|     /** | ||||
|      * 商品 SKU 编号,自增 | ||||
|      */ | ||||
|     private Long id; | ||||
|     /** | ||||
|      * SPU 编号 | ||||
|      */ | ||||
|     private Long spuId; | ||||
|     /** | ||||
|      * SPU 名字 | ||||
|      */ | ||||
|     private String spuName; | ||||
|  | ||||
|     /** | ||||
|      * 属性数组,JSON 格式 | ||||
|      */ | ||||
|     private List<Property> properties; | ||||
|     /** | ||||
|      * 销售价格,单位:分 | ||||
|      */ | ||||
|     private Integer price; | ||||
|     /** | ||||
|      * 市场价,单位:分 | ||||
|      */ | ||||
|     private Integer marketPrice; | ||||
|     /** | ||||
|      * 成本价,单位:分 | ||||
|      */ | ||||
|     private Integer costPrice; | ||||
|     /** | ||||
|      * SKU 的条形码 | ||||
|      */ | ||||
|     private String barCode; | ||||
|     /** | ||||
|      * 图片地址 | ||||
|      */ | ||||
|     private String picUrl; | ||||
|     /** | ||||
|      * SKU 状态 | ||||
|      * <p> | ||||
|      * 枚举 {@link CommonStatusEnum} | ||||
|      */ | ||||
|     private Integer status; | ||||
|     /** | ||||
|      * 库存 | ||||
|      */ | ||||
|     private Integer stock; | ||||
|     /** | ||||
|      * 预警预存 | ||||
|      */ | ||||
|     private Integer warnStock; | ||||
|     /** | ||||
|      * 商品重量,单位:kg 千克 | ||||
|      */ | ||||
|     private Double weight; | ||||
|     /** | ||||
|      * 商品体积,单位:m^3 平米 | ||||
|      */ | ||||
|     private Double volume; | ||||
|  | ||||
|     /** | ||||
|      * 商品属性 | ||||
|      */ | ||||
|     @Data | ||||
|     public static class Property { | ||||
|  | ||||
|         /** | ||||
|          * 属性编号 | ||||
|          */ | ||||
|         private Long propertyId; | ||||
|         /** | ||||
|          * 属性值编号 | ||||
|          */ | ||||
|         private Long valueId; | ||||
|  | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,47 @@ | ||||
| package cn.iocoder.yudao.module.product.api.sku.dto; | ||||
|  | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Data; | ||||
| import lombok.NoArgsConstructor; | ||||
|  | ||||
| import javax.validation.constraints.NotNull; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 商品 SKU 更新库存 Request DTO | ||||
|  * | ||||
|  * @author LeeYan9 | ||||
|  * @since 2022-08-26 | ||||
|  */ | ||||
| @Data | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class ProductSkuUpdateStockReqDTO { | ||||
|  | ||||
|     /** | ||||
|      * 商品 SKU | ||||
|      */ | ||||
|     @NotNull(message = "商品 SKU 不能为空") | ||||
|     private List<Item> items; | ||||
|  | ||||
|     @Data | ||||
|     public static class Item { | ||||
|  | ||||
|         /** | ||||
|          * 商品 SKU 编号 | ||||
|          */ | ||||
|         @NotNull(message = "商品 SKU 编号不能为空") | ||||
|         private Long id; | ||||
|  | ||||
|         /** | ||||
|          * 库存变化数量 | ||||
|          * | ||||
|          * 正数:增加库存 | ||||
|          * 负数:扣减库存 | ||||
|          */ | ||||
|         @NotNull(message = "库存变化数量不能为空") | ||||
|         private Integer incrCount; | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,24 @@ | ||||
| package cn.iocoder.yudao.module.product.api.spu; | ||||
|  | ||||
| import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 商品 SPU API 接口 | ||||
|  * | ||||
|  * @author LeeYan9 | ||||
|  * @since 2022-08-26 | ||||
|  */ | ||||
| public interface ProductSpuApi { | ||||
|  | ||||
|     /** | ||||
|      * 批量查询 SPU 数组 | ||||
|      * | ||||
|      * @param ids SPU 编号列表 | ||||
|      * @return SPU 数组 | ||||
|      */ | ||||
|     List<ProductSpuRespDTO> getSpuList(Collection<Long> ids); | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,127 @@ | ||||
| package cn.iocoder.yudao.module.product.api.spu.dto; | ||||
|  | ||||
| import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | ||||
| import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum; | ||||
| import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| // TODO @LeeYan9: ProductSpuRespDTO | ||||
| /** | ||||
|  * 商品 SPU 信息 Response DTO | ||||
|  * | ||||
|  * @author LeeYan9 | ||||
|  * @since 2022-08-26 | ||||
|  */ | ||||
| @Data | ||||
| public class ProductSpuRespDTO { | ||||
|  | ||||
|     /** | ||||
|      * 商品 SPU 编号,自增 | ||||
|      */ | ||||
|     private Long id; | ||||
|  | ||||
|     // ========== 基本信息 ========= | ||||
|  | ||||
|     /** | ||||
|      * 商品名称 | ||||
|      */ | ||||
|     private String name; | ||||
|     /** | ||||
|      * 商品编码 | ||||
|      */ | ||||
|     private String code; | ||||
|     /** | ||||
|      * 促销语 | ||||
|      */ | ||||
|     private String sellPoint; | ||||
|     /** | ||||
|      * 商品详情 | ||||
|      */ | ||||
|     private String description; | ||||
|     /** | ||||
|      * 商品分类编号 | ||||
|      */ | ||||
|     private Long categoryId; | ||||
|     /** | ||||
|      * 商品品牌编号 | ||||
|      */ | ||||
|     private Long brandId; | ||||
|     /** | ||||
|      * 商品图片的数组 | ||||
|      * <p> | ||||
|      * 1. 第一张图片将作为商品主图,支持同时上传多张图; | ||||
|      * 2. 建议使用尺寸 800x800 像素以上、大小不超过 1M 的正方形图片; | ||||
|      * 3. 至少 1 张,最多上传 10 张 | ||||
|      */ | ||||
|     private List<String> picUrls; | ||||
|     /** | ||||
|      * 商品视频 | ||||
|      */ | ||||
|     private String videoUrl; | ||||
|  | ||||
|     /** | ||||
|      * 排序字段 | ||||
|      */ | ||||
|     private Integer sort; | ||||
|     /** | ||||
|      * 商品状态 | ||||
|      * <p> | ||||
|      * 枚举 {@link ProductSpuStatusEnum} | ||||
|      */ | ||||
|     private Integer status; | ||||
|  | ||||
|     // ========== SKU 相关字段 ========= | ||||
|  | ||||
|     /** | ||||
|      * 规格类型 | ||||
|      * <p> | ||||
|      * 枚举 {@link ProductSpuSpecTypeEnum} | ||||
|      */ | ||||
|     private Integer specType; | ||||
|     /** | ||||
|      * 最小价格,单位使用:分 | ||||
|      * <p> | ||||
|      * 基于其对应的 {@link ProductSkuRespDTO#getPrice()} 最小值 | ||||
|      */ | ||||
|     private Integer minPrice; | ||||
|     /** | ||||
|      * 最大价格,单位使用:分 | ||||
|      * <p> | ||||
|      * 基于其对应的 {@link ProductSkuRespDTO#getPrice()} 最大值 | ||||
|      */ | ||||
|     private Integer maxPrice; | ||||
|     /** | ||||
|      * 市场价,单位使用:分 | ||||
|      * <p> | ||||
|      * 基于其对应的 {@link ProductSkuRespDTO#getMarketPrice()} 最大值 | ||||
|      */ | ||||
|     private Integer marketPrice; | ||||
|     /** | ||||
|      * 总库存 | ||||
|      * <p> | ||||
|      * 基于其对应的 {@link ProductSkuRespDTO#getStock()} 求和 | ||||
|      */ | ||||
|     private Integer totalStock; | ||||
|     /** | ||||
|      * 是否展示库存 | ||||
|      */ | ||||
|     private Boolean showStock; | ||||
|  | ||||
|     // ========== 统计相关字段 ========= | ||||
|  | ||||
|     /** | ||||
|      * 商品销量 | ||||
|      */ | ||||
|     private Integer salesCount; | ||||
|     /** | ||||
|      * 虚拟销量 | ||||
|      */ | ||||
|     private Integer virtualSalesCount; | ||||
|     /** | ||||
|      * 商品点击量 | ||||
|      */ | ||||
|     private Integer clickCount; | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,45 @@ | ||||
| package cn.iocoder.yudao.module.product.enums; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.exception.ErrorCode; | ||||
|  | ||||
| /** | ||||
|  * Product 错误码枚举类 | ||||
|  * | ||||
|  * product 系统,使用 1-008-000-000 段 | ||||
|  */ | ||||
| public interface ErrorCodeConstants { | ||||
|  | ||||
|     // ========== 商品分类相关 1008001000 ============ | ||||
|     ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(1008001000, "商品分类不存在"); | ||||
|     ErrorCode CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1008001001, "父分类不存在"); | ||||
|     ErrorCode CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1008001002, "父分类不能是二级分类"); | ||||
|     ErrorCode CATEGORY_EXISTS_CHILDREN = new ErrorCode(1008001003, "存在子分类,无法删除"); | ||||
|     ErrorCode CATEGORY_DISABLED = new ErrorCode(1008001004, "商品分类({})已禁用,无法使用"); | ||||
|  | ||||
|     // ========== 商品品牌相关编号 1008002000 ========== | ||||
|     ErrorCode BRAND_NOT_EXISTS = new ErrorCode(1008002000, "品牌不存在"); | ||||
|     ErrorCode BRAND_DISABLED = new ErrorCode(1008002001, "品牌不存在"); | ||||
|     ErrorCode BRAND_NAME_EXISTS = new ErrorCode(1008002002, "品牌名称已存在"); | ||||
|  | ||||
|     // ========== 商品属性项 1008003000 ========== | ||||
|     ErrorCode PROPERTY_NOT_EXISTS = new ErrorCode(1008003000, "属性项不存在"); | ||||
|     ErrorCode PROPERTY_EXISTS = new ErrorCode(1008003001, "属性项的名称已存在"); | ||||
|     ErrorCode PROPERTY_DELETE_FAIL_VALUE_EXISTS = new ErrorCode(1008003002, "属性项下存在属性值,无法删除"); | ||||
|  | ||||
|     // ========== 商品属性值 1008004000 ========== | ||||
|     ErrorCode PROPERTY_VALUE_NOT_EXISTS = new ErrorCode(1008004000, "属性值不存在"); | ||||
|     ErrorCode PROPERTY_VALUE_EXISTS = new ErrorCode(1008004001, "属性值的名称已存在"); | ||||
|  | ||||
|     // ========== 商品 SPU 1008005000 ========== | ||||
|     ErrorCode SPU_NOT_EXISTS = new ErrorCode(1008005000, "商品 SPU 不存在"); | ||||
|     ErrorCode SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR = new ErrorCode(1008005001, "商品分类不正确,原因:必须使用第三级的商品分类下"); | ||||
|     ErrorCode SPU_NOT_ENABLE = new ErrorCode(1008005002, "商品 SPU 不处于上架状态"); | ||||
|  | ||||
|     // ========== 商品 SKU 1008006000 ========== | ||||
|     ErrorCode SKU_NOT_EXISTS = new ErrorCode(1008006000, "商品 SKU 不存在"); | ||||
|     ErrorCode SKU_PROPERTIES_DUPLICATED = new ErrorCode(1008006001, "商品 SKU 的属性组合存在重复"); | ||||
|     ErrorCode SPU_ATTR_NUMBERS_MUST_BE_EQUALS = new ErrorCode(1008006002, "一个 SPU 下的每个 SKU,其属性项必须一致"); | ||||
|     ErrorCode SPU_SKU_NOT_DUPLICATE = new ErrorCode(1008006003, "一个 SPU 下的每个 SKU,必须不重复"); | ||||
|     ErrorCode SKU_STOCK_NOT_ENOUGH = new ErrorCode(1008006004, "商品 SKU 库存不足"); | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,38 @@ | ||||
| package cn.iocoder.yudao.module.product.enums.comment; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Getter; | ||||
|  | ||||
| import java.util.Arrays; | ||||
|  | ||||
| /** | ||||
|  * 商品评论的审批状态枚举 | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Getter | ||||
| @AllArgsConstructor | ||||
| public enum ProductCommentAuditStatusEnum implements IntArrayValuable { | ||||
|  | ||||
|     NONE(1, "待审核"), | ||||
|     APPROVE(2, "审批通过"), | ||||
|     REJECT(2, "审批不通过"),; | ||||
|  | ||||
|     public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentAuditStatusEnum::getStatus).toArray(); | ||||
|  | ||||
|     /** | ||||
|      * 审批状态 | ||||
|      */ | ||||
|     private final Integer status; | ||||
|     /** | ||||
|      * 状态名 | ||||
|      */ | ||||
|     private final String name; | ||||
|  | ||||
|     @Override | ||||
|     public int[] array() { | ||||
|         return ARRAYS; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,38 @@ | ||||
| package cn.iocoder.yudao.module.product.enums.delivery; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Getter; | ||||
|  | ||||
| import java.util.Arrays; | ||||
|  | ||||
| /** | ||||
|  * 配送方式枚举 | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Getter | ||||
| @AllArgsConstructor | ||||
| public enum DeliveryTypeEnum implements IntArrayValuable { | ||||
|  | ||||
|     // TODO 芋艿:英文单词,需要再想下; | ||||
|     EXPRESS(1, "快递发货"), | ||||
|     USER(2, "用户自提"),; | ||||
|  | ||||
|     public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryTypeEnum::getMode).toArray(); | ||||
|  | ||||
|     /** | ||||
|      * 配送方式 | ||||
|      */ | ||||
|     private final Integer mode; | ||||
|     /** | ||||
|      * 状态名 | ||||
|      */ | ||||
|     private final String name; | ||||
|  | ||||
|     @Override | ||||
|     public int[] array() { | ||||
|         return ARRAYS; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,38 @@ | ||||
| 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; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,37 @@ | ||||
| package cn.iocoder.yudao.module.product.enums.spu; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Getter; | ||||
|  | ||||
| import java.util.Arrays; | ||||
|  | ||||
| /** | ||||
|  * 商品 SPU 规格类型 | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Getter | ||||
| @AllArgsConstructor | ||||
| public enum ProductSpuSpecTypeEnum implements IntArrayValuable { | ||||
|  | ||||
|     RECYCLE(1, "统一规格"), | ||||
|     DISABLE(2, "多规格"); | ||||
|  | ||||
|     public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSpuSpecTypeEnum::getType).toArray(); | ||||
|  | ||||
|     /** | ||||
|      * 规格类型 | ||||
|      */ | ||||
|     private final Integer type; | ||||
|     /** | ||||
|      * 规格名称 | ||||
|      */ | ||||
|     private final String name; | ||||
|  | ||||
|     @Override | ||||
|     public int[] array() { | ||||
|         return ARRAYS; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,48 @@ | ||||
| package cn.iocoder.yudao.module.product.enums.spu; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Getter; | ||||
|  | ||||
| import java.util.Arrays; | ||||
|  | ||||
| /** | ||||
|  * 商品 SPU 状态 | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Getter | ||||
| @AllArgsConstructor | ||||
| public enum ProductSpuStatusEnum implements IntArrayValuable { | ||||
|  | ||||
|     RECYCLE(-1, "回收站"), | ||||
|     DISABLE(0, "下架"), | ||||
|     ENABLE(1, "上架"),; | ||||
|  | ||||
|     public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSpuStatusEnum::getStatus).toArray(); | ||||
|  | ||||
|     /** | ||||
|      * 状态 | ||||
|      */ | ||||
|     private final Integer status; | ||||
|     /** | ||||
|      * 状态名 | ||||
|      */ | ||||
|     private final String name; | ||||
|  | ||||
|     @Override | ||||
|     public int[] array() { | ||||
|         return ARRAYS; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 判断是否处于【上架】状态 | ||||
|      * | ||||
|      * @param status 状态 | ||||
|      * @return 是否处于【上架】状态 | ||||
|      */ | ||||
|     public static boolean isEnable(Integer status) { | ||||
|         return ENABLE.getStatus().equals(status); | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV