mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-11-04 08:06:12 +08:00 
			
		
		
		
	日志记录过滤特殊对象,防止转换异常
This commit is contained in:
		@ -2,6 +2,8 @@ package com.ruoyi.framework.aspectj;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.lang.reflect.Method;
 | 
					import java.lang.reflect.Method;
 | 
				
			||||||
import java.util.Map;
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					import javax.servlet.http.HttpServletRequest;
 | 
				
			||||||
 | 
					import javax.servlet.http.HttpServletResponse;
 | 
				
			||||||
import org.aspectj.lang.JoinPoint;
 | 
					import org.aspectj.lang.JoinPoint;
 | 
				
			||||||
import org.aspectj.lang.Signature;
 | 
					import org.aspectj.lang.Signature;
 | 
				
			||||||
import org.aspectj.lang.annotation.AfterReturning;
 | 
					import org.aspectj.lang.annotation.AfterReturning;
 | 
				
			||||||
@ -192,7 +194,7 @@ public class LogAspect
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            for (int i = 0; i < paramsArray.length; i++)
 | 
					            for (int i = 0; i < paramsArray.length; i++)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (!(paramsArray[i] instanceof MultipartFile))
 | 
					                if (!isFilterObject(paramsArray[i]))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Object jsonObj = JSON.toJSON(paramsArray[i]);
 | 
					                    Object jsonObj = JSON.toJSON(paramsArray[i]);
 | 
				
			||||||
                    params += jsonObj.toString() + " ";
 | 
					                    params += jsonObj.toString() + " ";
 | 
				
			||||||
@ -201,4 +203,15 @@ public class LogAspect
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        return params.trim();
 | 
					        return params.trim();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 判断是否需要过滤的对象。
 | 
				
			||||||
 | 
					     * 
 | 
				
			||||||
 | 
					     * @param o 对象信息。
 | 
				
			||||||
 | 
					     * @return 如果是需要过滤的对象,则返回true;否则返回false。
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public boolean isFilterObject(final Object o)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user