package cn.superdesk.uniorder.common.enums.lnss;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * 商品状态
 * @author Homan Liang
 * @version 1.0
 * @date 2019/8/12
 */
public enum ProductStatusEnum {

    TO_RACK(1,"待上架"),
    RACKED(2,"已上架"),
    REJECT(3,"不通过"),
    DOWN(4,"已下架"),
    ;

    private Integer key;
    private String desc;

    ProductStatusEnum(int key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public int getKey() {
        return key;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDesc(int key) {
        for (ProductStatusEnum c : ProductStatusEnum.values()) {
            if (c.key == key) {
                return c.getDesc();
            }
        }
        return null;
    }

    private static final Map<Integer, ProductStatusEnum> LOOKUP = new HashMap<>();

    static {
        for(ProductStatusEnum s : EnumSet.allOf(ProductStatusEnum.class)) {
            LOOKUP.put(s.getKey(), s);
        }
    }

    /**
     * 方向查找枚举类
     * @param key
     * @return
     */
    public static ProductStatusEnum get(Integer key) {
        return LOOKUP.get(key);
    }
}
