Commit a8001a117b2a4525ddfb3120cf7d240baab4d2cc

Authored by gaibu
1 parent 80ab569f

fix: 积木报表的部分请求会报错

yudao-module-visualization/yudao-module-visualization-biz/src/main/java/cn/iocoder/yudao/module/visualization/framework/jmreport/core/service/JmReportTokenServiceImpl.java
1 package cn.iocoder.yudao.module.visualization.framework.jmreport.core.service; 1 package cn.iocoder.yudao.module.visualization.framework.jmreport.core.service;
2 2
  3 +import cn.hutool.core.util.ObjectUtil;
3 import cn.hutool.core.util.StrUtil; 4 import cn.hutool.core.util.StrUtil;
4 import cn.iocoder.yudao.framework.common.exception.ServiceException; 5 import cn.iocoder.yudao.framework.common.exception.ServiceException;
5 import cn.iocoder.yudao.framework.security.core.LoginUser; 6 import cn.iocoder.yudao.framework.security.core.LoginUser;
@@ -35,7 +36,7 @@ public class JmReportTokenServiceImpl implements JmReportTokenServiceI { @@ -35,7 +36,7 @@ public class JmReportTokenServiceImpl implements JmReportTokenServiceI {
35 if (!Objects.isNull(userId)) { 36 if (!Objects.isNull(userId)) {
36 return true; 37 return true;
37 } 38 }
38 - return injectUserInfoByToken(token) != null; 39 + return buildLoginUserByToken(token) != null;
39 } 40 }
40 41
41 /** 42 /**
@@ -49,20 +50,20 @@ public class JmReportTokenServiceImpl implements JmReportTokenServiceI { @@ -49,20 +50,20 @@ public class JmReportTokenServiceImpl implements JmReportTokenServiceI {
49 @Override 50 @Override
50 public String getUsername(String token) { 51 public String getUsername(String token) {
51 Long userId = SecurityFrameworkUtils.getLoginUserId(); 52 Long userId = SecurityFrameworkUtils.getLoginUserId();
52 - if (Objects.isNull(userId)) {  
53 - LoginUser user = injectUserInfoByToken(token);  
54 - return user == null ? null : String.valueOf(user.getId()); 53 + if (ObjectUtil.isNotNull(userId)) {
  54 + return String.valueOf(userId);
55 } 55 }
56 - return String.valueOf(userId); 56 + LoginUser user = buildLoginUserByToken(token);
  57 + return user == null ? null : String.valueOf(user.getId());
57 } 58 }
58 59
59 /** 60 /**
60 - * 注入用户信息 61 + * 基于 token 构建登录用户
61 * 62 *
62 * @param token token 63 * @param token token
63 * @return 返回 token 对应的用户信息 64 * @return 返回 token 对应的用户信息
64 */ 65 */
65 - private LoginUser injectUserInfoByToken(String token) { 66 + private LoginUser buildLoginUserByToken(String token) {
66 if (StrUtil.isEmpty(token)) { 67 if (StrUtil.isEmpty(token)) {
67 return null; 68 return null;
68 } 69 }