tianwu.sun hai 9 meses
pai
achega
fa024f41b1

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

@@ -4,15 +4,13 @@ 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;
+
 
 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;
 import org.aspectj.lang.annotation.Aspect;
@@ -21,11 +19,9 @@ import org.aspectj.lang.reflect.MethodSignature;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
 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.system.domain.UserDO;
 
@@ -54,7 +50,8 @@ public class LogAspect {
         return result;
     }
 
-    void saveLog(ProceedingJoinPoint joinPoint, long time) throws InterruptedException {
+    void saveLog(ProceedingJoinPoint joinPoint, long time) throws Exception {
+
         MethodSignature signature = (MethodSignature) joinPoint.getSignature();
         Method method = signature.getMethod();
         LogDO sysLog = new LogDO();
@@ -67,6 +64,7 @@ public class LogAspect {
         String className = joinPoint.getTarget().getClass().getName();
         String methodName = signature.getName();
         sysLog.setMethod(className + "." + methodName + "()");
+        sysLog.setSysFlag(1);
 
         // 请求的参数
         Object[] args = joinPoint.getArgs();
@@ -74,7 +72,7 @@ public class LogAspect {
         for (int i = 0, len = args.length; i < len; ++i) {
             params.put("p" + (i + 1), args[i]);
         }
-        sysLog.setParams(JSONUtils.beanToJson(params));
+        sysLog.setParams(JsonUtil.toJson(params));
 
         // 获取request
         HttpServletRequest request = HttpContextUtils.getHttpServletRequest();

+ 12 - 0
src/main/java/com/bootdo/common/domain/LogDO.java

@@ -1,6 +1,7 @@
 package com.bootdo.common.domain;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
 
 import java.util.Date;
 
@@ -23,6 +24,8 @@ public class LogDO {
 	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
 	private Date gmtCreate;
 
+	private Integer sysFlag;
+
 	public Long getId() {
 		return id;
 	}
@@ -95,6 +98,14 @@ public class LogDO {
 		this.gmtCreate = gmtCreate;
 	}
 
+	public Integer getSysFlag() {
+		return sysFlag;
+	}
+
+	public void setSysFlag(Integer sysFlag) {
+		this.sysFlag = sysFlag;
+	}
+
 	@Override
 	public String toString() {
 		return "LogDO{" +
@@ -107,6 +118,7 @@ public class LogDO {
 				", params='" + params + '\'' +
 				", ip='" + ip + '\'' +
 				", gmtCreate=" + gmtCreate +
+				", sysFlag=" + sysFlag +
 				'}';
 	}
 }

+ 4 - 2
src/main/resources/mybatis/common/LogMapper.xml

@@ -58,7 +58,8 @@
 			`method`, 
 			`params`, 
 			`ip`, 
-			`gmt_create`
+			`gmt_create`,
+			`sys_flag`
 		)
 		values
 		(
@@ -69,7 +70,8 @@
 			#{method}, 
 			#{params}, 
 			#{ip}, 
-			#{gmtCreate}
+			#{gmtCreate},
+			#{sysFlag}
 		)
 	</insert>