package com.mortals.xhx.common.code;

import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.common.IBaseEnum;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 区域级别
 *
 * @author yiqimin
 * @create 2018/09/26
 */
public enum AreaLevelEnum implements IBaseEnum {

    PROVINCE(1, "省", SysConstains.STYLE_DEFAULT),
    CITY(2, "市", SysConstains.STYLE_DEFAULT),
    AREA(3, "区/县", SysConstains.STYLE_DEFAULT),
    TOWN(4, "镇", SysConstains.STYLE_DEFAULT);

    private int value;
    private String desc;
    private String style;

    AreaLevelEnum(int value, String desc, String style) {
        this.value = value;
        this.desc = desc;
        this.style = style;
    }

    @Override
    public int getValue() {
        return this.value;
    }

    public String getDesc() {
        return desc;
    }

    public String getStyle()
    {
        return style;
    }

    public static AreaLevelEnum getByValue(int value) {
        for (AreaLevelEnum e : AreaLevelEnum.values()) {
            if (e.getValue() == value) {
                return e;
            }
        }
        return null;
    }

    public static Map<String,String> getEnumMap(int... eItem) {
        Map<String,String> resultMap= new LinkedHashMap<String,String>();
        for (AreaLevelEnum item : AreaLevelEnum.values()) {
            try{
                boolean hasE = false;
                for (int e : eItem){
                    if(item.getValue()==e){
                        hasE = true;
                        break;
                    }
                }
                if(!hasE){
                    resultMap.put(item.getValue()+"", item.getDesc());
                }
            }catch(Exception ex){
            }
        }
        return resultMap;
    }
    
}
