提交 c880cda2 authored 作者: liupengfei's avatar liupengfei

--no commit message

上级 a148a9c3
package com.zrqx.core.enums;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
/**
* 资源类型枚举
* @author ycw
* @date
*/
public enum VisceraTypeEnum {
//资源类型 1图书、2专家、3文章、4图片、5视频、6音频、7课件
(0, "全部"),
(1, "胆"),
(2, "肝"),
(3, "肺"),
大肠(4, "大肠"),
(5, "胃"),
(6, "脾"),
(7, "心"),
小肠(8, "小肠"),
膀胱(9, "膀胱"),
(10, "肾"),
心包(11, "心包"),
三焦(12, "三焦");
private final Integer code;
private final String name;
private VisceraTypeEnum(Integer code,String name){
this.code=code;
this.name=name;
}
public static VisceraTypeEnum valueOfCode(String code) {
if (StringUtils.isBlank(code)) {
throw new IllegalArgumentException("Library Status " + code + " is blank");
}
for (VisceraTypeEnum mt : values()) {
if (mt.getCode().equals(code)) {
return mt;
}
}
throw new IllegalArgumentException("Library Status " + code + " is not exist");
}
/**
* 通过ID获取中文名称
* @param code
* @return
*/
public static String getName(Integer code) {
if (code == null) {
return null;
}
for (VisceraTypeEnum mt : values()) {
if (mt.getCode().equals(code)) {
return mt.getName();
}
}
return null;
}
/**
* 通过中文名称获取ID
* @param code
* @return
*/
public static Integer getCode(String name) {
if (StringUtils.isBlank(name)) {
return null;
}
for (VisceraTypeEnum mt : values()) {
if (mt.getName().equals(name)) {
return mt.getCode();
}
}
return null;
}
/**
* 获取所有的枚举,以MAP返回
* @return
*/
public static HashMap<String,String> getAllEnumMap() {
HashMap<String,String> map = new HashMap<String,String>();
for (VisceraTypeEnum mt : values()) {
map.put(mt.getCode()+"", mt.getName());
}
return map;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论