Fancy
2025-01-07 28f6317f7189d5c4a7e64f57dd6c7fc2011f8632
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java
@@ -34,6 +34,8 @@
    public String SsoCurUserUrl ;
    private LogService logSv;
    @Value("${pms.global.dev}")
    public String isDevStage ;//是否为开发阶段
    @Autowired
    public void setLogSv(LogService logSv){
        this.logSv = logSv;
@@ -46,11 +48,13 @@
    @AfterReturning(pointcut = "@annotation(com.dy.pmsGlobal.aop.Log)", returning = "result")
    public void logAfterReturning(JoinPoint joinPoint, BaseResponse result) {
        if(isDevStage != null && !isDevStage.trim().equals("") && isDevStage.trim().equalsIgnoreCase("true")){
            return;
        }
        try{
            // 获取用户信息
            BaUser user = (BaUser)getCurUser(result);
            if(user!=null && user.id !=null && !StringUtils.isNullOrEmpty(user.name)){
                Long operator = user.id;
                // 获取方法的中文描述
                MethodSignature sign = (MethodSignature) joinPoint.getSignature();
                Log logDesc = sign.getMethod().getAnnotation(Log.class);
@@ -58,7 +62,11 @@
                // 获取IP地址
                String ip = getRemoteHost();
                // 记录日志
                logSv.save(operator, operationName,ip,result.getCode(),result.getMsg());
                //msg  方法名 + 参数值 + 返回值
//                Stream.of(joinPoint.getArgs()).forEach(System.out::println);
//                String args = JSONObject.toJSONString(joinPoint.getArgs());
                //String args1 = Arrays.toString(joinPoint.getArgs());
                logSv.save(user.id,user.name, operationName,ip,result.getCode(),result.getMsg());
            }
        }catch (Exception e){
            log.error("记录日志异常:"+e.getMessage());