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

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

/**
 * @author Homan Liang
 * @date 2019/8/8
 */
public enum DeliveryStaffType {
    /**
     * 项目配送员
     */
    PROJECT(1,"项目配送员"),
    /**
     * 商户配送员"
     */
    SALE(2,"商户配送员");

    private Integer key;
    private String desc;

    DeliveryStaffType(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 (DeliveryStaffType c : DeliveryStaffType.values()) {
            if (c.key == key) {
                return c.getDesc();
            }
        }
        return null;
    }

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

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

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