Commit 078ead536bef09b0ef78690ca12c3ac5bc3a46e9

Authored by YunaiV
1 parent 9a03f1a7

🐛 REPORT:支持 SaaS 租户模式

yudao-dependencies/pom.xml
@@ -71,7 +71,7 @@ @@ -71,7 +71,7 @@
71 <aliyun-java-sdk-dysmsapi.version>2.2.1</aliyun-java-sdk-dysmsapi.version> 71 <aliyun-java-sdk-dysmsapi.version>2.2.1</aliyun-java-sdk-dysmsapi.version>
72 <tencentcloud-sdk-java.version>3.1.880</tencentcloud-sdk-java.version> 72 <tencentcloud-sdk-java.version>3.1.880</tencentcloud-sdk-java.version>
73 <justauth.version>2.0.5</justauth.version> 73 <justauth.version>2.0.5</justauth.version>
74 - <jimureport.version>1.6.1</jimureport.version> 74 + <jimureport.version>1.6.6-beta2</jimureport.version>
75 <xercesImpl.version>2.12.2</xercesImpl.version> 75 <xercesImpl.version>2.12.2</xercesImpl.version>
76 <weixin-java.version>4.5.7.B</weixin-java.version> 76 <weixin-java.version>4.5.7.B</weixin-java.version>
77 <ureport2.version>2.2.9</ureport2.version> 77 <ureport2.version>2.2.9</ureport2.version>
@@ -639,7 +639,7 @@ @@ -639,7 +639,7 @@
639 <!-- 积木报表--> 639 <!-- 积木报表-->
640 <dependency> 640 <dependency>
641 <groupId>org.jeecgframework.jimureport</groupId> 641 <groupId>org.jeecgframework.jimureport</groupId>
642 - <artifactId>jimureport-spring-boot-starter</artifactId> 642 + <artifactId>jimureport-spring-boot3-starter</artifactId>
643 <version>${jimureport.version}</version> 643 <version>${jimureport.version}</version>
644 <exclusions> 644 <exclusions>
645 <exclusion> 645 <exclusion>
yudao-module-report/yudao-module-report-biz/pom.xml
@@ -66,7 +66,7 @@ @@ -66,7 +66,7 @@
66 <!-- 积木报表--> 66 <!-- 积木报表-->
67 <dependency> 67 <dependency>
68 <groupId>org.jeecgframework.jimureport</groupId> 68 <groupId>org.jeecgframework.jimureport</groupId>
69 - <artifactId>jimureport-spring-boot-starter</artifactId> 69 + <artifactId>jimureport-spring-boot3-starter</artifactId>
70 </dependency> 70 </dependency>
71 <!-- 单独依赖升级版本,解决低版本validator失败问题 --> 71 <!-- 单独依赖升级版本,解决低版本validator失败问题 -->
72 <dependency> 72 <dependency>
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/service/JmReportTokenServiceImpl.java
@@ -11,6 +11,7 @@ import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; @@ -11,6 +11,7 @@ import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
11 import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; 11 import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
12 import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; 12 import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi;
13 import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO; 13 import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO;
  14 +import cn.iocoder.yudao.module.system.api.permission.RoleApi;
14 import lombok.RequiredArgsConstructor; 15 import lombok.RequiredArgsConstructor;
15 import org.jeecg.modules.jmreport.api.JmReportTokenServiceI; 16 import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
16 import org.springframework.http.HttpHeaders; 17 import org.springframework.http.HttpHeaders;
@@ -128,4 +129,20 @@ public class JmReportTokenServiceImpl implements JmReportTokenServiceI { @@ -128,4 +129,20 @@ public class JmReportTokenServiceImpl implements JmReportTokenServiceI {
128 return user; 129 return user;
129 } 130 }
130 131
  132 + @Override
  133 + public String[] getRoles(String s) {
  134 + // 暂时不用实现,因为不用 JmReport 的角色
  135 + return null;
  136 + }
  137 +
  138 + @Override
  139 + public String getTenantId() {
  140 + // 补充说明:不能直接通过 TenantContext 获取,因为 jimu 报表前端请求时,没有带上 tenant-id Header
  141 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
  142 + if (loginUser == null) {
  143 + return null;
  144 + }
  145 + return StrUtil.toStringOrNull(loginUser.getTenantId());
  146 + }
  147 +
