Commit 892fa63ac3ec35ea10863bd335fc954ea7e9d37f

Authored by lst
1 parent 69a3a835

提交resultCode pr

yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java
@@ -44,7 +44,7 @@ import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeC @@ -44,7 +44,7 @@ import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeC
44 * 满足如下任一条件,则会进行记录: 44 * 满足如下任一条件,则会进行记录:
45 * 1. 使用 @ApiOperation + 非 @GetMapping 45 * 1. 使用 @ApiOperation + 非 @GetMapping
46 * 2. 使用 @OperateLog 注解 46 * 2. 使用 @OperateLog 注解
47 - * 47 + * <p>
48 * 但是,如果声明 @OperateLog 注解时,将 enable 属性设置为 false 时,强制不记录。 48 * 但是,如果声明 @OperateLog 注解时,将 enable 属性设置为 false 时,强制不记录。
49 * 49 *
50 * @author 芋道源码 50 * @author 芋道源码
@@ -77,7 +77,8 @@ public class OperateLogAspect { @@ -77,7 +77,8 @@ public class OperateLogAspect {
77 return around0(joinPoint, operateLog, apiOperation); 77 return around0(joinPoint, operateLog, apiOperation);
78 } 78 }
79 79
80 - @Around("!@annotation(io.swagger.annotations.ApiOperation) && @annotation(operateLog)") // 兼容处理,只添加 @OperateLog 注解的情况 80 + @Around("!@annotation(io.swagger.annotations.ApiOperation) && @annotation(operateLog)")
  81 + // 兼容处理,只添加 @OperateLog 注解的情况
81 public Object around(ProceedingJoinPoint joinPoint, 82 public Object around(ProceedingJoinPoint joinPoint,
82 cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog) throws Throwable { 83 cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog) throws Throwable {
83 return around0(joinPoint, operateLog, null); 84 return around0(joinPoint, operateLog, null);
@@ -236,14 +237,12 @@ public class OperateLogAspect { @@ -236,14 +237,12 @@ public class OperateLogAspect {
236 } 237 }
237 operateLogObj.setDuration((int) (System.currentTimeMillis() - startTime.getTime())); 238 operateLogObj.setDuration((int) (System.currentTimeMillis() - startTime.getTime()));
238 // (正常)处理 resultCode 和 resultMsg 字段 239 // (正常)处理 resultCode 和 resultMsg 字段
239 - if (result != null) {  
240 - if (result instanceof CommonResult) {  
241 - CommonResult<?> commonResult = (CommonResult<?>) result;  
242 - operateLogObj.setResultCode(commonResult.getCode());  
243 - operateLogObj.setResultMsg(commonResult.getMsg());  
244 - } else {  
245 - operateLogObj.setResultCode(SUCCESS.getCode());  
246 - } 240 + if (result instanceof CommonResult) {
  241 + CommonResult<?> commonResult = (CommonResult<?>) result;
  242 + operateLogObj.setResultCode(commonResult.getCode());
  243 + operateLogObj.setResultMsg(commonResult.getMsg());
  244 + } else {
  245 + operateLogObj.setResultCode(SUCCESS.getCode());
247 } 246 }
248 // (异常)处理 resultCode 和 resultMsg 字段 247 // (异常)处理 resultCode 和 resultMsg 字段
249 if (exception != null) { 248 if (exception != null) {
@@ -267,9 +266,9 @@ public class OperateLogAspect { @@ -267,9 +266,9 @@ public class OperateLogAspect {
267 return null; 266 return null;
268 } 267 }
269 return Arrays.stream(requestMethods).filter(requestMethod -> 268 return Arrays.stream(requestMethods).filter(requestMethod ->
270 - requestMethod == RequestMethod.POST  
271 - || requestMethod == RequestMethod.PUT  
272 - || requestMethod == RequestMethod.DELETE) 269 + requestMethod == RequestMethod.POST
  270 + || requestMethod == RequestMethod.PUT
  271 + || requestMethod == RequestMethod.DELETE)
273 .findFirst().orElse(null); 272 .findFirst().orElse(null);
274 } 273 }
275 274