This commit is contained in:
wells
2026-08-05 13:48:48 +08:00
commit 1303bf37dc
80 changed files with 5154 additions and 0 deletions
@@ -0,0 +1,46 @@
package com.tailbet.model.vo;
/**
* 用户上下文 - ThreadLocal保存当前登录用户
*/
public class UserContext {
private static final ThreadLocal<LoginUserVo> USER = new ThreadLocal<>();
public static void setUser(LoginUserVo user) {
USER.set(user);
}
public static LoginUserVo getUser() {
return USER.get();
}
public static Long getUserId() {
LoginUserVo user = USER.get();
return user != null ? user.getUserId() : null;
}
public static void remove() {
USER.remove();
}
public static boolean isOps() {
LoginUserVo user = USER.get();
return user != null && Boolean.TRUE.equals(user.getIsOps());
}
public static boolean isBot() {
LoginUserVo user = USER.get();
return user != null && Boolean.TRUE.equals(user.getIsBot());
}
public static boolean isFake() {
LoginUserVo user = USER.get();
return user != null && Boolean.TRUE.equals(user.getIsFake());
}
public static boolean isWhite() {
LoginUserVo user = USER.get();
return user != null && Boolean.TRUE.equals(user.getIsWhite());
}
}