diff --git a/safety-eval-domain/src/main/java/org/qinan/safetyeval/domain/constant/ProjectArchiveFileSourceEnum.java b/safety-eval-domain/src/main/java/org/qinan/safetyeval/domain/constant/ProjectArchiveFileSourceEnum.java new file mode 100644 index 00000000..a3bd2b09 --- /dev/null +++ b/safety-eval-domain/src/main/java/org/qinan/safetyeval/domain/constant/ProjectArchiveFileSourceEnum.java @@ -0,0 +1,61 @@ +package org.qinan.safetyeval.domain.constant; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +/** + * 文件来源枚举 + */ +@Getter +@RequiredArgsConstructor +public enum ProjectArchiveFileSourceEnum { + + /** + * 流程自动记录 + */ + AUTO_PROCESS_RECORD("auto_process_record", "流程自动记录"), + + /** + * 补充上传 + */ + UPLOAD_ADDITIONAL_FILES("upload_additional_files", "补充上传"); + + /** + * 编码,用于数据库存储 + */ + private final String code; + + /** + * 中文描述,用于界面展示 + */ + private final String desc; + + public static final String REMARKS = "文件来源 auto_process_record:流程自动记录, upload_additional_files:补充上传"; + + /** + * 根据编码获取枚举 + */ + public static ProjectArchiveFileSourceEnum fromCode(String code) { + if (code == null || code.isEmpty()) { + return null; + } + for (ProjectArchiveFileSourceEnum type : values()) { + if (type.code.equals(code)) { + return type; + } + } + throw new IllegalArgumentException("未知的文件来源编码: " + code); + } + + /** + * 根据编码获取描述,找不到时返回原编码 + */ + public static String getDescByCode(String code) { + for (ProjectArchiveFileSourceEnum type : values()) { + if (type.code.equals(code)) { + return type.desc; + } + } + return code; + } +}