package com.vci.starter.web.enumpck;
|
|
/**
|
* 会话信息存储的方式,实际上和spring-session的管理方式是一样的,但是为了兼容以前的项目,又重复造了轮子
|
* @author weidy
|
* @date 2020/2/5
|
*/
|
public enum SessionStorageTypeEnum implements BaseEnum {
|
/**
|
* redis管理
|
*/
|
REDIS("redis","缓存"),
|
|
/**
|
* 数据库
|
*/
|
DATABASE("database","数据库");
|
|
/**
|
* 值
|
*/
|
private String value;
|
|
/**
|
* 显示文本
|
*/
|
private String text;
|
|
@Override
|
public String getValue() {
|
return value;
|
}
|
|
@Override
|
public String getText() {
|
return text;
|
}
|
|
public void setValue(String value) {
|
this.value = value;
|
}
|
|
public void setText(String text) {
|
this.text = text;
|
}
|
|
private SessionStorageTypeEnum(String value,String text){
|
this.value = value;
|
this.text = text;
|
}
|
|
/**
|
* 根据名称获取对应的枚举值
|
* @param text 名称
|
* @return 枚举值
|
*/
|
public static String getValueByText(String text){
|
for(SessionStorageTypeEnum wenum : SessionStorageTypeEnum.values()){
|
if(wenum.getText().equalsIgnoreCase(text)){
|
return wenum.getValue();
|
}
|
}
|
return "";
|
}
|
|
/**
|
* 根据枚举值获取名称
|
* @param value 枚举值
|
* @return 名称
|
*/
|
public static String getTextByValue(String value){
|
for(SessionStorageTypeEnum wenum : SessionStorageTypeEnum.values()){
|
if(wenum.getValue().equalsIgnoreCase(value)){
|
return wenum.getText();
|
}
|
}
|
return "";
|
}
|
|
/**
|
* 值转换为枚举对象
|
* @param value 值
|
* @return 如果不符合要求返回Null
|
*/
|
public static SessionStorageTypeEnum forValue(String value){
|
for(SessionStorageTypeEnum wenum : SessionStorageTypeEnum.values()){
|
if(wenum.getValue().equalsIgnoreCase(value)){
|
return wenum;
|
}
|
}
|
return SessionStorageTypeEnum.REDIS;
|
}
|
}
|