diff --git a/ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java index ed4e471a4..bde0d4a94 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java @@ -9,6 +9,11 @@ import io.jsonwebtoken.Claims; */ public class Constants { + /** + * UTF-8 字符集 + */ + public static final String UTF8 = "UTF-8"; + /** * 通用成功标识 */ diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java b/ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java index fde9bb2de..8e8de0584 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java +++ b/ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java @@ -70,6 +70,18 @@ public class TokenService return null; } + /** + * 设置用户身份信息 + */ + public void setLoginUser(LoginUser loginUser) + { + if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken())) + { + String userKey = getTokenKey(loginUser.getToken()); + redisCache.setCacheObject(userKey, loginUser); + } + } + /** * 创建令牌 * diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java index fd8eee232..aab393635 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java @@ -98,6 +98,8 @@ public class SysProfileController extends BaseController { AjaxResult ajax = AjaxResult.success(); ajax.put("imgUrl", avatar); + loginUser.getUser().setAvatar(avatar); + tokenService.setLoginUser(loginUser); return ajax; } }