public enum CustomerRoleEnum {
ROLE_CUSTOMER(0, "xxx", "gk"),
ROLE_DR_MEMBER(1, "xxxx", "hy"),
ROLE_SALESMAN(2, "xxxxx", "dxy"),
ROLE_AGENCY(3, "xxxxxx", "jxs"),
ROLE_MANAGER_AND_OVER(4, "xxxxxxxx", "jlover");
private CustomerRoleEnum(Integer code, String text, String orgLv) {
this.code = code;
this.text = text;
this.orgLv = orgLv;}
private Integer code;
private String text;
private String orgLv;/** 角色代码 */
public Integer code() {
return code;
}
/** 角色中文名称 */
public String text() {
return text;
}public String orgLv() {
return orgLv;
}
public static CustomerRoleEnum getByCode(Integer code) {for (CustomerRoleEnum item : CustomerRoleEnum.values()) {
if (item.code() == code) {
return item;
}
}return null;
}}
调用
CustomerRoleEnum cre = CustomerRoleEnum.ROLE_CUSTOMER;
Integer code = CustomerRoleEnum.ROLE_CUSTOMER.code();
Sring text = CustomerRoleEnum.ROLE_CUSTOMER.text();
String orgLv = CustomerRoleEnum.ROLE_CUSTOMER.orgLv();