From ecb0d53bfaeba89a1a13f0e5103822e09bb277bc Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Thu, 17 Aug 2023 15:07:48 +0800 Subject: [PATCH] =?UTF-8?q?doc:=20=E6=B7=BB=E5=8A=A0=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=A4=9A=E7=A7=9F=E6=88=B7=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=9A=84=E6=96=87=E6=A1=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh/core/multi-tenancy.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/zh/core/multi-tenancy.md b/docs/zh/core/multi-tenancy.md index 10b5cbba..e014f358 100644 --- a/docs/zh/core/multi-tenancy.md +++ b/docs/zh/core/multi-tenancy.md @@ -75,7 +75,7 @@ public class MyConfiguration { TenantFactory tenantFactory = new ....; return tenantFactory; } - + } ``` @@ -162,7 +162,7 @@ System.out.println(tenantAccounts); ```java try { TenantManager.ignoreTenantCondition(); - + //此处操作的数据不会带有 tenant_id 的条件 accountMapper.selectListByQuery(...); } finally { @@ -171,3 +171,22 @@ try { ``` 当然,除此之外,`TenantFactory` 返回空数据,也会忽略 tenant 条件。 + +## 全局配置多租户字段 + +在 `MyBatis-Flex` 中,可以使用 `FlexGlobalConfig` 在 `MyBatis-Flex` 启动之前,指定项目中的多租户列的列名。 + +```java +FlexGlobalConfig.getDefaultConfig().setTenantColumn("tenant_id"); +``` + +这样就可以省略实体类属性上的 `@Column(tenantId = true)` 注解了。 + +```java +public class Account { + + // @Column(tenantId = true) + private Integer tenantId; + +} +```