打印sql参数把base64长度超过5000的隐藏
This commit is contained in:
parent
74beb49df3
commit
9c4b8564e4
|
@ -19,10 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: SqlLogInterceptor
|
* @ClassName: SqlLogInterceptor
|
||||||
|
@ -159,7 +156,15 @@ public class SqlLogInterceptor implements Interceptor {
|
||||||
private String getParameterValue(Object obj) {
|
private String getParameterValue(Object obj) {
|
||||||
String value;
|
String value;
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
|
if (((String) obj).length() < 5000){
|
||||||
value = "'" + obj.toString() + "'";
|
value = "'" + obj.toString() + "'";
|
||||||
|
}else {
|
||||||
|
if (!isBase64((String) obj)){
|
||||||
|
value = "'" + obj.toString() + "'";
|
||||||
|
}else {
|
||||||
|
value = "'" +"base64"+ "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (obj instanceof Date) {
|
} else if (obj instanceof Date) {
|
||||||
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.CHINA);
|
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.CHINA);
|
||||||
value = "'" + formatter.format(obj) + "'";
|
value = "'" + formatter.format(obj) + "'";
|
||||||
|
@ -172,4 +177,23 @@ public class SqlLogInterceptor implements Interceptor {
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断一个字符串是否是Base64编码
|
||||||
|
*
|
||||||
|
* @param str 输入的字符串
|
||||||
|
* @return 如果是Base64编码返回true,否则返回false
|
||||||
|
*/
|
||||||
|
public static boolean isBase64(String str) {
|
||||||
|
try {
|
||||||
|
// 尝试对字符串进行Base64解码
|
||||||
|
byte[] decodedBytes = Base64.getDecoder().decode(str);
|
||||||
|
// 解码成功,返回true
|
||||||
|
return true;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// 捕获异常,返回false
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue