parent
c70d83f29f
commit
9ee9f820dc
@ -1,4 +1,4 @@
|
||||
package com.xjs.translation;
|
||||
package com.xjs;
|
||||
|
||||
import com.ruoyi.common.security.annotation.EnableCustomConfig;
|
||||
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
|
@ -0,0 +1,31 @@
|
||||
package com.xjs.log.aop;
|
||||
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.log.enums.OperatorType;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author xiejs
|
||||
* @desc 自定义api日志注解
|
||||
* @create 2021-12-26
|
||||
*/
|
||||
@Target({ ElementType.PARAMETER, ElementType.METHOD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface ApiLog {
|
||||
/**
|
||||
* api名称
|
||||
*/
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* 请求url
|
||||
*/
|
||||
public String url() default "";
|
||||
|
||||
/**
|
||||
* 请求方法
|
||||
*/
|
||||
public String method() default "Post";
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.xjs.log.aop;
|
||||
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.Signature;
|
||||
import org.aspectj.lang.annotation.*;
|
||||
import org.aspectj.lang.reflect.SourceLocation;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author xiejs
|
||||
* @desc
|
||||
* @create 2021-12-26
|
||||
*/
|
||||
@Component
|
||||
@Aspect
|
||||
public class ApiLogAspect {
|
||||
|
||||
/**
|
||||
* 处理完请求后执行
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
*/
|
||||
@AfterReturning(pointcut = "@annotation(apiLog)", returning = "jsonResult")
|
||||
public void doAfterReturning(JoinPoint joinPoint, ApiLog apiLog, Object jsonResult)
|
||||
{
|
||||
this.handleApiLog(joinPoint, apiLog, null, jsonResult);
|
||||
}
|
||||
|
||||
|
||||
@AfterThrowing(value = "@annotation(apiLog)", throwing = "e")
|
||||
public void doAfterThrowing(JoinPoint joinPoint, ApiLog apiLog, Exception e)
|
||||
{
|
||||
handleApiLog(joinPoint, apiLog, e, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void handleApiLog(JoinPoint joinPoint, ApiLog apiLog, final Exception e, Object jsonResult) {
|
||||
String name = apiLog.name();//请求名称
|
||||
String url = apiLog.url();//请求地址
|
||||
Object[] args = joinPoint.getArgs();//请求体
|
||||
for (Object arg : args) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue