package cn.reghao.tnb.content.api.constant;

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

/**
 * 视频错误类型
 *
 * @author reghao
 * @date 2024-11-07 21:49:19
 */
public enum VideoErrorType {
    noCover(1, "视频无封面"),
    noAudio(2, "视频无声音"),
    noVideo(3, "视频无画面"),
    noResource(4, "视频无资源"),
    hasAd(5, "视频有广告"),
    needRestore(8, "视频待恢复");

    private final Integer code;
    private final String desc;

    private static Map<Integer, VideoErrorType> descMap = new HashMap<>();
    static {
        for (VideoErrorType status : VideoErrorType.values()) {
            descMap.put(status.code, status);
        }
    }

    VideoErrorType(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Deprecated
    public Integer getCode() {
        return code;
    }

    public int getValue() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    // TODO 第一次调用时会初始化 descMap
    public static VideoErrorType getDescByCode(int code) {
        return descMap.get(code);
    }
}
