package com.hwrj.cloud.admin.dao.excel.enumbo;

public enum PayType {


    UNPAID(0, "未支付"),
    ALIPAY(1, "支付宝"),
    WECHAT(2, "微信"),
    DEFAULT(99, "未知");

    private Integer key;

    private String name;

    /**
     * @param key
     * @param name
     */
    PayType(Integer key, String name) {
        this.key = key;
        this.name = name;
    }

    /**
     * @return Returns the key.
     */
    public Integer getKey() {
        return key;
    }

    /**
     * @return Returns the name.
     */
    public String getName() {
        return name;
    }


    /**
     * 根据Key得到枚举的Value
     * 普通for循环遍历，比较判断
     *
     * @param key
     * @return
     */
    public static PayType getEnumType(Integer key) {
        PayType[] alarmGrades = PayType.values();
        for (int i = 0; i < alarmGrades.length; i++) {
            if (alarmGrades[i].getKey().equals(key)) {
                return alarmGrades[i];
            }
        }
        return PayType.DEFAULT;
    }
}
