package cn.reghao.tnb.oss.store.util;

/**
 * @author reghao
 * @date 2023-06-02 10:48:59
 */
public class AuthContext implements AutoCloseable {
    static final ThreadLocal<Integer> CURRENT = new ThreadLocal<>();

    public AuthContext(int user) {
        CURRENT.set(user);
    }

    @Deprecated
    public static int getUser() {
        return CURRENT.get();
    }

    public static int getUserId() {
        return CURRENT.get();
    }

    @Override
    public void close() {
        CURRENT.remove();
    }
}
