package com.mortals.xhx.common.code;

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

/**
* 区域等级(1.省，2.地市州，3.区县，4.街道，5.社区)枚举类
*
* @author zxfei
*/
public enum AreaLevelEnum {
    省(1, "省"),
    地市州(2, "地市州"),
    区县(3, "区县"),
    街道(4, "街道"),
    社区(5, "社区");
    private Integer value;
    private String desc;

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

    public Integer getValue() {
        return this.value;
    }

    public String getDesc() {
        return this.desc;
    }

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

    /**
    * 获取Map集合
    *
    * @param eItem 不包含项
    * @return
    */
    public static Map<String, String> getEnumMap(Integer... eItem) {
        Map<String, String> resultMap = new LinkedHashMap<>();
        for (AreaLevelEnum item : AreaLevelEnum.values()) {
            try {
                boolean hasE = false;
                for (Integer e : eItem) {
                    if (item.getValue() == e) {
                        hasE = true;
                        break;
                    }
                }
                if (!hasE) {
                    resultMap.put(item.getValue() + "", item.getDesc());
                }
            } catch (Exception ex) {

            }
        }
        return resultMap;
    }
}