1. 统一包名修改
This commit is contained in:
@@ -12,7 +12,7 @@ import java.util.Set;
|
||||
*
|
||||
* @author ZT
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "cloud.tenant")
|
||||
@ConfigurationProperties(prefix = "zt.tenant")
|
||||
@Data
|
||||
public class TenantProperties {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.zt.plat.framework.common.biz.system.tenant.TenantCommonApi;
|
||||
import com.zt.plat.framework.common.enums.WebFilterOrderEnum;
|
||||
import com.zt.plat.framework.mybatis.core.util.MyBatisUtils;
|
||||
import com.zt.plat.framework.redis.config.CloudCacheProperties;
|
||||
import com.zt.plat.framework.redis.config.ZtCacheProperties;
|
||||
import com.zt.plat.framework.security.core.service.SecurityFrameworkService;
|
||||
import com.zt.plat.framework.tenant.core.aop.TenantIgnore;
|
||||
import com.zt.plat.framework.tenant.core.aop.TenantIgnoreAspect;
|
||||
@@ -53,16 +53,16 @@ import java.util.Objects;
|
||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
||||
|
||||
@AutoConfiguration
|
||||
@ConditionalOnProperty(prefix = "cloud.tenant", value = "enable", matchIfMissing = true) // 允许使用 cloud.tenant.enable=false 禁用多租户
|
||||
@ConditionalOnProperty(prefix = "zt.tenant", value = "enable", matchIfMissing = true) // 允许使用 zt.tenant.enable=false 禁用多租户
|
||||
@EnableConfigurationProperties(TenantProperties.class)
|
||||
public class CloudTenantAutoConfiguration {
|
||||
public class ZtTenantAutoConfiguration {
|
||||
|
||||
@Resource
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Bean
|
||||
public TenantFrameworkService tenantFrameworkService(TenantCommonApi tenantApi) {
|
||||
// 参见 https://gitee.com/zhijiantianya/cloud-cloud/issues/IC6YZF
|
||||
// 参见 https://gitee.com/zhijiantianya/zt-cloud/issues/IC6YZF
|
||||
try {
|
||||
TenantCommonApi tenantApiImpl = SpringUtil.getBean("tenantApiImpl", TenantCommonApi.class);
|
||||
if (tenantApiImpl != null) {
|
||||
@@ -221,12 +221,12 @@ public class CloudTenantAutoConfiguration {
|
||||
@Primary // 引入租户时,tenantRedisCacheManager 为主 Bean
|
||||
public RedisCacheManager tenantRedisCacheManager(RedisTemplate<String, Object> redisTemplate,
|
||||
RedisCacheConfiguration redisCacheConfiguration,
|
||||
CloudCacheProperties cloudCacheProperties,
|
||||
ZtCacheProperties ztCacheProperties,
|
||||
TenantProperties tenantProperties) {
|
||||
// 创建 RedisCacheWriter 对象
|
||||
RedisConnectionFactory connectionFactory = Objects.requireNonNull(redisTemplate.getConnectionFactory());
|
||||
RedisCacheWriter cacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory,
|
||||
BatchStrategies.scan(cloudCacheProperties.getRedisScanBatchSize()));
|
||||
BatchStrategies.scan(ztCacheProperties.getRedisScanBatchSize()));
|
||||
// 创建 TenantRedisCacheManager 对象
|
||||
return new TenantRedisCacheManager(cacheWriter, redisCacheConfiguration, tenantProperties.getIgnoreCaches());
|
||||
}
|
||||
@@ -8,9 +8,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@AutoConfiguration
|
||||
@ConditionalOnProperty(prefix = "cloud.tenant", value = "enable", matchIfMissing = true) // 允许使用 cloud.tenant.enable=false 禁用多租户
|
||||
@ConditionalOnProperty(prefix = "zt.tenant", value = "enable", matchIfMissing = true) // 允许使用 zt.tenant.enable=false 禁用多租户
|
||||
@EnableFeignClients(clients = TenantCommonApi.class) // 主要是引入相关的 API 服务
|
||||
public class CloudTenantRpcAutoConfiguration {
|
||||
public class ZtTenantRpcAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public TenantRequestInterceptor tenantRequestInterceptor() {
|
||||
@@ -66,7 +66,7 @@ public class TenantDatabaseInterceptor implements TenantLineHandler {
|
||||
}
|
||||
|
||||
private boolean computeIgnoreTable(String tableName) {
|
||||
// 找不到的表,说明不是 cloud 项目里的,不进行拦截(忽略租户)
|
||||
// 找不到的表,说明不是 zt 项目里的,不进行拦截(忽略租户)
|
||||
TableInfo tableInfo = TableInfoHelper.getTableInfo(tableName);
|
||||
if (tableInfo == null) {
|
||||
return true;
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
* 6. MQ:在 Producer 发送消息时,Header 带上 tenant-id 租户编号;在 Consumer 消费消息时,将 Header 的 tenant-id 租户编号,添加到租户上下文。
|
||||
* 7. Async:异步需要保证 ThreadLocal 的传递性,通过使用阿里开源的 TransmittableThreadLocal 实现。相关的改造点,可见:
|
||||
* 1)Spring Async:
|
||||
* {@link com.zt.plat.framework.quartz.config.CloudAsyncAutoConfiguration#threadPoolTaskExecutorBeanPostProcessor()}
|
||||
* {@link com.zt.plat.framework.quartz.config.ZtAsyncAutoConfiguration#threadPoolTaskExecutorBeanPostProcessor()}
|
||||
* 2)Spring Security:
|
||||
* TransmittableThreadLocalSecurityContextHolderStrategy
|
||||
* 和 CloudSecurityAutoConfiguration#securityContextHolderMethodInvokingFactoryBean() 方法
|
||||
* 和 ZtSecurityAutoConfiguration#securityContextHolderMethodInvokingFactoryBean() 方法
|
||||
*
|
||||
*/
|
||||
package com.zt.plat.framework.tenant;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
com.zt.plat.framework.tenant.config.CloudTenantRpcAutoConfiguration
|
||||
com.zt.plat.framework.tenant.config.CloudTenantAutoConfiguration
|
||||
com.zt.plat.framework.tenant.config.ZtTenantRpcAutoConfiguration
|
||||
com.zt.plat.framework.tenant.config.ZtTenantAutoConfiguration
|
||||
|
||||
Reference in New Issue
Block a user