//package com.scpyun.platform.jilinsscgsdp.aspect;
//
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//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 javax.servlet.http.HttpServletRequest;
//
///**
// * @Author liu
// * @Date 2025/1/2 13:24
// * @PackageName:com.scpyun.platform.jilinsscgsdp.aspect
// * @ClassName: AopLog
// * @Description: TODO
// * @Version 1.0
// */
//
//@Aspect
//@Component
//public class AopLog {
//    private Logger logger = LoggerFactory.getLogger(this.getClass());
//    ThreadLocal<Long> startTime = new ThreadLocal<>();
//    //定义切点
//    @Pointcut(value = "execution(* com.scpyun.platform.jilinsscgsdp.service.impl.*.*(..))")
////    @Pointcut(value = "execution(* com.scpyun.platform.jilinsscgsdp.service.impl..*.*(..))")
//    public void aopWebLog() {
//    }
//    //使用环绕通知
//    @Around("aopWebLog()")
//    public Object myLogger(ProceedingJoinPoint pjp) throws Throwable {
//        startTime.set(System.currentTimeMillis());
//        //使用ServletRequestAttributes请求上下文获取方法更多
//        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        HttpServletRequest request = attributes.getRequest();
//        String className = pjp.getSignature().getDeclaringTypeName();
//        String methodName = pjp.getSignature().getName();
//        //使用数组来获取参数
//        Object[] array = pjp.getArgs();
//        ObjectMapper mapper = new ObjectMapper();
//        //执行函数前打印日志
//        logger.info("调用前：{}：{},传递的参数为：{}", className, methodName, mapper.writeValueAsString(array));
//        logger.info("URL:{}", request.getRequestURL().toString());
//        logger.info("IP地址：{}", request.getRemoteAddr());
//        //调用整个目标函数执行
//        Object obj = pjp.proceed();
//        //执行函数后打印日志
//        logger.info("调用后：{}：{},返回值为：{}", className, methodName, mapper.writeValueAsString(obj));
//        logger.info("耗时：{}ms", System.currentTimeMillis() - startTime.get());
//        return obj;
//    }
//}
