public static enum SourceEnum{
YOUOILAPP("好油",1),
YOUOILWX("微微信",2),
QUANZHOUTONGAPP("泉小红",3),
YOUOILWEBAPP("移动端",4),
YOUOILPC("电脑端",5),
XLYAPP("APP端",7);
private SourceEnum(String value,int key){
this.value = value;
this.key=key;
}
private int key;
private String value;
public int getKey() {
return key;
}
public void setKey(int key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
//根据key获取value的值
public static String getValueByKey(int key){
for (SourceEnum s : SourceEnum.values()) {
if(s.getKey()==key){
return s.getValue();
}
}
return "";
}
//根据匹配value的值获取key
public static int getKeyByValue(String channelName){
for (SourceEnum s : SourceEnum.values()) {
if(channelName.equals(s.getValue())){
return s.getKey();
}
}
return 0;
}
}