适配无token接口的报错拦截器
This commit is contained in:
@@ -44,9 +44,11 @@ public class ControllerLoggingAspect {
|
||||
|
||||
// 获取当前用户ID
|
||||
Long userId = null;
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
if (authPrincipalVo != null) {
|
||||
try {
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
userId = authPrincipalVo.getId();
|
||||
} catch (RuntimeException e) {
|
||||
// 匿名接口,无认证上下文,忽略
|
||||
}
|
||||
|
||||
// 获取请求参数
|
||||
@@ -121,9 +123,11 @@ public class ControllerLoggingAspect {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
|
||||
Long userId = null;
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
if (authPrincipalVo != null) {
|
||||
try {
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
userId = authPrincipalVo.getId();
|
||||
} catch (RuntimeException e) {
|
||||
// 匿名接口,无认证上下文,忽略
|
||||
}
|
||||
|
||||
// 获取请求参数
|
||||
|
||||
Reference in New Issue
Block a user