From dcf416dcfd58e33d5140d1ae52979284aaf47623 Mon Sep 17 00:00:00 2001 From: gqlin <1079535662@qq.com> Date: Wed, 8 Feb 2023 23:02:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3asyncSaveSystemLog=E6=89=80?= =?UTF-8?q?=E5=9C=A8=E5=AD=90=E7=BA=BF=E7=A8=8B=E5=9C=A8=E4=B8=BB=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=89=A7=E8=A1=8C=E5=AE=8C=E6=88=90=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E4=B8=BB=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E6=9C=AC=E6=AC=A1=E8=AF=B7=E6=B1=82=E7=9B=B8=E5=85=B3=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B=E5=90=8C=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E8=AF=81=E4=B8=BB=E7=BA=BF=E7=A8=8B=E6=97=A0?= =?UTF-8?q?=E9=9C=80=E7=AD=89=E5=BE=85=E5=AD=90=E7=BA=BF=E7=A8=8B=E7=9A=84?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=AE=8C=E6=88=90=EF=BC=8C=E4=BB=8E=E8=80=8C?= =?UTF-8?q?=E4=B8=8D=E5=BD=B1=E5=93=8Dweb=E9=A1=B5=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zyd/blog/business/aspect/BussinessLogAspect.java | 3 ++- .../java/com/zyd/blog/business/service/SysLogService.java | 3 ++- .../zyd/blog/business/service/impl/SysLogServiceImpl.java | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/blog-core/src/main/java/com/zyd/blog/business/aspect/BussinessLogAspect.java b/blog-core/src/main/java/com/zyd/blog/business/aspect/BussinessLogAspect.java index bc7850c1..dff1804b 100644 --- a/blog-core/src/main/java/com/zyd/blog/business/aspect/BussinessLogAspect.java +++ b/blog-core/src/main/java/com/zyd/blog/business/aspect/BussinessLogAspect.java @@ -67,7 +67,8 @@ private void handle(ProceedingJoinPoint point) throws Exception { return; } - logService.asyncSaveSystemLog(platform, bussinessName); + ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + logService.asyncSaveSystemLog(platform, bussinessName, servletRequestAttributes); } diff --git a/blog-core/src/main/java/com/zyd/blog/business/service/SysLogService.java b/blog-core/src/main/java/com/zyd/blog/business/service/SysLogService.java index 542f60ef..0f230a33 100644 --- a/blog-core/src/main/java/com/zyd/blog/business/service/SysLogService.java +++ b/blog-core/src/main/java/com/zyd/blog/business/service/SysLogService.java @@ -6,6 +6,7 @@ import com.zyd.blog.business.enums.PlatformEnum; import com.zyd.blog.business.vo.LogConditionVO; import com.zyd.blog.framework.object.AbstractService; +import org.springframework.web.context.request.ServletRequestAttributes; /** * @author yadong.zhang email:yadong.zhang0415(a)gmail.com @@ -23,5 +24,5 @@ public interface SysLogService extends AbstractService { */ PageInfo findPageBreakByCondition(LogConditionVO vo); - void asyncSaveSystemLog(PlatformEnum platform, String bussinessName); + void asyncSaveSystemLog(PlatformEnum platform, String bussinessName, ServletRequestAttributes servletRequestAttributes); } diff --git a/blog-core/src/main/java/com/zyd/blog/business/service/impl/SysLogServiceImpl.java b/blog-core/src/main/java/com/zyd/blog/business/service/impl/SysLogServiceImpl.java index 9defb040..68ec9cec 100644 --- a/blog-core/src/main/java/com/zyd/blog/business/service/impl/SysLogServiceImpl.java +++ b/blog-core/src/main/java/com/zyd/blog/business/service/impl/SysLogServiceImpl.java @@ -22,6 +22,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; import java.util.ArrayList; import java.util.Date; @@ -57,7 +59,9 @@ public PageInfo findPageBreakByCondition(LogConditionVO vo) { @Async @Override - public void asyncSaveSystemLog(PlatformEnum platform, String bussinessName) { + public void asyncSaveSystemLog(PlatformEnum platform, String bussinessName, ServletRequestAttributes servletRequestAttributes) { + RequestContextHolder.setRequestAttributes(servletRequestAttributes); + String ua = RequestUtil.getUa(); Log sysLog = new Log(); sysLog.setLogLevel(LogLevelEnum.INFO);