!200 修复导出 Excel 时,报结果码不能为空的错误

Merge pull request !200 from 李树桐/result_code_pr
This commit is contained in:
芋道源码 2022-06-30 05:21:26 +00:00 committed by Gitee
commit df868109c1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -44,7 +44,7 @@ import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeC
* 满足如下任一条件则会进行记录
* 1. 使用 @ApiOperation + @GetMapping
* 2. 使用 @OperateLog 注解
*
* <p>
* 但是如果声明 @OperateLog 注解时 enable 属性设置为 false 强制不记录
*
* @author 芋道源码
@ -77,7 +77,8 @@ public class OperateLogAspect {
return around0(joinPoint, operateLog, apiOperation);
}
@Around("!@annotation(io.swagger.annotations.ApiOperation) && @annotation(operateLog)") // 兼容处理只添加 @OperateLog 注解的情况
@Around("!@annotation(io.swagger.annotations.ApiOperation) && @annotation(operateLog)")
// 兼容处理只添加 @OperateLog 注解的情况
public Object around(ProceedingJoinPoint joinPoint,
cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog) throws Throwable {
return around0(joinPoint, operateLog, null);
@ -236,14 +237,12 @@ public class OperateLogAspect {
}
operateLogObj.setDuration((int) (System.currentTimeMillis() - startTime.getTime()));
// 正常处理 resultCode resultMsg 字段
if (result != null) {
if (result instanceof CommonResult) {
CommonResult<?> commonResult = (CommonResult<?>) result;
operateLogObj.setResultCode(commonResult.getCode());
operateLogObj.setResultMsg(commonResult.getMsg());
} else {
operateLogObj.setResultCode(SUCCESS.getCode());
}
if (result instanceof CommonResult) {
CommonResult<?> commonResult = (CommonResult<?>) result;
operateLogObj.setResultCode(commonResult.getCode());
operateLogObj.setResultMsg(commonResult.getMsg());
} else {
operateLogObj.setResultCode(SUCCESS.getCode());
}
// 异常处理 resultCode resultMsg 字段
if (exception != null) {
@ -267,9 +266,9 @@ public class OperateLogAspect {
return null;
}
return Arrays.stream(requestMethods).filter(requestMethod ->
requestMethod == RequestMethod.POST
|| requestMethod == RequestMethod.PUT
|| requestMethod == RequestMethod.DELETE)
requestMethod == RequestMethod.POST
|| requestMethod == RequestMethod.PUT
|| requestMethod == RequestMethod.DELETE)
.findFirst().orElse(null);
}