package com.mortals.xhx.common.code;

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

/**
* 请假类型(1.事假,2.调休,3.病假,4.年假,5.产假,6.陪产假,7.婚假,8.例假,9.哺乳假,10.丧假)枚举类
*
* @author zxfei
*/
public enum LeaveTypeEnum {
    事假(1, "事假"),
    调休(2, "调休"),
    病假(3, "病假"),
    年假(4, "年假"),
    产假(5, "产假"),
    陪产假(6, "陪产假"),
    婚假(7, "婚假"),
    例假(8, "例假"),
    哺乳假(9, "哺乳假"),
    丧假(10, "丧假");
    private Integer value;
    private String desc;

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

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

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

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

    /**
    * 获取Map集合
    *
    * @param eItem 不包含项
    * @return
    */
    public static Map<String, String> getEnumMap(Integer... eItem) {
        Map<String, String> resultMap = new LinkedHashMap<>();
        for (LeaveTypeEnum item : LeaveTypeEnum.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;
    }
}