mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-11-15 06:59:29 +08:00
✨ 添加 TenantIdUtil 方便在非 web 场景使用
This commit is contained in:
parent
78dea9b212
commit
72ca05fd27
@ -61,4 +61,20 @@ public class TenantIdUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用租户 id 执行函数
|
||||
*
|
||||
* @param tenantId tenantId
|
||||
* @param runnable Runnable
|
||||
*/
|
||||
public static void use(String tenantId, Runnable runnable) {
|
||||
Assert.hasText(tenantId, "参数 tenantId 为空");
|
||||
tl.set(tenantId);
|
||||
try {
|
||||
runnable.run();
|
||||
} finally {
|
||||
tl.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user