龚焕茏
2024-04-17 1de0d92e2a630927f391ae080709ae678e5f5618
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;
    }
}