package enumeration.general; import lombok.Getter; /** * 区域枚举 */ @Getter public enum AreaDeptEnum { ZLJQ("自流井", "510302", 201), GJQ("贡井", "510303", 202), DAQ("大安", "510304", 102), YTQ("沿滩", "510311", 211), RX("荣县", "510321", 203), FSX("富顺", "510322", 101), GXQ("高新", "510399", 210), ; private final String name; private final String code; private final Integer deptId; AreaDeptEnum(String name, String code, Integer deptId) { this.name = name; this.code = code; this.deptId = deptId; } public static AreaDeptEnum fromCode(String code) { for (AreaDeptEnum type : AreaDeptEnum.values()) { if (type.getCode().equals(code) ) { return type; } } return null; } public static AreaDeptEnum fromDept(Integer deptId) { for (AreaDeptEnum type : AreaDeptEnum.values()) { if (type.getDeptId().equals(deptId) ) { return type; } } return null; } }