diff --git a/ruoyi-auth/src/main/java/org/dromara/auth/listener/UserActionListener.java b/ruoyi-auth/src/main/java/org/dromara/auth/listener/UserActionListener.java index 211b911b..c4a1a0e1 100644 --- a/ruoyi-auth/src/main/java/org/dromara/auth/listener/UserActionListener.java +++ b/ruoyi-auth/src/main/java/org/dromara/auth/listener/UserActionListener.java @@ -74,7 +74,6 @@ public class UserActionListener implements SaTokenListener { logininforEvent.setUsername(username); logininforEvent.setStatus(Constants.LOGIN_SUCCESS); logininforEvent.setMessage(MessageUtils.message("user.login.success")); - logininforEvent.setRequest(ServletUtils.getRequest()); SpringUtils.context().publishEvent(logininforEvent); // 更新登录信息 remoteUserService.recordLoginInfo((Long) loginModel.getExtra(LoginHelper.USER_KEY), ip); diff --git a/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java b/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java index daa87ff7..7d614a2e 100644 --- a/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java +++ b/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java @@ -23,7 +23,6 @@ import org.dromara.common.core.exception.user.CaptchaException; import org.dromara.common.core.exception.user.CaptchaExpireException; import org.dromara.common.core.exception.user.UserException; import org.dromara.common.core.utils.MessageUtils; -import org.dromara.common.core.utils.ServletUtils; import org.dromara.common.core.utils.SpringUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.log.event.LogininforEvent; @@ -186,7 +185,6 @@ public class SysLoginService { logininforEvent.setUsername(username); logininforEvent.setStatus(status); logininforEvent.setMessage(message); - logininforEvent.setRequest(ServletUtils.getRequest()); SpringUtils.context().publishEvent(logininforEvent); } diff --git a/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/event/LogEventListener.java b/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/event/LogEventListener.java index 4c3e8e3e..3584e0c6 100644 --- a/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/event/LogEventListener.java +++ b/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/event/LogEventListener.java @@ -18,7 +18,6 @@ import org.dromara.system.api.domain.bo.RemoteLogininforBo; import org.dromara.system.api.domain.bo.RemoteOperLogBo; import org.dromara.system.api.domain.vo.RemoteClientVo; import org.springframework.context.event.EventListener; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; /** @@ -38,7 +37,6 @@ public class LogEventListener { /** * 保存系统日志记录 */ - @Async @EventListener public void saveLog(OperLogEvent operLogEvent) { RemoteOperLogBo sysOperLog = BeanUtil.toBean(operLogEvent, RemoteOperLogBo.class); @@ -48,10 +46,9 @@ public class LogEventListener { /** * 保存系统访问记录 */ - @Async @EventListener public void saveLogininfor(LogininforEvent logininforEvent) { - HttpServletRequest request = logininforEvent.getRequest(); + HttpServletRequest request = ServletUtils.getRequest(); final UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent")); final String ip = ServletUtils.getClientIP(request); // 客户端信息 @@ -95,7 +92,7 @@ public class LogEventListener { } remoteLogService.saveLogininfor(logininfor); } - + private String getBlock(Object msg) { if (msg == null) { msg = ""; diff --git a/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/event/LogininforEvent.java b/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/event/LogininforEvent.java index 938eaadd..212bf18b 100644 --- a/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/event/LogininforEvent.java +++ b/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/event/LogininforEvent.java @@ -2,8 +2,6 @@ package org.dromara.common.log.event; import lombok.Data; -import jakarta.servlet.http.HttpServletRequest; - import java.io.Serial; import java.io.Serializable; @@ -39,11 +37,6 @@ public class LogininforEvent implements Serializable { */ private String message; - /** - * 请求体 - */ - private HttpServletRequest request; - /** * 其他参数 */ diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteLogServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteLogServiceImpl.java index fd2a69e3..bcb0e058 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteLogServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteLogServiceImpl.java @@ -10,6 +10,7 @@ import org.dromara.system.domain.bo.SysLogininforBo; import org.dromara.system.domain.bo.SysOperLogBo; import org.dromara.system.service.ISysLogininforService; import org.dromara.system.service.ISysOperLogService; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; /** @@ -25,12 +26,14 @@ public class RemoteLogServiceImpl implements RemoteLogService { private final ISysOperLogService operLogService; private final ISysLogininforService logininforService; + @Async @Override public void saveLog(RemoteOperLogBo remoteOperLogBo) { SysOperLogBo sysOperLogBo = MapstructUtils.convert(remoteOperLogBo, SysOperLogBo.class); operLogService.insertOperlog(sysOperLogBo); } + @Async @Override public void saveLogininfor(RemoteLogininforBo remoteLogininforBo) { SysLogininforBo sysLogininforBo = MapstructUtils.convert(remoteLogininforBo, SysLogininforBo.class);