131 } 148 }
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/config/UReportConfiguration.java
1 package cn.iocoder.yudao.module.report.framework.ureport.config; 1 package cn.iocoder.yudao.module.report.framework.ureport.config;
2 2
3 -import com.bstek.ureport.console.UReportServlet;  
4 import org.springframework.boot.context.properties.EnableConfigurationProperties; 3 import org.springframework.boot.context.properties.EnableConfigurationProperties;
5 -import org.springframework.boot.web.servlet.ServletRegistrationBean;  
6 -import org.springframework.context.annotation.Bean;  
7 import org.springframework.context.annotation.Configuration; 4 import org.springframework.context.annotation.Configuration;
8 import org.springframework.context.annotation.ImportResource; 5 import org.springframework.context.annotation.ImportResource;
9 import org.springframework.context.annotation.PropertySource; 6 import org.springframework.context.annotation.PropertySource;
10 7
11 -import jakarta.servlet.Servlet;  
12 -  
13 /** 8 /**
14 * UReport2 配置类 9 * UReport2 配置类
15 * 10 *
16 * @author 赤焰 11 * @author 赤焰
17 */ 12 */
18 -@Configuration 13 +// @Configuration TODO 芋艿:JDK21 暂时不支持 UReport2,原因是 Spring Boot 3 的 javax 替换成 jakarta 了
19 @ImportResource({"classpath:ureport-console-context.xml"}) 14 @ImportResource({"classpath:ureport-console-context.xml"})
20 @PropertySource(value = {"classpath:ureport.properties"}) // TODO @赤焰:这个可以搞到 application.yaml 里么? 15 @PropertySource(value = {"classpath:ureport.properties"}) // TODO @赤焰:这个可以搞到 application.yaml 里么?
21 @EnableConfigurationProperties({UReportProperties.class}) 16 @EnableConfigurationProperties({UReportProperties.class})
22 public class UReportConfiguration { 17 public class UReportConfiguration {
23 18
24 - @Bean  
25 - public ServletRegistrationBean<Servlet> uReportRegistrationBean() {  
26 - return new ServletRegistrationBean<>(new UReportServlet(), "/ureport/*");  
27 - } 19 +// TODO 芋艿:JDK21 暂时不支持 UReport2,原因是 Spring Boot 3 的 javax 替换成 jakarta 了
  20 +// @Bean
  21 +// public ServletRegistrationBean<Servlet> uReportRegistrationBean() {
  22 +// return new ServletRegistrationBean<>(new UReportServlet(), "/ureport/*");
  23 +// }
28 24
29 } 25 }
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UReportDataSource.java
@@ -18,7 +18,7 @@ import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.UREPORT_DA @@ -18,7 +18,7 @@ import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.UREPORT_DA
18 * @author 赤焰 18 * @author 赤焰
19 */ 19 */
20 @Slf4j 20 @Slf4j
21 -@Component 21 +//@Component
22 public class UReportDataSource implements BuildinDatasource { 22 public class UReportDataSource implements BuildinDatasource {
23 23
24 private static final String NAME = "UReportDataSource"; 24 private static final String NAME = "UReportDataSource";
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UReportDatabaseProvider.java
@@ -29,7 +29,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. @@ -29,7 +29,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
29 * @author 赤焰 29 * @author 赤焰
30 */ 30 */
31 // TODO @赤焰:这个 bean 的注解,交给 UReportConfiguration 搞 31 // TODO @赤焰:这个 bean 的注解,交给 UReportConfiguration 搞
32 -@Component 32 +//@Component
33 @Slf4j 33 @Slf4j
34 @Setter 34 @Setter
35 public class UReportDatabaseProvider implements ReportProvider { 35 public class UReportDatabaseProvider implements ReportProvider {
yudao-server/src/main/resources/application-dev.yaml
@@ -5,9 +5,6 @@ server: @@ -5,9 +5,6 @@ server:
5 5
6 spring: 6 spring:
7 # 数据源配置项 7 # 数据源配置项
8 - autoconfigure:  
9 - exclude:  
10 - - org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration # 排除积木报表带来的 MongoDB 的自动配置  
11 datasource: 8 datasource:
12 druid: # Druid 【监控】相关的全局配置 9 druid: # Druid 【监控】相关的全局配置
13 web-stat-filter: 10 web-stat-filter:
yudao-server/src/main/resources/application-local.yaml
@@ -7,7 +7,6 @@ spring: @@ -7,7 +7,6 @@ spring:
7 # 数据源配置项 7 # 数据源配置项
8 autoconfigure: 8 autoconfigure:
9 exclude: 9 exclude:
10 - - org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration # 排除积木报表带来的 MongoDB 的自动配置  
11 - org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置 10 - org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置
12 - de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置 11 - de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置
13 - de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置 12 - de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置
@@ -188,6 +187,7 @@ logging: @@ -188,6 +187,7 @@ logging:
188 cn.iocoder.yudao.module.trade.dal.mysql: debug 187 cn.iocoder.yudao.module.trade.dal.mysql: debug
189 cn.iocoder.yudao.module.promotion.dal.mysql: debug 188 cn.iocoder.yudao.module.promotion.dal.mysql: debug
190 cn.iocoder.yudao.module.statistics.dal.mysql: debug 189 cn.iocoder.yudao.module.statistics.dal.mysql: debug
  190 + org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿:先禁用,Spring Boot 3.X 存在部分错误的 WARN 提示
191 191
192 debug: false 192 debug: false
193 193
yudao-server/src/main/resources/application.yaml
@@ -260,9 +260,9 @@ yudao: @@ -260,9 +260,9 @@ yudao:
260 debug: false 260 debug: false
261 261
262 # 积木报表配置 262 # 积木报表配置
263 -minidao :  
264 - base-package: org.jeecg.modules.jmreport.desreport.dao*  
265 - db-type: mysql 263 +jeecg:
  264 + jmreport:
  265 + saas-mode: tenant
266 266
267 # UReport 配置 267 # UReport 配置
268 ureport: 268 ureport: