/*
package cn.exploring.engine.server.wx.config;

import com.alibaba.fastjson.JSONObject;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

@Aspect
@Component
public class WebLogAspect {
    private final static Logger logger = LoggerFactory.getLogger(WebLogAspect.class);

    */
/** 以 controller 包下定义的所有请求为切入点 *//*

    @Pointcut("execution(public * cn.exploring.engine.server.wx.web..*.*(..))")
    public void webLog() {}

    */
/**
     * 在切点之前织入
     * @param joinPoint
     * @throws Throwable
     *//*

    @Before("webLog()")
    public void doBefore(JoinPoint joinPoint) throws Throwable {
        // 开始打印请求日志
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();

        // 打印请求相关参数
        System.out.println("========================================== Start ==========================================");
        // 打印请求 url
        System.out.println("URL            : {" + request.getRequestURL().toString() + "}");
        // 打印 Http method
        // System.out.println("HTTP Method    : {" + request.getMethod() + "}");
        // 打印调用 controller 的全路径以及执行方法
        System.out.println("Class Method   : {" + joinPoint.getSignature().getDeclaringTypeName() + "}.{" + joinPoint.getSignature().getName() + "}");
        // 打印请求的 IP
        // System.out.println("IP             : {" + request.getRemoteAddr() + "}");
        // 打印请求入参
        System.out.println("Request Args   : {" + args2Str(joinPoint) + "}");
    }

    */
/**
     * 过滤掉JoinPoint中不能序列化的信息,并将有用参数序列化
     * @param joinPoint
     * @return
     *//*

    private String args2Str(JoinPoint joinPoint) {
        String result = "";

        Object[] args = joinPoint.getArgs();
        if (args != null || args.length > 0) {
            Object[] arguments  = new Object[args.length];
            for (int i = 0; i < args.length; i++) {
                if (args[i] instanceof ServletRequest || args[i] instanceof ServletResponse || args[i] instanceof MultipartFile) {
                    //ServletRequest不能序列化，从入参里排除，否则报异常：java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
                    //ServletResponse不能序列化 从入参里排除，否则报异常：java.lang.IllegalStateException: getOutputStream() has already been called for this response
                    continue;
                }
                arguments[i] = args[i];
            }

            if (arguments != null) {
                try {
                    result = JSONObject.toJSONString(arguments);
                } catch (Exception e) {
                    result = arguments.toString();
                }
            }
        }

        return result;
    }

    */
/**
     * 在切点之后织入
     * @throws Throwable
     *//*

    @After("webLog()")
    public void doAfter() throws Throwable {
        System.out.println("=========================================== End ===========================================");
        // 每个请求之间空一行
        System.out.println("");
    }

    */
/**
     * 环绕
     * @param proceedingJoinPoint
     * @return
     * @throws Throwable
     *//*

    @Around("webLog()")
    public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        long startTime = System.currentTimeMillis();
        Object result = proceedingJoinPoint.proceed();
        // 打印出参
        // System.out.println("Response Args  : {" + result + "}");
        // 执行耗时
        System.out.println("Time-Consuming : { " + (System.currentTimeMillis() - startTime) + "} ms");
        return result;
    }

}
*/
