@Aspect
@Component
public class DoneTimeAspect {
@Around("@annotation(doneTime)")
public Object around(ProceedingJoinPoint joinPoint, DoneTime doneTime) throws Throwable {
System.out.println("吃提交");
System.out.println("方法开始时间是:"+new Date());
System.out.println("方法结束时间是:"+new Date()) ;
// 拦截的方法名称。当前正在执行的方法
String methodName = joinPoint.getSignature().getName();
// 拦截的方法参数
Object[] args = joinPoint.getArgs();
// for ()
// Object proceed = joinPoint.proceed();
return null;
}
}
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface DoneTime {
String param() default "";
}
@RestController
@RequestMapping("u")
@Api("Hellow 简单测试")
public class HelloController {
@Autowired
UserService usersService;
@GetMapping("/hello")
@DoneTime
public void hello(){
System.out.println("呵呵");
}
}