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

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

/**
 * 描述稿件的可见范围
 * 基于 cn.reghao.oss.store.api.constant.ObjectScope 的扩展
 *
 * @author reghao
 * @date 2024-03-05 10:45:45
 */
public enum PostScope {
    PRIVATE(1, "本人可见"),
    PUBLIC(2, "所有人可见"),
    PROTECT(3, "VIP 可见"),
    FRIEND(4, "验证码可见");

    private final int code;
    private final String desc;
    private static final Map<Integer, PostScope> map = new HashMap<>();
    static {
        for (PostScope scope : PostScope.values()) {
            map.put(scope.code, scope);
        }
    }

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

    public String getName() {
        return this.name();
    }

    /**
     * 提供给 @ValidEnum 调用
     *
     * @param
     * @return
     * @date 2023-10-11 14:44:42
     */
    public int getValue() {
        return this.code;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static PostScope getByCode(int code) {
        return map.get(code);
    }
}
