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

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

/**
 * 视频状态
 * 审核 -> 发布 -> 撤销
 *
 * @author reghao
 * @date 2021-11-24 17:49:19
 */
public enum VideoStatus {
    censor(1, "审核中"),
    publish(2, "审核通过"),
    censorFailed(3, "审核未通过"),
    revoke(4, "下架"),
    noVideoFile(5, "无视频资源"),
    hasAd(6, "视频有广告"),
    needRepair(7, "视频待修正"),
    needRestore(8, "视频待恢复");

    private final Integer code;
    private final String desc;

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

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

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

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