fix(系统设置): 导入用户失败的日志详细显示导入成功

--bug=1018653 --user=李玉号 [系统设置]系统-操作日志-导入用户失败的日志详细显示导入成功
https://www.tapd.cn/55049933/s/1278451
This commit is contained in:
shiziyuan9527 2022-10-26 15:45:42 +08:00 committed by 刘瑞斌
parent 0768215c85
commit 12bdd23d59
1 changed files with 20 additions and 2 deletions

View File

@ -5,11 +5,13 @@ import io.metersphere.base.domain.OperatingLogWithBLOBs;
import io.metersphere.commons.utils.JSON;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.excel.domain.ExcelResponse;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.service.OperatingLogService;
import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
@ -107,9 +109,12 @@ public class MsLogAspect {
/**
* 切面 配置通知
*/
@AfterReturning("logPoinCut()")
public void saveLog(JoinPoint joinPoint) {
@AfterReturning(value = "logPoinCut()", returning = "result")
public void saveLog(JoinPoint joinPoint, Object result) {
try {
if (this.hasLogicalFail(result)) {
return;
}
//从切面织入点处通过反射机制获取织入点处的方法
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
//获取切入点所在的方法
@ -263,4 +268,17 @@ public class MsLogAspect {
beforeValue.remove();
}
}
/**
* 方法正常返回但是执行逻辑是失败的
* @param result 方法返回值
* @return boolean
*/
private boolean hasLogicalFail(Object result) {
if (result instanceof ExcelResponse) {
return BooleanUtils.isFalse(((ExcelResponse<?>) result).getSuccess());
}
return false;
}
}