package com.happy.Until.Enum;

import com.happy.Until.Func;

import static com.happy.Until.Enum.PayEnum.状态异常;

public enum ProgressEnum {

    待处理(1,"待处理"),处理中(2,"处理中"),已处理(3,"已处理");
    private int num;
    private String progressType;

    ProgressEnum(int num, String progressType) {

        this.num = num;
        this.progressType = progressType;
    }

    /**
     * 遍历枚举类
     * @param num
     * @return
     */
    public static String getKeyBykey(int num) {
        try {
            for (ProgressEnum type : ProgressEnum.values()) {
                if (Func.parseInt(type.getNum()) == num) {
                    return Func.parseStr(type.getNum());
                }
            }
        } catch (Exception e) {
            return Func.parseStr(状态异常.getNum());
        }
        return Func.parseStr(状态异常.getNum());
    }

    /**
     * 遍历枚举类
     * @param num
     * @return
     */
    public static String getValueBykey(int num) {
        try {
            for (ProgressEnum type : ProgressEnum.values()) {
                if (Func.parseInt(type.getNum()) == num) {
                    return type.getProgressType();
                }
            }
        } catch (Exception e) {
            return 状态异常.getPayStatus();
        }
        return 状态异常.getPayStatus();
    }

    /**
     * 遍历枚举类
     * @param value
     * @return
     */
    public static int getKeyByValue(String value) {
        try {
            if (Func.checkNull(value))
                return 状态异常.getNum();

            for (PayEnum type : PayEnum.values()) {
                if (value.equals(Func.parseStr(type.getPayStatus()))) {
                    return type.getNum();
                }
            }
        } catch (Exception e) {
            return 状态异常.getNum();
        }
        return 状态异常.getNum();
    }


    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public String getProgressType() {
        return progressType;
    }

    public void setProgressType(String progressType) {
        this.progressType = progressType;
    }
}
