AOP
@Component
@Aspect
@Slf4j
public class ParameterInterceptor {
@Autowired
private
HttpServletRequest request;
@Around(value = "execution (* com.sjyl.app.*.controller.*.*(..))
")
public
Object aroundMethod(ProceedingJoinPoint proceedingJoinPoint) throws
Throwable {
if (log.isInfoEnabled()) {
Object[] args = proceedingJoinPoint.getArgs();
if (args.length == 0) {
return proceedingJoinPoint.proceed();
}
Signature sig = proceedingJoinPoint.getSignature();
MethodSignature msig = (MethodSignature) sig;
Object target = proceedingJoinPoint.getTarget();
Method currentMethod = target.getClass().getMethod(msig.getName(),
msig.getParameterTypes());
if (checkApi(currentMethod)) {
log.info("接口:{}.{},ip:{},请求参数:{}",
currentMethod.getDeclaringClass().getName(),
currentMethod.getName(), IpUtil.getIp(request),
JsonSerializer.serialize(args[0]));
}
}
加载中,请稍候......