From a8001a117b2a4525ddfb3120cf7d240baab4d2cc Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Sat, 7 Jan 2023 00:46:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=AF=E6=9C=A8=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E9=83=A8=E5=88=86=E8=AF=B7=E6=B1=82=E4=BC=9A=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/service/JmReportTokenServiceImpl.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/yudao-module-visualization/yudao-module-visualization-biz/src/main/java/cn/iocoder/yudao/module/visualization/framework/jmreport/core/service/JmReportTokenServiceImpl.java b/yudao-module-visualization/yudao-module-visualization-biz/src/main/java/cn/iocoder/yudao/module/visualization/framework/jmreport/core/service/JmReportTokenServiceImpl.java index be26ce2e8..d690e28e5 100644 --- a/yudao-module-visualization/yudao-module-visualization-biz/src/main/java/cn/iocoder/yudao/module/visualization/framework/jmreport/core/service/JmReportTokenServiceImpl.java +++ b/yudao-module-visualization/yudao-module-visualization-biz/src/main/java/cn/iocoder/yudao/module/visualization/framework/jmreport/core/service/JmReportTokenServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.visualization.framework.jmreport.core.service; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.exception.ServiceException; import cn.iocoder.yudao.framework.security.core.LoginUser; @@ -35,7 +36,7 @@ public class JmReportTokenServiceImpl implements JmReportTokenServiceI { if (!Objects.isNull(userId)) { return true; } - return injectUserInfoByToken(token) != null; + return buildLoginUserByToken(token) != null; } /** @@ -49,20 +50,20 @@ public class JmReportTokenServiceImpl implements JmReportTokenServiceI { @Override public String getUsername(String token) { Long userId = SecurityFrameworkUtils.getLoginUserId(); - if (Objects.isNull(userId)) { - LoginUser user = injectUserInfoByToken(token); - return user == null ? null : String.valueOf(user.getId()); + if (ObjectUtil.isNotNull(userId)) { + return String.valueOf(userId); } - return String.valueOf(userId); + LoginUser user = buildLoginUserByToken(token); + return user == null ? null : String.valueOf(user.getId()); } /** - * 注入用户信息 + * 基于 token 构建登录用户 * * @param token token * @return 返回 token 对应的用户信息 */ - private LoginUser injectUserInfoByToken(String token) { + private LoginUser buildLoginUserByToken(String token) { if (StrUtil.isEmpty(token)) { return null; }