@Aspect
@Component
public class SystemLogAspect {
@Pointcut("@annotation(com.doctor.common.annotation.SystemLog)")
public void test() {
// 下面的doAfter方法,会在调用当前方法之后被调用;
System.out.println("test");
}
@Before("test()")
public void doBefore(JoinPoint joinPoint) {
}
@After("test()")
public void doAfter(JoinPoint joinPoint) {
// 注解的时候,会在被调用的方法调用之后再调用
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String ip = request.getRemoteAddr();// IP地址
getControllerMethodDescription(joinPoint);
}
@SuppressWarnings("rawtypes")
private static String getControllerMethodDescription(JoinPoint joinPoint) {