zjh
2023-10-13 906328ba3f842f5f86cb5bd60e09a8a7f6d2ac93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.ltkj.framework.config;
 
import com.ltkj.common.core.domain.model.LoginUser;
import com.ltkj.hosp.domain.Wxuser;
 
/**
 * @Author: 西安路泰科技有限公司/赵佳豪
 * @Date: 2022/11/17 10:26
 */
 
//工具类:实现向threadLocal存储数据
public class UserHoder {
    private static ThreadLocal<Wxuser> tl = new ThreadLocal<>();
    private static ThreadLocal<LoginUser> tt = new ThreadLocal<>();
 
    //将用户存入theradlocal
    public static void set(Wxuser wxuser) {
        tl.set(wxuser);
    }
 
    public static void setLoginUser(LoginUser loginUser) {
        tt.set(loginUser);
    }
 
    //从当前线程获取用户id
    public static Wxuser getWxuser() {
        return tl.get();
    }
 
    public static LoginUser getLoginUser() {
        return tt.get();
    }
}