class WebAspectConfig {
    private final Logger logger = LoggerFactory.getLogger(WebAspectConfig.class);

    /**
     * @return void
     * @author ZhouYiXun
     * @des 定义切点，注解类webAspect
     * @date 2021/8/15 23:08
     */
    @Pointcut("@annotation(WebAspect)")
    public void webAspect() {
    }

    /**
     * @param joinPoint
     * @return void
     * @author ZhouYiXun
     * @des 请求前获取所有信息
     * @date 2021/8/15 23:08
     */
    @Before("webAspect()")
    public void deBefore(JoinPoint joinPoint) throws Throwable {<FILL_FUNCTION_BODY>}

    /**
     * @param ret
     * @return void
     * @author ZhouYiXun
     * @des 请求完毕后打印结果
     * @date 2021/8/15 23:10
     */
    @AfterReturning(returning = "ret", pointcut = "webAspect()")
    public void doAfterReturning(Object ret) throws Throwable {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("response", ret);
        logger.info(jsonObject.toJSONString());
    }

    /**
     * @param joinPoint
     * @param ex
     * @return void
     * @author ZhouYiXun
     * @des 报错的话打印错误信息
     * @date 2021/8/15 23:11
     */
    @AfterThrowing(throwing = "ex", pointcut = "webAspect()")
    public void error(JoinPoint joinPoint, Exception ex) {
        logger.info("error : " + ex.getMessage());
    }

}

        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        //默认打印为json格式，接入elasticsearch等会方便查看
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("url", request.getRequestURL().toString());
        jsonObject.put("method", request.getMethod());
        jsonObject.put("auth", request.getHeader("SonicToken"));
        jsonObject.put("class", joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
        jsonObject.put("request", Arrays.toString(joinPoint.getArgs()));
        logger.info(jsonObject.toJSONString());
    
<no_super_class>