加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

SpringBoot基础-AOP

(2022-05-15 19:16:33)
分类: JAVA开发

AOP



SpringBoot基础-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]));
            }
        }

0

阅读 收藏 喜欢 打印举报/Report
前一篇:JAVA基础-2022
后一篇:linux命令-route
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有