mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-14 12:23:39 +00:00
[fix][feat](chat): 添加会话中SaToken-token值传递和使用;修复“自动注入警告 => 用户未登录”
- 新增 BaseContext 类,用于保存和获取当前登录用户的 token - 在 OpenAIServiceImpl 和 imageServiceImpl 中获取当前会话 token - 将 token 作为参数传递给 SSEEventSourceListener - 在 SSEEventSourceListener 中使用 token 进行用户身份验证和权限控制 - 修改 LoginHelper,增加根据 token 获取登录用户信息的方法 - 更新 InjectionMetaObjectHandler,使用 BaseContext 获取当前 token - 修复对话时出先”自动注入警告 => 用户未登录“
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package org.ruoyi.common.core.service;
|
||||
|
||||
/**
|
||||
* @description: 基于ThreadLocal封装工具类,用户保存和获取当前登录用户Sa-Token token值
|
||||
* @author: yzm
|
||||
**/
|
||||
public class BaseContext {
|
||||
private static ThreadLocal<String> threadLocal = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* @description: 设置值
|
||||
* @author: yzm
|
||||
* @param: [token] 线程token
|
||||
**/
|
||||
public static void setCurrentToken(String token){
|
||||
threadLocal.set(token);
|
||||
}
|
||||
/**
|
||||
* @description: 获取值
|
||||
* @author: yzm
|
||||
**/
|
||||
public static String getCurrentToken(){
|
||||
return threadLocal.get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user