|
|
|
|
@ -2,11 +2,10 @@ 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.redis.config.YudaoCacheProperties;
|
|
|
|
|
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;
|
|
|
|
|
@ -17,24 +16,19 @@ 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 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;
|
|
|
|
|
import org.springframework.cloud.function.context.catalog.FunctionAroundWrapper;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.context.annotation.Primary;
|
|
|
|
|
import org.springframework.data.redis.cache.BatchStrategies;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
@ -104,12 +98,13 @@ public class YudaoTenantAutoConfiguration {
|
|
|
|
|
@Bean
|
|
|
|
|
@Primary // 引入租户时,tenantRedisCacheManager 为主 Bean
|
|
|
|
|
public RedisCacheManager tenantRedisCacheManager(RedisTemplate<String, Object> redisTemplate,
|
|
|
|
|
RedisCacheConfiguration redisCacheConfiguration) {
|
|
|
|
|
RedisCacheConfiguration redisCacheConfiguration,
|
|
|
|
|
YudaoCacheProperties yudaoCacheProperties) {
|
|
|
|
|
// 创建 RedisCacheWriter 对象
|
|
|
|
|
RedisConnectionFactory connectionFactory = Objects.requireNonNull(redisTemplate.getConnectionFactory());
|
|
|
|
|
RedisCacheWriter cacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory);
|
|
|
|
|
RedisCacheWriter cacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory,
|
|
|
|
|
BatchStrategies.scan(yudaoCacheProperties.getRedisScanBatchSize()));
|
|
|
|
|
// 创建 TenantRedisCacheManager 对象
|
|
|
|
|
return new TenantRedisCacheManager(cacheWriter, redisCacheConfiguration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|