refactor(operalog): 优化操作日志切面类代码结构
- 在方法调用前添加this关键字明确对象引用
This commit is contained in:
+5
-7
@@ -52,18 +52,16 @@ public class OperationLogAspect {
|
|||||||
private SystemOperationLogMapper systemOperationLogMapper;
|
private SystemOperationLogMapper systemOperationLogMapper;
|
||||||
|
|
||||||
@Around("@annotation(operationLog)")
|
@Around("@annotation(operationLog)")
|
||||||
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog)
|
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) throws Throwable {
|
||||||
throws Throwable {
|
return this.handleLog(joinPoint, operationLog);
|
||||||
return handleLog(joinPoint, operationLog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object handleLog(ProceedingJoinPoint joinPoint, OperationLog annotation)
|
private Object handleLog(ProceedingJoinPoint joinPoint, OperationLog annotation) throws Throwable {
|
||||||
throws Throwable {
|
|
||||||
TimeInterval timeInterval = new TimeInterval();
|
TimeInterval timeInterval = new TimeInterval();
|
||||||
try {
|
try {
|
||||||
Object result = joinPoint.proceed();
|
Object result = joinPoint.proceed();
|
||||||
long interval = timeInterval.interval();
|
long interval = timeInterval.interval();
|
||||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
|
SystemOperationLogTb record = this.getOperationLogTb(joinPoint, annotation, interval);
|
||||||
ThreadUtil.execAsync(
|
ThreadUtil.execAsync(
|
||||||
() -> {
|
() -> {
|
||||||
try {
|
try {
|
||||||
@@ -75,7 +73,7 @@ public class OperationLogAspect {
|
|||||||
return result;
|
return result;
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
long interval = timeInterval.interval();
|
long interval = timeInterval.interval();
|
||||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
|
SystemOperationLogTb record = this.getOperationLogTb(joinPoint, annotation, interval);
|
||||||
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
||||||
ThreadUtil.execAsync(
|
ThreadUtil.execAsync(
|
||||||
() -> {
|
() -> {
|
||||||
|
|||||||
+6
-9
@@ -52,18 +52,16 @@ public class OperationLogAspect {
|
|||||||
private SystemOperationLogMapper systemOperationLogMapper;
|
private SystemOperationLogMapper systemOperationLogMapper;
|
||||||
|
|
||||||
@Around("@annotation(operationLog)")
|
@Around("@annotation(operationLog)")
|
||||||
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog)
|
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) throws Throwable {
|
||||||
throws Throwable {
|
return this.handleLog(joinPoint, operationLog);
|
||||||
return handleLog(joinPoint, operationLog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object handleLog(ProceedingJoinPoint joinPoint, OperationLog annotation)
|
private Object handleLog(ProceedingJoinPoint joinPoint, OperationLog annotation) throws Throwable {
|
||||||
throws Throwable {
|
|
||||||
TimeInterval timeInterval = new TimeInterval();
|
TimeInterval timeInterval = new TimeInterval();
|
||||||
try {
|
try {
|
||||||
Object result = joinPoint.proceed();
|
Object result = joinPoint.proceed();
|
||||||
long interval = timeInterval.interval();
|
long interval = timeInterval.interval();
|
||||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
|
SystemOperationLogTb record = this.getOperationLogTb(joinPoint, annotation, interval);
|
||||||
ThreadUtil.execAsync(
|
ThreadUtil.execAsync(
|
||||||
() -> {
|
() -> {
|
||||||
try {
|
try {
|
||||||
@@ -75,7 +73,7 @@ public class OperationLogAspect {
|
|||||||
return result;
|
return result;
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
long interval = timeInterval.interval();
|
long interval = timeInterval.interval();
|
||||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
|
SystemOperationLogTb record = this.getOperationLogTb(joinPoint, annotation, interval);
|
||||||
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
||||||
ThreadUtil.execAsync(
|
ThreadUtil.execAsync(
|
||||||
() -> {
|
() -> {
|
||||||
@@ -89,8 +87,7 @@ public class OperationLogAspect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SystemOperationLogTb getOperationLogTb(
|
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, long executeTime) {
|
||||||
ProceedingJoinPoint joinPoint, OperationLog annotation, long executeTime) {
|
|
||||||
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