From b477e40d3c98d06c5bd680b1eb3dd2ba6b230d6d Mon Sep 17 00:00:00 2001 From: lihy2021 Date: Fri, 24 Sep 2021 00:41:43 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E4=BF=A1=E6=81=AF=EF=BC=8C=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/web/service/SysLoginService.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index 07bb03c..2b54743 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -87,7 +87,7 @@ public class SysLoginService } AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); LoginUser loginUser = (LoginUser) authentication.getPrincipal(); - recordLoginInfo(loginUser.getUser()); + recordLoginInfo(loginUser.getUserId()); // 生成token return tokenService.createToken(loginUser); } @@ -119,11 +119,15 @@ public class SysLoginService /** * 记录登录信息 + * + * @param userId 用户ID */ - public void recordLoginInfo(SysUser user) + public void recordLoginInfo(Long userId) { - user.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest())); - user.setLoginDate(DateUtils.getNowDate()); - userService.updateUserProfile(user); + SysUser sysUser = new SysUser(); + sysUser.setUserId(userId); + sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest())); + sysUser.setLoginDate(DateUtils.getNowDate()); + userService.updateUserProfile(sysUser); } }