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
@@ -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);
}
}
}