tianwu.sun hai 9 meses
pai
achega
d0b376e3af
Modificáronse 1 ficheiros con 9 adicións e 9 borrados
  1. 9 9
      src/main/java/com/bootdo/common/aspect/LogAspect.java

+ 9 - 9
src/main/java/com/bootdo/common/aspect/LogAspect.java

@@ -2,6 +2,8 @@ package com.bootdo.common.aspect;
 
 import java.lang.reflect.Method;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
@@ -9,6 +11,7 @@ import java.util.concurrent.TimeUnit;
 import javax.servlet.http.HttpServletRequest;
 
 import com.bootdo.common.service.LogService;
+import com.bootdo.common.utils.*;
 import com.bootdo.system.domain.UserToken;
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.Around;
@@ -24,10 +27,6 @@ import org.springframework.stereotype.Component;
 import com.bootdo.common.annotation.Log;
 import com.bootdo.common.dao.LogDao;
 import com.bootdo.common.domain.LogDO;
-import com.bootdo.common.utils.HttpContextUtils;
-import com.bootdo.common.utils.IPUtils;
-import com.bootdo.common.utils.JSONUtils;
-import com.bootdo.common.utils.ShiroUtils;
 import com.bootdo.system.domain.UserDO;
 
 @Aspect
@@ -68,14 +67,15 @@ public class LogAspect {
         String className = joinPoint.getTarget().getClass().getName();
         String methodName = signature.getName();
         sysLog.setMethod(className + "." + methodName + "()");
+
         // 请求的参数
         Object[] args = joinPoint.getArgs();
-        try {
-            String params = JSONUtils.beanToJson(args[0]).substring(0, 4999);
-            sysLog.setParams(params);
-        } catch (Exception e) {
-
+        Map<String, Object> params = new HashMap<>();
+        for (int i = 0, len = args.length; i < len; ++i) {
+            params.put("p" + (i + 1), args[i]);
         }
+        sysLog.setParams(JSONUtils.beanToJson(params));
+
         // 获取request
         HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
         // 设置IP地址