From 5803258ed7c0b8c4c092557695f29709cc05e195 Mon Sep 17 00:00:00 2001 From: Lyon <18423215834@163.com> Date: Sun, 7 Mar 2021 15:49:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=B6=85=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E7=94=A8=E6=88=B7-=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/system/job/auth/SysUserSessionTimeoutJob.java | 4 ++-- .../system/service/auth/impl/SysUserSessionServiceImpl.java | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/job/auth/SysUserSessionTimeoutJob.java b/src/main/java/cn/iocoder/dashboard/modules/system/job/auth/SysUserSessionTimeoutJob.java index ff5fa2f2d..799fe115f 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/job/auth/SysUserSessionTimeoutJob.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/job/auth/SysUserSessionTimeoutJob.java @@ -21,9 +21,9 @@ public class SysUserSessionTimeoutJob implements JobHandler { @Override public String execute(String param) throws Exception { - log.info("[execute][执行任务:{}]", "清除过期用户信息"); + log.info("[execute][执行任务:{}]", "移除超时的在线用户"); long timeoutCount = sysUserSessionService.clearSessionTimeout(); - log.info("[execute][执行任务:{}]", "清楚过期用户信息完成" + timeoutCount); + log.info("[execute][执行任务:{}]", "移除超时的在线用户完成" + timeoutCount); return null; } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/auth/impl/SysUserSessionServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/auth/impl/SysUserSessionServiceImpl.java index 0c192a404..e1fb1fa2f 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/auth/impl/SysUserSessionServiceImpl.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/auth/impl/SysUserSessionServiceImpl.java @@ -105,9 +105,11 @@ public class SysUserSessionServiceImpl implements SysUserSessionService { @Override public long clearSessionTimeout() { + // 获取db里已经超时的用户列表 Long timeoutCount = 0L; - List sessionDOS = userSessionMapper.selectSessionTimeout(); - for (SysUserSessionDO sessionDO : sessionDOS) { + List sessionTimeoutDOS = userSessionMapper.selectSessionTimeout(); + for (SysUserSessionDO sessionDO : sessionTimeoutDOS) { + // 确认已经超时,移出在线用户列表 if (loginUserRedisDAO.get(sessionDO.getId()) == null) { timeoutCount += userSessionMapper.deleteById(sessionDO.getId()); }