refactor(operalog): 优化操作日志切面类代码结构

- 在方法调用前添加this关键字明确对象引用
This commit is contained in:
2026-02-25 16:03:36 +08:00
parent 6d486c5ba6
commit a78b1d9e08
2 changed files with 11 additions and 16 deletions
@@ -52,18 +52,16 @@ public class OperationLogAspect {
private SystemOperationLogMapper systemOperationLogMapper;
@Around("@annotation(operationLog)")
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog)
throws Throwable {
return handleLog(joinPoint, operationLog);
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) throws Throwable {
return this.handleLog(joinPoint, operationLog);
}
private Object handleLog(ProceedingJoinPoint joinPoint, OperationLog annotation)
throws Throwable {
private Object handleLog(ProceedingJoinPoint joinPoint, OperationLog annotation) throws Throwable {
TimeInterval timeInterval = new TimeInterval();
try {
Object result = joinPoint.proceed();
long interval = timeInterval.interval();
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
SystemOperationLogTb record = this.getOperationLogTb(joinPoint, annotation, interval);
ThreadUtil.execAsync(
() -> {
try {
@@ -75,7 +73,7 @@ public class OperationLogAspect {
return result;
} catch (Throwable exception) {
long interval = timeInterval.interval();
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
SystemOperationLogTb record = this.getOperationLogTb(joinPoint, annotation, interval);
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
ThreadUtil.execAsync(
() -> {
@@ -52,18 +52,16 @@ public class OperationLogAspect {
private SystemOperationLogMapper systemOperationLogMapper;
@Around("@annotation(operationLog)")
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog)
throws Throwable {
return handleLog(joinPoint, operationLog);
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) throws Throwable {
return this.handleLog(joinPoint, operationLog);
}
private Object handleLog(ProceedingJoinPoint joinPoint, OperationLog annotation)
throws Throwable {
private Object handleLog(ProceedingJoinPoint joinPoint, OperationLog annotation) throws Throwable {
TimeInterval timeInterval = new TimeInterval();
try {
Object result = joinPoint.proceed();
long interval = timeInterval.interval();
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
SystemOperationLogTb record = this.getOperationLogTb(joinPoint, annotation, interval);
ThreadUtil.execAsync(
() -> {
try {
@@ -75,7 +73,7 @@ public class OperationLogAspect {
return result;
} catch (Throwable exception) {
long interval = timeInterval.interval();
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, interval);
SystemOperationLogTb record = this.getOperationLogTb(joinPoint, annotation, interval);
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
ThreadUtil.execAsync(
() -> {
@@ -89,8 +87,7 @@ public class OperationLogAspect {
}
}
private SystemOperationLogTb getOperationLogTb(
ProceedingJoinPoint joinPoint, OperationLog annotation, long executeTime) {
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, long executeTime) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
String bizName = annotation.bizName();
if (StrUtil.isBlank(bizName)) {