package com.vci.starter.web.enumpck;
|
|
import com.vci.starter.web.annotation.VciEnum;
|
|
/**
|
* 用户密级
|
* @author weidy
|
* @date 2019-07-14
|
*/
|
@VciEnum(name = "usersecurityenum",text = "人员密级",description = "用户,人员的密级")
|
public enum UserSecretEnum implements BaseEnumInt{
|
|
/**
|
* 内部
|
*/
|
NONE(10,"内部"),
|
/**
|
* 一般
|
*/
|
SECRET(20,"一般"),
|
/**
|
* 重要
|
*/
|
PRIVACY(30,"重要");
|
|
/**
|
* 枚举值
|
*/
|
private int value;
|
|
/**
|
* 枚举显示值
|
*/
|
private String text;
|
/**
|
* 获取枚举值
|
* @return 枚举值
|
*/
|
public int getValue() {
|
return value;
|
}
|
|
/**
|
* 设置枚举值
|
* @param value 枚举值
|
*/
|
public void setValue(int value) {
|
this.value = value;
|
}
|
|
/**
|
* 获取显示文本
|
* @return 显示文本
|
*/
|
public String getText() {
|
return text;
|
}
|
|
/**
|
* 设置显示文本
|
* @param text 显示文本
|
*/
|
public void setText(String text) {
|
this.text = text;
|
}
|
|
/**
|
* 枚举内部构造方法
|
* @param secret 枚举值
|
* @param secretText 显示文本
|
*/
|
private UserSecretEnum(int secret, String secretText){
|
this.value = secret;
|
this.text = secretText;
|
}
|
|
/**
|
* 根据枚举的值获取显示文本
|
* @param secret 枚举值
|
* @return 显示文本
|
*/
|
public static String getSecretText(int secret){
|
for(UserSecretEnum eu:UserSecretEnum.values()){
|
if(eu.value == secret){
|
return eu.text;
|
}
|
}
|
return NONE.text;
|
}
|
|
|
/**
|
* 是否有效的密级值
|
* @param secret 密级值
|
* @return 符合范围要求则返回true
|
*/
|
public static boolean isValid(int secret){
|
for(UserSecretEnum eu:UserSecretEnum.values()){
|
if(eu.value == secret){
|
return true;
|
}
|
}
|
return false;
|
}
|
|
/**
|
* 根据枚举显示文本获取枚举值
|
* @param text 显示文本
|
* @return 枚举值
|
*/
|
public static int getSecretValueByText(String text){
|
for(UserSecretEnum eu:UserSecretEnum.values()){
|
if(eu.text.equalsIgnoreCase(text)){
|
return eu.value;
|
}
|
}
|
return NONE.value;
|
}
|
}
|