From 50a862870d6945c8b69adfb283826b84abeb236b Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期三, 03 四月 2024 16:56:47 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java | 58 +++++++++++++++++++++++++++++++++-------------------------
1 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java
index 3e11121..7454ef6 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java
@@ -4,9 +4,9 @@
import com.zy.asrs.common.utils.IpTools;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.wcs.common.annotation.OperationLog;
-import com.zy.asrs.wcs.sys.entity.OperationRecord;
-import com.zy.asrs.wcs.sys.entity.User;
-import com.zy.asrs.wcs.sys.service.OperationRecordService;
+import com.zy.asrs.wcs.system.entity.OperationRecord;
+import com.zy.asrs.wcs.system.entity.User;
+import com.zy.asrs.wcs.system.service.OperationRecordService;
import com.zy.asrs.wcs.utils.Utils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
@@ -23,6 +23,7 @@
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -66,8 +67,23 @@
* 淇濆瓨鎿嶄綔璁板綍
*/
private void saveLog(JoinPoint joinPoint, Object result, Exception e) {
+ // 璁板綍妯″潡鍚嶃�佹搷浣滃姛鑳姐�佽姹傛柟娉曘�佽姹傚弬鏁般�佽繑鍥炵粨鏋�
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ Method method = signature.getMethod();
+ if (null == method) {
+ return;
+ }
+ OperationLog ol = method.getAnnotation(OperationLog.class);
+ if (null == ol) {
+ return;
+ }
+ String desc = getDescription(method, ol);
+ if (Cools.isEmpty(desc)) {
+ return;
+ }
OperationRecord record = new OperationRecord();
Long endTime = startTime.get();
+ record.setCreateTime(new Date());
// 璁板綍鎿嶄綔鑰楁椂
if (endTime != null) {
record.setSpendTime((int) (System.currentTimeMillis() - endTime));
@@ -77,7 +93,7 @@
User user = getLoginUser();
if (user != null) {
record.setUserId(user.getId());
- record.setHostId(user.getHostId());
+// record.setHostId(user.getHostId());
}
// 璁板綍璇锋眰鍦板潃銆佽姹傛柟寮忋�乮p
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
@@ -93,27 +109,19 @@
} else {
record.setResult(1);
}
- // 璁板綍妯″潡鍚嶃�佹搷浣滃姛鑳姐�佽姹傛柟娉曘�佽姹傚弬鏁般�佽繑鍥炵粨鏋�
- MethodSignature signature = (MethodSignature) joinPoint.getSignature();
- Method method = signature.getMethod();
- if (method != null) {
- OperationLog ol = method.getAnnotation(OperationLog.class);
- if (ol != null) {
- // 璁板綍鎿嶄綔鍔熻兘
- record.setNamespace(getDescription(method, ol));
- // 璁板綍澶囨敞
- if (!Cools.isEmpty(ol.comments())) {
- record.setMemo(ol.comments());
- }
- // 璁板綍璇锋眰鍙傛暟
- if (ol.param() && request != null) {
- record.setRequest(Utils.sub(getParams(joinPoint, request), MAX_LENGTH));
- }
- // 璁板綍璇锋眰缁撴灉
- if (ol.result() && result != null) {
- record.setResponse(Utils.sub(JSON.toJSONString(result), MAX_LENGTH));
- }
- }
+ // 璁板綍鎿嶄綔鍔熻兘
+ record.setNamespace(desc);
+ // 璁板綍澶囨敞
+ if (!Cools.isEmpty(ol.comments())) {
+ record.setMemo(ol.comments());
+ }
+ // 璁板綍璇锋眰鍙傛暟
+ if (ol.param() && request != null) {
+ record.setRequest(Utils.sub(getParams(joinPoint, request), MAX_LENGTH));
+ }
+ // 璁板綍璇锋眰缁撴灉
+ if (ol.result() && result != null) {
+ record.setResponse(Utils.sub(JSON.toJSONString(result), MAX_LENGTH));
}
operationRecordService.saveAsync(record);
}
--
Gitblit v1.9.1