gongchunyi
2 天以前 52e93e45d7c989483693f53ded1b4483891fb055
src/main/java/com/ruoyi/production/enums/MaterialConfigTypeEnum.java
@@ -13,13 +13,50 @@
    /**
     * 物料类型
     * 对应数据库 config_type = MATERIAL_TYPE
     */
    MATERIAL_TYPE,
    MATERIAL_TYPE(1, "物料类型"),
    /**
     * 存货类别
     * 对应数据库 config_type = INVENTORY_CAT
     */
    INVENTORY_CAT
    INVENTORY_CAT(2, "存货类别");
    private final Integer type;
    private final String desc;
    MaterialConfigTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }
    public Integer getType() {
        return type;
    }
    public String getDesc() {
        return desc;
    }
    /**
     * 根据 type 获取枚举
     */
    public static MaterialConfigTypeEnum getByType(Integer type) {
        for (MaterialConfigTypeEnum value : values()) {
            if (value.type.equals(type)) {
                return value;
            }
        }
        return null;
    }
    /**
     * 根据 type 获取数据库存储值
     */
    public static String getConfigType(Integer type) {
        MaterialConfigTypeEnum e = getByType(type);
        if (e == null) {
            throw new IllegalArgumentException("配置类型错误");
        }
        return e.name();
    }
}