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

public enum OrderType {

    NORMAL_ORDER(0, "正常订单"),
    SECKILL_ORDER(1, "秒杀订单"),
    DEFAULT(99, "未知");

    private Integer key;

    private String name;

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