package com.fjhx.entity.supplier.enums;

import cn.hutool.core.util.ObjectUtil;
import org.springblade.core.tool.utils.StringPool;

import java.util.LinkedHashMap;

/**
 * 面料问题反馈类型
 */
public enum SupplierProblemEnum {
    SHORTAGE(1, "短少"),
    DRAWN_WORK(2, "抽纱"),
    WRINKLE(3, "褶皱"),
    SMUDGINESS(4, "脏污"),
    HOLE(5, "破洞"),
    SHRINK(6, "缩水"),
    ;

    private int key;

    private String value;

    private static LinkedHashMap<Integer, String> map = new LinkedHashMap<>();

    SupplierProblemEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    /**
     * 获取枚举map
     *
     * @return
     */
    public static LinkedHashMap<Integer, String> getMap() {
        if (ObjectUtil.isNotEmpty(map)) {
            return map;
        }
        for (SupplierProblemEnum ms : values()) {
            map.put(ms.key, ms.value);
        }
        return map;
    }

    /**
     * 通过key获取名称
     *
     * @param key
     * @return
     */
    public static String getNameByKey(Integer key) {
        if (key == null || key < 0) {
            return StringPool.EMPTY;
        }
        LinkedHashMap<Integer, String> map = getMap();
        return map.getOrDefault(key, StringPool.EMPTY);
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

}
