feat(pricing): 添加商品分类枚举并扩展商品类型枚举

- 新增 ProductCategory 枚举类,定义商品分类
- 为 ProductType 枚举增加分类关联字段
- 扩展 ProductType 枚举值并按分类分组注释
- 添加获取分类代码和描述的方法
- 实现根据代码查找枚举的静态方法
- 完善枚举类的文档注释和类型安全引用
This commit is contained in:
2025-11-27 18:39:43 +08:00
parent 8a88c74df2
commit e9a59cd466
2 changed files with 68 additions and 12 deletions

View File

@@ -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);
}
}

View File

@@ -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();
}
}