refactor(operalog): 优化操作日志切面的时间间隔处理
This commit is contained in:
+6
-6
@@ -27,8 +27,8 @@ import cn.odboy.util.KitBrowserUtil;
|
|||||||
import cn.odboy.util.KitIPUtil;
|
import cn.odboy.util.KitIPUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
@@ -60,7 +60,8 @@ public class OperationLogAspect {
|
|||||||
TimeInterval timeInterval = new TimeInterval();
|
TimeInterval timeInterval = new TimeInterval();
|
||||||
try {
|
try {
|
||||||
Object result = joinPoint.proceed();
|
Object result = joinPoint.proceed();
|
||||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
long interval = timeInterval.interval();
|
||||||
|
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
|
||||||
ThreadUtil.execAsync(() -> {
|
ThreadUtil.execAsync(() -> {
|
||||||
try {
|
try {
|
||||||
systemOperationLogMapper.insert(record);
|
systemOperationLogMapper.insert(record);
|
||||||
@@ -70,7 +71,8 @@ public class OperationLogAspect {
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
long interval = timeInterval.interval();
|
||||||
|
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
|
||||||
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
||||||
ThreadUtil.execAsync(() -> {
|
ThreadUtil.execAsync(() -> {
|
||||||
try {
|
try {
|
||||||
@@ -83,9 +85,7 @@ public class OperationLogAspect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation,
|
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, long executeTime) {
|
||||||
TimeInterval timeInterval) {
|
|
||||||
long executeTime = timeInterval.intervalMs();
|
|
||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
String bizName = annotation.bizName();
|
String bizName = annotation.bizName();
|
||||||
if (StrUtil.isBlank(bizName)) {
|
if (StrUtil.isBlank(bizName)) {
|
||||||
|
|||||||
+5
-5
@@ -60,7 +60,8 @@ public class OperationLogAspect {
|
|||||||
TimeInterval timeInterval = new TimeInterval();
|
TimeInterval timeInterval = new TimeInterval();
|
||||||
try {
|
try {
|
||||||
Object result = joinPoint.proceed();
|
Object result = joinPoint.proceed();
|
||||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
long interval = timeInterval.interval();
|
||||||
|
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
|
||||||
ThreadUtil.execAsync(() -> {
|
ThreadUtil.execAsync(() -> {
|
||||||
try {
|
try {
|
||||||
systemOperationLogMapper.insert(record);
|
systemOperationLogMapper.insert(record);
|
||||||
@@ -70,7 +71,8 @@ public class OperationLogAspect {
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
long interval = timeInterval.interval();
|
||||||
|
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
|
||||||
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
||||||
ThreadUtil.execAsync(() -> {
|
ThreadUtil.execAsync(() -> {
|
||||||
try {
|
try {
|
||||||
@@ -83,9 +85,7 @@ public class OperationLogAspect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation,
|
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, long executeTime) {
|
||||||
TimeInterval timeInterval) {
|
|
||||||
long executeTime = timeInterval.intervalMs();
|
|
||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
String bizName = annotation.bizName();
|
String bizName = annotation.bizName();
|
||||||
if (StrUtil.isBlank(bizName)) {
|
if (StrUtil.isBlank(bizName)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user