From e9a59cd4669c5aa9faf4fcd3b6c856b352340ea5 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 27 Nov 2025 18:39:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(pricing):=20=E6=B7=BB=E5=8A=A0=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=86=E7=B1=BB=E6=9E=9A=E4=B8=BE=E5=B9=B6=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E5=95=86=E5=93=81=E7=B1=BB=E5=9E=8B=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 ProductCategory 枚举类,定义商品分类 - 为 ProductType 枚举增加分类关联字段 - 扩展 ProductType 枚举值并按分类分组注释 - 添加获取分类代码和描述的方法 - 实现根据代码查找枚举的静态方法 - 完善枚举类的文档注释和类型安全引用 --- .../basic/pricing/enums/ProductCategory.java | 33 +++++++++++++ .../ycwl/basic/pricing/enums/ProductType.java | 47 ++++++++++++++----- 2 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/ycwl/basic/pricing/enums/ProductCategory.java diff --git a/src/main/java/com/ycwl/basic/pricing/enums/ProductCategory.java b/src/main/java/com/ycwl/basic/pricing/enums/ProductCategory.java new file mode 100644 index 00000000..f9aa75a3 --- /dev/null +++ b/src/main/java/com/ycwl/basic/pricing/enums/ProductCategory.java @@ -0,0 +1,33 @@ +package com.ycwl.basic.pricing.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 商品分类枚举 + */ +@Getter +@AllArgsConstructor +public enum ProductCategory { + + VLOG("VLOG", "Vlog类"), + PHOTO("PHOTO", "照片类"), + VIDEO("VIDEO", "视频类"), + PRINT("PRINT", "打印类"), + OTHER("OTHER", "其他"); + + private final String code; + private final String description; + + /** + * 根据代码获取枚举 + */ + public static ProductCategory fromCode(String code) { + for (ProductCategory category : values()) { + if (category.code.equals(code)) { + return category; + } + } + throw new IllegalArgumentException("Unknown product category code: " + code); + } +} diff --git a/src/main/java/com/ycwl/basic/pricing/enums/ProductType.java b/src/main/java/com/ycwl/basic/pricing/enums/ProductType.java index e5021261..d2cab829 100644 --- a/src/main/java/com/ycwl/basic/pricing/enums/ProductType.java +++ b/src/main/java/com/ycwl/basic/pricing/enums/ProductType.java @@ -9,20 +9,29 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum ProductType { - - VLOG_VIDEO("VLOG_VIDEO", "Vlog视频"), - RECORDING_SET("RECORDING_SET", "录像集"), - PHOTO_SET("PHOTO_SET", "照相集"), - PHOTO_LOG("PHOTO_LOG", "pLog图"), - PHOTO_VLOG("PHOTO_VLOG", "pLog视频"), - PHOTO_PRINT("PHOTO_PRINT", "照片打印"), - PHOTO_PRINT_MU("PHOTO_PRINT_MU", "手机照片打印"), - PHOTO_PRINT_FX("PHOTO_PRINT_FX", "特效照片打印"), - MACHINE_PRINT("MACHINE_PRINT", "一体机打印"); - + + // VLOG类 + VLOG_VIDEO("VLOG_VIDEO", "Vlog视频", ProductCategory.VLOG), + PHOTO_VLOG("PHOTO_VLOG", "pLog视频", ProductCategory.VLOG), + + // 照片类 + PHOTO("PHOTO", "照片", ProductCategory.PHOTO), + PHOTO_SET("PHOTO_SET", "照片集", ProductCategory.PHOTO), + PHOTO_LOG("PHOTO_LOG", "pLog图", ProductCategory.PHOTO), + + // 视频类(素材视频) + RECORDING_SET("RECORDING_SET", "录像集", ProductCategory.VIDEO), + + // 其他类(打印类等) + PHOTO_PRINT("PHOTO_PRINT", "照片打印", ProductCategory.PRINT), + PHOTO_PRINT_MU("PHOTO_PRINT_MU", "手机照片打印", ProductCategory.PRINT), + PHOTO_PRINT_FX("PHOTO_PRINT_FX", "特效照片打印", ProductCategory.PRINT), + MACHINE_PRINT("MACHINE_PRINT", "一体机打印", ProductCategory.PRINT); + private final String code; private final String description; - + private final ProductCategory category; + /** * 根据代码获取枚举 */ @@ -34,4 +43,18 @@ public enum ProductType { } throw new IllegalArgumentException("Unknown product type code: " + code); } + + /** + * 获取分类代码 + */ + public String getCategoryCode() { + return category.getCode(); + } + + /** + * 获取分类描述 + */ + public String getCategoryDescription() { + return category.getDescription(); + } } \ No newline at end of file