package com.ycwl.basic.enums;

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

/**
 * @Author：longbinbin
 * @Date：2024/12/6 16:46
 */
public enum GoodsTypeEnum {
    VIDEO(1,"成片"),
    SOURCE(2,"源素材")
    ;


    public Integer code;

    private String value;
    public static final Map<Integer, GoodsTypeEnum> cacheMap;

    static {
        cacheMap = new HashMap<>(GoodsTypeEnum.values().length);
        for (GoodsTypeEnum value : GoodsTypeEnum.values()) {
            cacheMap.put(value.code, value);
        }
    }
    public static final java.util.Map<String, GoodsTypeEnum> valueMap;

    static {
        valueMap = new HashMap<>(GoodsTypeEnum.values().length);
        for (GoodsTypeEnum value : GoodsTypeEnum.values()) {
            valueMap.put(value.value, value);
        }
    }

    GoodsTypeEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    /**
     * 获取value值
     */
    public static String getValue(Integer noticeMethod) {
        if (noticeMethod == null) {
            return null;
        }

        GoodsTypeEnum GoodsTypeEnum = cacheMap.get(noticeMethod);
        if (GoodsTypeEnum == null) {
            return null;
        }
        return GoodsTypeEnum.value;
    }
    /**
     * 获取code值
     */
    public static Integer getCode(String noticeMethod) {
        if (noticeMethod == null) {
            return -1;
        }

        GoodsTypeEnum GoodsTypeEnum = valueMap.get(noticeMethod);
        if (GoodsTypeEnum == null) {
            return -1;
        }
        return GoodsTypeEnum.code;
    }
}
