feat: 添加日志,后面准备拆分
This commit is contained in:
@@ -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 "";
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package cn.meowrain.aioj.backend.framework.log.utils;
|
||||
|
||||
public class SysLogUtils {
|
||||
}
|
||||
Reference in New Issue
Block a user