From 985f56c3cf4f94119be28430cde83b578539b2ee Mon Sep 17 00:00:00 2001 From: liuxm <liuxm@fescotech.com> Date: 星期三, 24 四月 2024 14:04:32 +0800 Subject: [PATCH] 日志管理相关修改 --- pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-) diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java index 0902667..62d2281 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java @@ -45,21 +45,23 @@ @AfterReturning(pointcut = "@annotation(com.dy.pmsGlobal.aop.Log)", returning = "result") public void logAfterReturning(JoinPoint joinPoint, Object result) { - // 鑾峰彇鏂规硶鐨勪腑鏂囨弿杩� - MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); - Log operationDescription = methodSignature.getMethod().getAnnotation(Log.class); - String operationName = operationDescription.value(); //缁撴灉 - BaseResponse response = (BaseResponse)result; - response.isSuccess(); + BaseResponse res = (BaseResponse)result; + res.isSuccess(); // 鑾峰彇鐢ㄦ埛淇℃伅 - BaUser user = (BaUser)getCurUser(response); - Long operator = user!=null?user.id: 1l; + BaUser user = (BaUser)getCurUser(res); + if(user!=null){ + Long operator = user.id; + // 鑾峰彇鏂规硶鐨勪腑鏂囨弿杩� + MethodSignature sign = (MethodSignature) joinPoint.getSignature(); + Log logDesc = sign.getMethod().getAnnotation(Log.class); + String operationName = logDesc.value(); + // 鑾峰彇IP鍦板潃 + String ip = getRemoteHost(); + // 璁板綍鏃ュ織 + logSv.save(operator, operationName,ip); + } - // 鑾峰彇IP鍦板潃 - String ipAddress = getRemoteHost(); - // 璁板綍鏃ュ織 - logSv.save(operator, operationName,ipAddress); } /** -- Gitblit v1.8.0