package com.mortals.xhx.common.code;

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

/**
* 发送状态(0.未发送，1.提交，2.发送成功，3.发生失败)枚举类
*
* @author zxfei
*/
public enum SendStatusEnum {
    未发送(0, "未发送"),
    提交(1, "提交"),
    发送成功(2, "发送成功"),
    发生失败(3, "发生失败");
    private Integer value;
    private String desc;

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

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

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

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

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