org.zodiac.autoconfigure.tenant.PlatformTenantAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.tenant;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.zodiac.autoconfigure.mybatisplus.MyBatisPlusConfigAutoConfiguration;
import org.zodiac.autoconfigure.tenant.condition.ConditionalOnPlatformTenantEnabled;
@SpringBootConfiguration
@ConditionalOnPlatformTenantEnabled
@AutoConfigureBefore(value = {MyBatisPlusConfigAutoConfiguration.class})
@ConditionalOnClass(value = {com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler.class, org.zodiac.tenant.TenantId.class})
public class PlatformTenantAutoConfiguration {
public PlatformTenantAutoConfiguration() {
super();
}
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties(prefix = org.zodiac.tenant.constants.PlatformTenantSystemPropetiesConstants.PLATFORM_TENANT_PREFIX)
protected PlatformTenantProperties platformTenantProperties() {
return new PlatformTenantProperties();
}
@Bean
@Primary
protected com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler tenantLineHandler(PlatformTenantProperties tenantProperties, org.zodiac.security.SecurityAuthOperations2 securityAuthOperations) {
return new org.zodiac.tenant.PlatformTenantHandler(tenantProperties, securityAuthOperations);
}
@Bean
@Primary
protected com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor tenantLineInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler tenantHandler,
PlatformTenantProperties tenantProperties, org.zodiac.security.SecurityAuthOperations2 securityAuthOperations) {
org.zodiac.tenant.PlatformTenantInterceptor tenantInterceptor = new org.zodiac.tenant.PlatformTenantInterceptor(securityAuthOperations);
tenantInterceptor.setTenantLineHandler(tenantHandler);
tenantInterceptor.setPlatformTenantInfo(tenantProperties);
return tenantInterceptor;
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.tenant.TenantId tenantId() {
return new org.zodiac.tenant.PlatformTenantId();
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.tenant.aspect.PlatformTenantAspect platformTenantAspect() {
return new org.zodiac.tenant.aspect.PlatformTenantAspect();
}
}