mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
Sonar代码问题修改
This commit is contained in:
+64
-33
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user