fix(extension/tenant): 修复部分错误

This commit is contained in:
2024-12-24 21:52:35 +08:00
parent c5cb203532
commit 88d11027dd
4 changed files with 10 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ import top.continew.starter.extension.tenant.context.TenantContext;
* 租户提供者 * 租户提供者
* *
* @author Charles7c * @author Charles7c
* @author 小熊
* @since 2.7.0 * @since 2.7.0
*/ */
public interface TenantProvider { public interface TenantProvider {

View File

@@ -54,7 +54,7 @@ public class TenantAutoConfiguration {
private static final Logger log = LoggerFactory.getLogger(TenantAutoConfiguration.class); private static final Logger log = LoggerFactory.getLogger(TenantAutoConfiguration.class);
private final TenantProperties tenantProperties; private final TenantProperties tenantProperties;
private TenantAutoConfiguration(TenantProperties tenantProperties) { public TenantAutoConfiguration(TenantProperties tenantProperties) {
this.tenantProperties = tenantProperties; this.tenantProperties = tenantProperties;
} }

View File

@@ -65,7 +65,10 @@ public class TenantDataSourceAdvisor extends AbstractPointcutAdvisor implements
*/ */
private Pointcut buildPointcut() { private Pointcut buildPointcut() {
AspectJExpressionPointcut cut = new AspectJExpressionPointcut(); AspectJExpressionPointcut cut = new AspectJExpressionPointcut();
cut.setExpression("execution(* *..controller..*(..))"); cut.setExpression("""
execution(* *..controller..*(..))
&& !@annotation(top.continew.starter.extension.tenant.annotation.TenantDataSourceIgnore)
""");
return new ComposablePointcut((Pointcut)cut); return new ComposablePointcut((Pointcut)cut);
} }
} }

View File

@@ -55,8 +55,10 @@ public class DefaultTenantLineHandler implements TenantLineHandler {
@Override @Override
public boolean ignoreTable(String tableName) { public boolean ignoreTable(String tableName) {
Long tenantId = TenantContextHolder.getTenantId(); Long tenantId = TenantContextHolder.getTenantId();
if ((null != tenantId && tenantId.equals(tenantProperties if (null != tenantId && tenantId.equals(tenantProperties.getSuperTenantId())) {
.getSuperTenantId())) || TenantIsolationLevel.DATASOURCE.equals(TenantContextHolder.getIsolationLevel())) { return true;
}
if (TenantIsolationLevel.DATASOURCE.equals(TenantContextHolder.getIsolationLevel())) {
return true; return true;
} }
return CollUtil.contains(tenantProperties.getIgnoreTables(), tableName); return CollUtil.contains(tenantProperties.getIgnoreTables(), tableName);