feat: 添加日志,后面准备拆分

This commit is contained in:
lirui
2025-11-24 17:37:37 +08:00
parent 00c2fffad1
commit 122a1738bd
4 changed files with 63 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
package cn.meowrain.aioj.backend.framework.annotation;
import java.lang.annotation.*;
/**
* 系统日志注解
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface SysLog {
/**
* 描述
* @return {@link String}
*/
String value() default "";
/**
* Spel表达式
* @return 日志描述
*/
String expression() default "";
}

View File

@@ -0,0 +1,32 @@
package cn.meowrain.aioj.backend.framework.aspect;
import cn.hutool.core.util.StrUtil;
import cn.meowrain.aioj.backend.framework.annotation.SysLog;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.expression.EvaluationContext;
@Aspect
@Slf4j
@RequiredArgsConstructor
public class SysLogAspect {
@Around("@annotation(sysLog)")
public Object around(ProceedingJoinPoint joinPoint,SysLog sysLog) throws Throwable {
String strClassName = joinPoint.getTarget().getClass().getName();
String strMethodName = joinPoint.getSignature().getName();
log.debug("[类名]:{},[方法]:{}", strClassName, strMethodName);
String value = sysLog.value();
String expression = sysLog.expression();
if(StrUtil.isNotBlank(expression)) {
// 解析SPEL
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
EvaluationContext context = SysLogUtils.getContext(point.getArgs(), signature.getMethod());
}
}
}

View File

@@ -0,0 +1,4 @@
package cn.meowrain.aioj.backend.framework.log.utils;
public class SysLogUtils {
}