mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
add TenantManager.java
This commit is contained in:
parent
85c0978bfb
commit
8f034485ff
@ -17,6 +17,8 @@ package com.mybatisflex.core.tenant;
|
||||
|
||||
public class TenantManager {
|
||||
|
||||
private static ThreadLocal<Boolean> ignoreFlags = new ThreadLocal<>();
|
||||
|
||||
private static TenantFactory tenantFactory;
|
||||
|
||||
public static TenantFactory getTenantFactory() {
|
||||
@ -27,7 +29,30 @@ public class TenantManager {
|
||||
TenantManager.tenantFactory = tenantFactory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 忽略 tenant 条件
|
||||
*/
|
||||
public static void ignoreTenantCondition() {
|
||||
ignoreFlags.set(Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 恢复 tenant 条件
|
||||
*/
|
||||
public static void restore() {
|
||||
ignoreFlags.remove();
|
||||
}
|
||||
|
||||
|
||||
public static Object[] getTenantIds() {
|
||||
Boolean ignoreFlag = ignoreFlags.get();
|
||||
if (ignoreFlag != null && ignoreFlag) {
|
||||
return null;
|
||||
}
|
||||
return tenantFactory != null ? tenantFactory.getTenantIds() : null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user