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

public enum Status {

    TO_BE_PAID(0, "待付款"),
    TO_BE_DELIVERED(1, "待发货"),
    DELIVERED(2, "已发货"),
    COMPLETED(3, "已完成"),
    CLOSED(4, "已关闭"),
    INVALID_ORDER(5, "无效订单"),
    DEFAULT(99, "未知");

    private Integer key;

    private String name;

    /**
     * @param key
     * @param name
     */
    Status(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 Status getEnumType(Integer key) {
        Status[] alarmGrades = Status.values();
        for (int i = 0; i < alarmGrades.length; i++) {
            if (alarmGrades[i].getKey().equals(key)) {
                return alarmGrades[i];
            }
        }
        return Status.DEFAULT;
    }
}
