package com.panzhihua.common.enums; import lombok.Getter; /** * 婚姻状况 * * @author huanghongfa */ @Getter public enum SafeWordDangerLevelEnum { RED(1, "红色预警"), ORANGE(2, "橙色预警"), YELLOW(3, "黄色预警"), BLUE(4, "蓝色预警"); private final Integer code; private final String name; SafeWordDangerLevelEnum(Integer code, String name) { this.code = code; this.name = name; } public static int getCodeByName(String name) { for (SafeWordDangerLevelEnum item : SafeWordDangerLevelEnum.values()) { if (item.name.equals(name)) { return item.getCode(); } } return -1; } public static String getCnDescByName(Integer code) { for (SafeWordDangerLevelEnum item : SafeWordDangerLevelEnum.values()) { if (item.code.equals(code)) { return item.getName(); } } return "其他"; } }