package cn.iocoder.yudao.module.archive.enums; import cn.hutool.core.util.ArrayUtil; import lombok.AllArgsConstructor; import lombok.Getter; /** * 档案载体类型枚举 * * @author 超级管理员 */ @Getter @AllArgsConstructor public enum ArchiveCarrierTypeEnum { ELECTRONIC(1, "电子"), PHYSICAL(2, "实体"), BOTH(3, "电子+实体"), ; private final Integer type; private final String name; public static ArchiveCarrierTypeEnum valueOf(Integer type) { return ArrayUtil.firstMatch(e -> e.getType().equals(type), values()); } /** 按载体值取中文名,未匹配时回退原始值,便于错误提示可读 */ public static String nameOf(Integer type) { ArchiveCarrierTypeEnum item = valueOf(type); return item != null ? item.getName() : String.valueOf(type); } }