This commit is contained in:
18792927508
2024-01-05 15:34:00 +08:00
parent 464eb8b824
commit 37a72958f1
10 changed files with 414 additions and 136 deletions
@@ -1,11 +1,13 @@
package com.ruoyi.common.enums;
import com.ruoyi.common.interfaces.EnumsInterface;
/**
* @author wangqiong
* @description 是否枚举
* @date 2023-11-17 14:05
*/
public enum YesOrNoEnum
public enum YesOrNoEnum implements EnumsInterface
{
NO(0, "否"),
YES(1, "是"),
@@ -30,4 +32,32 @@ public enum YesOrNoEnum
{
return text;
}
/**
* 根据code获取text
* @param codeNo
* @return
*/
public static String getTextByCode(Integer codeNo){
for (YesOrNoEnum value : YesOrNoEnum.values()) {
if (value.getCode().equals(codeNo)){
return value.getText();
}
}
return codeNo.toString();
}
/**
* 根据text获取code
* @param textStr
* @return
*/
public static String getCodeByText(String textStr){
for (YesOrNoEnum value : YesOrNoEnum.values()) {
if (value.getText().equals(textStr)){
return value.getText();
}
}
return textStr;
}
}