package com.atguigu.ssyx.common.auth;

import com.atguigu.ssyx.vo.user.UserLoginVo;

/**
 * ClassName: AuthContextHolder
 * Package: com.atguigu.ssyx.common.auth
 *
 * @author yovinchen
 * @Create 2023/9/22 17:40
 */
//ThreadLocal工具类
public class AuthContextHolder {

    //用户id
    private static final ThreadLocal<Long> userId = new ThreadLocal<>();

    //用户仓库id
    private static final ThreadLocal<Long> wareId = new ThreadLocal<>();

    //用户信息对象
    private static final ThreadLocal<UserLoginVo> userLoginVo = new ThreadLocal<>();

    public static Long getUserId() {
        return userId.get();
    }

    //userId操作的方法
    public static void setUserId(Long _userId) {
        userId.set(_userId);
    }

    public static Long getWareId() {
        return wareId.get();
    }

    public static void setWareId(Long _wareId) {
        wareId.set(_wareId);
    }

    public static UserLoginVo getUserLoginVo() {
        return userLoginVo.get();
    }

    public static void setUserLoginVo(UserLoginVo _userLoginVo) {
        userLoginVo.set(_userLoginVo);
    }


}
