Sonar代码问题修改

This commit is contained in:
liuzhaotian
2024-10-29 17:19:05 +08:00
parent 334536bd03
commit 2239cfb84f
15 changed files with 138 additions and 166 deletions
@@ -226,7 +226,7 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
processOtherFromItem((FromItem) where);
return;
}
if (where.toString().indexOf("SELECT") > 0) {
if (where.toString().indexOf("SELECT") >= 1) {
// 有子查询
if (where instanceof BinaryExpression) {
// 比较符号 , and , or , 等等
@@ -167,39 +167,13 @@ public class OperateLogAspect {
ProceedingJoinPoint joinPoint,
com.cf.imes.framework.operatelog.core.annotations.OperateLog operateLog,
Operation operation) {
// module 属性
if (operateLog != null) {
operateLogObj.setModule(operateLog.module());
}
if (CharSequenceUtil.isEmpty(operateLogObj.getModule())) {
Tag tag = getClassAnnotation(joinPoint, Tag.class);
if (tag != null) {
// 优先读取 @Tag 的 name 属性
if (CharSequenceUtil.isNotEmpty(tag.name())) {
operateLogObj.setModule(tag.name());
}
// 没有的话,读取 @API 的 description 属性
if (CharSequenceUtil.isEmpty(operateLogObj.getModule()) && ArrayUtil.isNotEmpty(tag.description())) {
operateLogObj.setModule(tag.description());
}
}
}
// name 属性
if (operateLog != null) {
operateLogObj.setName(operateLog.name());
}
if (CharSequenceUtil.isEmpty(operateLogObj.getName()) && operation != null) {
operateLogObj.setName(operation.summary());
}
// type 属性
if (operateLog != null && ArrayUtil.isNotEmpty(operateLog.type())) {
operateLogObj.setType(operateLog.type()[0].getType());
}
if (operateLogObj.getType() == null) {
RequestMethod requestMethod = obtainFirstMatchRequestMethod(obtainRequestMethod(joinPoint));
OperateTypeEnum operateLogType = convertOperateLogType(requestMethod);
operateLogObj.setType(operateLogType != null ? operateLogType.getType() : null);
}
setModule(operateLogObj, joinPoint, operateLog);
setName(operateLogObj, operateLog, operation);
setType(operateLogObj, joinPoint, operateLog);
// content 和 exts 属性
operateLogObj.setContent(CONTENT.get());
operateLogObj.setExts(EXTS.get());
@@ -371,4 +345,61 @@ public class OperateLogAspect {
|| object instanceof BindingResult;
}
// module 属性
private static void setModule(OperateLog operateLogObj, ProceedingJoinPoint joinPoint,
com.cf.imes.framework.operatelog.core.annotations.OperateLog operateLog) {
if (operateLog != null) {
operateLogObj.setModule(operateLog.module());
}
if (CharSequenceUtil.isEmpty(operateLogObj.getModule())) {
Tag tag = getClassAnnotation(joinPoint, Tag.class);
if (tag != null) {
// 优先读取 @Tag 的 name 属性
if (CharSequenceUtil.isNotEmpty(tag.name())) {
operateLogObj.setModule(tag.name());
}
// 没有的话,读取 @API 的 description 属性
if (CharSequenceUtil.isEmpty(operateLogObj.getModule()) && ArrayUtil.isNotEmpty(tag.description())) {
operateLogObj.setModule(tag.description());
}
}
}
}
// name 属性
private static void setName(OperateLog operateLogObj,
com.cf.imes.framework.operatelog.core.annotations.OperateLog operateLog,
Operation operation) {
if (operateLog != null) {
operateLogObj.setName(operateLog.name());
}
if (CharSequenceUtil.isEmpty(operateLogObj.getName()) && operation != null) {
operateLogObj.setName(operation.summary());
}
}
// type 属性
private static void setType(OperateLog operateLogObj,
ProceedingJoinPoint joinPoint,
com.cf.imes.framework.operatelog.core.annotations.OperateLog operateLog) {
if (operateLog != null && ArrayUtil.isNotEmpty(operateLog.type())) {
operateLogObj.setType(operateLog.type()[0].getType());
}
if (operateLogObj.getType() == null) {
RequestMethod requestMethod = obtainFirstMatchRequestMethod(obtainRequestMethod(joinPoint));
OperateTypeEnum operateLogType = convertOperateLogType(requestMethod);
operateLogObj.setType(operateLogType != null ? operateLogType.getType() : null);
}
}
}
@@ -9,6 +9,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.io.Serial;
/**
* XSS 过滤 jackson 反序列化器。
@@ -55,5 +56,19 @@ public class XssStringJsonDeserializer extends StringDeserializer {
}
return (String) ctxt.handleUnexpectedToken(_valueClass, p);
}
@Serial
private void writeObject(java.io.ObjectOutputStream stream)
throws IOException {
stream.defaultWriteObject();
}
@Serial
private void readObject(java.io.ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
}
}