修复记录操作时,会存在调用异常的情况
This commit is contained in:
parent
0ff2f9783d
commit
3930fd739a
@ -227,8 +227,7 @@ public class OperateLogAspect {
|
|||||||
private static void fillMethodFields(OperateLog operateLogObj,
|
private static void fillMethodFields(OperateLog operateLogObj,
|
||||||
ProceedingJoinPoint joinPoint,
|
ProceedingJoinPoint joinPoint,
|
||||||
cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog,
|
cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog,
|
||||||
LocalDateTime startTime, Object result, Throwable exception) {
|
LocalDateTime startTime, Object result, Throwable exception) {MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
|
||||||
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
|
|
||||||
operateLogObj.setJavaMethod(methodSignature.toString());
|
operateLogObj.setJavaMethod(methodSignature.toString());
|
||||||
if (operateLog == null || operateLog.logArgs()) {
|
if (operateLog == null || operateLog.logArgs()) {
|
||||||
operateLogObj.setJavaMethodArgs(obtainMethodArgs(joinPoint));
|
operateLogObj.setJavaMethodArgs(obtainMethodArgs(joinPoint));
|
||||||
@ -258,6 +257,11 @@ public class OperateLogAspect {
|
|||||||
if (operateLog != null) {
|
if (operateLog != null) {
|
||||||
return operateLog.enable();
|
return operateLog.enable();
|
||||||
}
|
}
|
||||||
|
// Cloud 专属逻辑:如果是 RPC 请求,则必须 @OperateLog 注解,才会记录操作日志
|
||||||
|
String className = joinPoint.getSignature().getDeclaringType().getName();
|
||||||
|
if (WebFrameworkUtils.isRpcRequest(className)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// 没有 @ApiOperation 注解的情况下,只记录 POST、PUT、DELETE 的情况
|
// 没有 @ApiOperation 注解的情况下,只记录 POST、PUT、DELETE 的情况
|
||||||
return obtainFirstLogRequestMethod(obtainRequestMethod(joinPoint)) != null;
|
return obtainFirstLogRequestMethod(obtainRequestMethod(joinPoint)) != null;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cn.iocoder.yudao.framework.web.core.util;
|
package cn.iocoder.yudao.framework.web.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.enums.RpcConstants;
|
import cn.iocoder.yudao.framework.common.enums.RpcConstants;
|
||||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
@ -136,4 +135,16 @@ public class WebFrameworkUtils {
|
|||||||
return request.getRequestURI().startsWith(RpcConstants.RPC_API_PREFIX);
|
return request.getRequestURI().startsWith(RpcConstants.RPC_API_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否为 RPC 请求
|
||||||
|
*
|
||||||
|
* 约定大于配置,只要以 Api 结尾,都认为是 RPC 接口
|
||||||
|
*
|
||||||
|
* @param className 类名
|
||||||
|
* @return 是否为 RPC 请求
|
||||||
|
*/
|
||||||
|
public static boolean isRpcRequest(String className) {
|
||||||
|
return className.endsWith("Api");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,13 @@ spring:
|
|||||||
- Path=/app-api/pay/**
|
- Path=/app-api/pay/**
|
||||||
filters:
|
filters:
|
||||||
- RewritePath=/app-api/pay/v3/api-docs, /v3/api-docs
|
- RewritePath=/app-api/pay/v3/api-docs, /v3/api-docs
|
||||||
|
## mp-server 服务
|
||||||
|
- id: mp-admin-api # 路由的编号
|
||||||
|
uri: grayLb://mp-server
|
||||||
|
predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
|
||||||
|
- Path=/admin-api/mp/**
|
||||||
|
filters:
|
||||||
|
- RewritePath=/admin-api/mp/v3/api-docs, /v3/api-docs
|
||||||
x-forwarded:
|
x-forwarded:
|
||||||
prefix-enabled: false # 避免 Swagger 重复带上额外的 /admin-api/system 前缀
|
prefix-enabled: false # 避免 Swagger 重复带上额外的 /admin-api/system 前缀
|
||||||
|
|
||||||
@ -85,3 +91,6 @@ knife4j:
|
|||||||
- name: pay-server
|
- name: pay-server
|
||||||
service-name: pay-server
|
service-name: pay-server
|
||||||
url: /admin-api/pay/v3/api-docs
|
url: /admin-api/pay/v3/api-docs
|
||||||
|
- name: mp-server
|
||||||
|
service-name: mp-server
|
||||||
|
url: /admin-api/mp/v3/api-docs
|
||||||
|
@ -71,6 +71,7 @@ wx:
|
|||||||
type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取
|
type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取
|
||||||
key-prefix: wx # Redis Key 的前缀
|
key-prefix: wx # Redis Key 的前缀
|
||||||
http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台
|
http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台
|
||||||
|
app-id: null # 避免 weixin-java-mp starter 报错
|
||||||
|
|
||||||
--- #################### 芋道相关配置 ####################
|
--- #################### 芋道相关配置 ####################
|
||||||
|
|
||||||
@ -81,6 +82,9 @@ yudao:
|
|||||||
web:
|
web:
|
||||||
admin-ui:
|
admin-ui:
|
||||||
url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址
|
url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址
|
||||||
|
security:
|
||||||
|
permit-all_urls:
|
||||||
|
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录
|
||||||
swagger:
|
swagger:
|
||||||
title: 管理后台
|
title: 管理后台
|
||||||
description: 提供管理员管理的所有功能
|
description: 提供管理员管理的所有功能
|
||||||
|
@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.system.api.logger;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
|
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.system.enums.ApiConstants;
|
import cn.iocoder.yudao.module.system.enums.ApiConstants;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
Loading…
Reference in New Issue
Block a user