| | |
| | | @ConditionalOnProperty(value = "tenant.enable", havingValue = "true") |
| | | public class TenantConfig { |
| | | |
| | | /** |
| | | * 多租户插件 |
| | | */ |
| | | @ConditionalOnClass(TenantLineInnerInterceptor.class) |
| | | @Bean |
| | | public TenantLineInnerInterceptor tenantLineInnerInterceptor(TenantProperties tenantProperties) { |
| | | return new TenantLineInnerInterceptor(new PlusTenantLineHandler(tenantProperties)); |
| | | @AutoConfiguration |
| | | static class MybatisPlusConfiguration { |
| | | |
| | | /** |
| | | * 多租户插件 |
| | | */ |
| | | @Bean |
| | | public TenantLineInnerInterceptor tenantLineInnerInterceptor(TenantProperties tenantProperties) { |
| | | return new TenantLineInnerInterceptor(new PlusTenantLineHandler(tenantProperties)); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Bean |
| | |
| | | // 使用单机模式 |
| | | // 设置多租户 redis key前缀 |
| | | singleServerConfig.setNameMapper(nameMapper); |
| | | ReflectUtils.invokeSetter(config, "singleServerConfig", singleServerConfig); |
| | | } |
| | | ClusterServersConfig clusterServersConfig = ReflectUtils.invokeGetter(config, "clusterServersConfig"); |
| | | // 集群配置方式 参考下方注释 |
| | | if (ObjectUtil.isNotNull(clusterServersConfig)) { |
| | | // 设置多租户 redis key前缀 |
| | | clusterServersConfig.setNameMapper(nameMapper); |
| | | ReflectUtils.invokeSetter(config, "clusterServersConfig", clusterServersConfig); |
| | | } |
| | | }; |
| | | } |