Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
a81f5de3
提交
a81f5de3
authored
2月 08, 2023
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化 tenant 组件,支持不引入 mq 和 job 依赖
上级
e24d9dec
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
62 行增加
和
35 行删除
+62
-35
pom.xml
yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml
+2
-0
YudaoTenantAutoConfiguration.java
...framework/tenant/config/YudaoTenantAutoConfiguration.java
+2
-35
YudaoTenantMQAutoConfiguration.java
...amework/tenant/config/YudaoTenantMQAutoConfiguration.java
+57
-0
org.springframework.boot.autoconfigure.AutoConfiguration.imports
...ingframework.boot.autoconfigure.AutoConfiguration.imports
+1
-0
没有找到文件。
yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml
浏览文件 @
a81f5de3
...
...
@@ -49,12 +49,14 @@
<dependency>
<groupId>
cn.iocoder.cloud
</groupId>
<artifactId>
yudao-spring-boot-starter-job
</artifactId>
<optional>
true
</optional>
</dependency>
<!-- 消息队列相关 -->
<dependency>
<groupId>
cn.iocoder.cloud
</groupId>
<artifactId>
yudao-spring-boot-starter-mq
</artifactId>
<optional>
true
</optional>
</dependency>
<!-- Test 测试相关 -->
...
...
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
浏览文件 @
a81f5de3
...
...
@@ -21,6 +21,7 @@ import com.xxl.job.core.executor.XxlJobExecutor;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.config.BeanPostProcessor
;
import
org.springframework.boot.autoconfigure.AutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
...
...
@@ -90,44 +91,10 @@ public class YudaoTenantAutoConfiguration {
return
registrationBean
;
}
// ========== MQ ==========
@Bean
@GlobalChannelInterceptor
// 必须添加在方法上,否则无法生效
public
TenantChannelInterceptor
tenantChannelInterceptor
()
{
return
new
TenantChannelInterceptor
();
}
@Bean
public
FunctionAroundWrapper
functionAroundWrapper
()
{
return
new
TenantFunctionAroundWrapper
();
}
// ========== Job ==========
@Bean
public
BeanPostProcessor
jobHandlerBeanPostProcessor
(
TenantFrameworkService
tenantFrameworkService
)
{
return
new
BeanPostProcessor
()
{
@Override
public
Object
postProcessBeforeInitialization
(
Object
bean
,
String
beanName
)
throws
BeansException
{
if
(!(
bean
instanceof
XxlJobExecutor
))
{
return
bean
;
}
// // 有 TenantJob 注解的情况下,才会进行处理
// if (!AnnotationUtil.hasAnnotation(bean.getClass(), TenantJob.class)) {
// return bean;
// }
//
// // 使用 TenantJobHandlerDecorator 装饰
// return new TenantJobHandlerDecorator(tenantFrameworkService, (JobHandler) bean);
return
bean
;
}
};
}
@Bean
@ConditionalOnClass
(
name
=
"com.xxl.job.core.handler.annotation.XxlJob"
)
public
TenantJobAspect
tenantJobAspect
(
TenantFrameworkService
tenantFrameworkService
)
{
return
new
TenantJobAspect
(
tenantFrameworkService
);
}
...
...
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantMQAutoConfiguration.java
0 → 100644
浏览文件 @
a81f5de3
package
cn
.
iocoder
.
yudao
.
framework
.
tenant
.
config
;
import
cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum
;
import
cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils
;
import
cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnoreAspect
;
import
cn.iocoder.yudao.framework.tenant.core.db.TenantDatabaseInterceptor
;
import
cn.iocoder.yudao.framework.tenant.core.job.TenantJobAspect
;
import
cn.iocoder.yudao.framework.tenant.core.mq.TenantChannelInterceptor
;
import
cn.iocoder.yudao.framework.tenant.core.mq.TenantFunctionAroundWrapper
;
import
cn.iocoder.yudao.framework.tenant.core.redis.TenantRedisCacheManager
;
import
cn.iocoder.yudao.framework.tenant.core.security.TenantSecurityWebFilter
;
import
cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService
;
import
cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkServiceImpl
;
import
cn.iocoder.yudao.framework.tenant.core.web.TenantContextWebFilter
;
import
cn.iocoder.yudao.framework.web.config.WebProperties
;
import
cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler
;
import
cn.iocoder.yudao.module.system.api.tenant.TenantApi
;
import
com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor
;
import
org.springframework.boot.autoconfigure.AutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.cloud.function.context.catalog.FunctionAroundWrapper
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.data.redis.cache.RedisCacheConfiguration
;
import
org.springframework.data.redis.cache.RedisCacheManager
;
import
org.springframework.data.redis.cache.RedisCacheWriter
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.integration.config.GlobalChannelInterceptor
;
import
java.util.Objects
;
@AutoConfiguration
@ConditionalOnProperty
(
prefix
=
"yudao.tenant"
,
value
=
"enable"
,
matchIfMissing
=
true
)
// 允许使用 yudao.tenant.enable=false 禁用多租户
@ConditionalOnClass
(
name
=
{
"org.springframework.messaging.support.ChannelInterceptor"
,
"org.springframework.cloud.function.context.catalog.FunctionAroundWrapper"
})
@EnableConfigurationProperties
(
TenantProperties
.
class
)
public
class
YudaoTenantMQAutoConfiguration
{
@Bean
@GlobalChannelInterceptor
// 必须添加在方法上,否则无法生效
public
TenantChannelInterceptor
tenantChannelInterceptor
()
{
return
new
TenantChannelInterceptor
();
}
@Bean
public
FunctionAroundWrapper
functionAroundWrapper
()
{
return
new
TenantFunctionAroundWrapper
();
}
}
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
浏览文件 @
a81f5de3
cn.iocoder.yudao.framework.tenant.config.YudaoTenantRpcAutoConfiguration
cn.iocoder.yudao.framework.tenant.config.YudaoTenantAutoConfiguration
cn.iocoder.yudao.framework.tenant.config.YudaoTenantMQAutoConfiguration
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论