From 018195e47b9acb0cb7aec566023d206e2eb02509 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 19 Nov 2019 16:08:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=8A=E4=BC=A0=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E5=AE=9E=E6=97=B6=E5=90=8C=E6=AD=A5=E7=BC=93=E5=AD=98?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E9=9C=80=E9=87=8D=E6=96=B0=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/common/constant/Constants.java | 5 +++++ .../framework/security/service/TokenService.java | 12 ++++++++++++ .../system/controller/SysProfileController.java | 2 ++ 3 files changed, 19 insertions(+) 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 ed4e471a..bde0d4a9 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 fde9bb2d..8e8de058 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 fd8eee23..aab39363 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; } }