package com.ycl.aop;
|
|
import jakarta.annotation.Resource;
|
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.springframework.stereotype.Component;
|
|
@Aspect
|
@Component
|
@Slf4j
|
public class TimeAspect {
|
|
// 定义切点Pointcut
|
@Pointcut("execution(public * com.ycl..*.*Controller.*(..))")
|
public void excudeService() {
|
}
|
|
@Around("excudeService()")
|
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
|
long start=System.currentTimeMillis();
|
Object result = pjp.proceed();
|
long end=System.currentTimeMillis();
|
log.debug("接口总计耗时:{}ms",end-start);
|
return result;
|
}
|
}
|