!359 积木报表:API数据集解析时,提示数据为空,报表字段明细会被清空
Merge pull request !359 from 与或非/issues/I62TCM
This commit is contained in:
commit
bbb27df5e9
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.visualization.framework.jmreport.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
|
||||
import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi;
|
||||
import cn.iocoder.yudao.module.visualization.framework.jmreport.core.service.JmReportTokenServiceImpl;
|
||||
import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
|
||||
@ -18,8 +19,8 @@ public class JmReportConfiguration {
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||
public JmReportTokenServiceI jmReportTokenService(OAuth2TokenApi oAuth2TokenApi) {
|
||||
return new JmReportTokenServiceImpl(oAuth2TokenApi);
|
||||
public JmReportTokenServiceI jmReportTokenService(OAuth2TokenApi oAuth2TokenApi, SecurityProperties securityProperties) {
|
||||
return new JmReportTokenServiceImpl(oAuth2TokenApi, securityProperties);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ 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.common.util.servlet.ServletUtils;
|
||||
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
@ -11,7 +13,9 @@ import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi;
|
||||
import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -22,8 +26,37 @@ import java.util.Objects;
|
||||
@RequiredArgsConstructor
|
||||
public class JmReportTokenServiceImpl implements JmReportTokenServiceI {
|
||||
|
||||
/**
|
||||
* 积木 token head 头
|
||||
*/
|
||||
private static final String JM_TOKEN_HEADER = "X-Access-Token";
|
||||
/**
|
||||
* auth 相关格式
|
||||
*/
|
||||
private static final String AUTHORIZATION_FORMAT = SecurityFrameworkUtils.AUTHORIZATION_BEARER + " %s";
|
||||
|
||||
private final OAuth2TokenApi oauth2TokenApi;
|
||||
|
||||
private final SecurityProperties securityProperties;
|
||||
|
||||
/**
|
||||
* 自定义 API 数据集appian自定义 Header,解决 Token 传递。
|
||||
* 参考 <a href="http://report.jeecg.com/2222224">api数据集token机制详解</a> 文档
|
||||
*
|
||||
* @return 新 head
|
||||
*/
|
||||
@Override
|
||||
public HttpHeaders customApiHeader() {
|
||||
// 读取积木标标系统的 token
|
||||
HttpServletRequest request = ServletUtils.getRequest();
|
||||
String token = request.getHeader(JM_TOKEN_HEADER);
|
||||
|
||||
// 设置到 yudao 系统的 token
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add(securityProperties.getTokenHeader(), String.format(AUTHORIZATION_FORMAT, token));
|
||||
return headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验 Token 是否有效,即验证通过
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user