package com.ruoyi.common.enums; import com.ruoyi.common.interfaces.EnumsInterface; /** * @author wangqiong * @description 短信状态枚举 * @date 2023-11-17 14:05 */ public enum SMSStatusEnum implements EnumsInterface { SUCCESS(1, "成功"), SENDING(2, "发送中"), FAIL(3, "失败"), ; private final Integer code; private final String text; SMSStatusEnum(Integer code, String text) { this.code = code; this.text = text; } public Integer getCode() { return code; } public String getText() { return text; } /** * 根据code获取text * @param codeNo * @return */ public static String getTextByCode(Integer codeNo){ for (SMSStatusEnum value : SMSStatusEnum.values()) { if (value.getCode().equals(codeNo)){ return value.getText(); } } return codeNo.toString(); } /** * 根据text获取code * @param textStr * @return */ public static String getCodeByText(String textStr){ for (SMSStatusEnum value : SMSStatusEnum.values()) { if (value.getText().equals(textStr)){ return value.getText(); } } return textStr; } }