diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/TenantAccount.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/TenantAccount.java index 1c19ec49..58b0bbdf 100644 --- a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/TenantAccount.java +++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/TenantAccount.java @@ -16,7 +16,10 @@ package com.mybatisflex.test; -import com.mybatisflex.annotation.*; +import com.mybatisflex.annotation.ColumnMask; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; +import com.mybatisflex.annotation.Table; import com.mybatisflex.core.mask.Masks; import java.util.Date; @@ -34,7 +37,7 @@ public class TenantAccount { private Date birthday; - @Column(tenantId = true) +// @Column(tenantId = true) private Long tenantId; public Long getId() { diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/TenantTester.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/TenantTester.java index da4b5539..99454565 100644 --- a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/TenantTester.java +++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/TenantTester.java @@ -18,8 +18,6 @@ package com.mybatisflex.test; import com.mybatisflex.core.MybatisFlexBootstrap; import com.mybatisflex.core.audit.AuditManager; import com.mybatisflex.core.audit.ConsoleMessageCollector; -import com.mybatisflex.core.query.QueryWrapper; -import com.mybatisflex.core.tenant.TenantFactory; import com.mybatisflex.core.tenant.TenantManager; import com.mybatisflex.mapper.TenantAccountMapper; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; @@ -27,10 +25,6 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import javax.sql.DataSource; -import static com.mybatisflex.core.query.QueryMethods.select; -import static com.mybatisflex.test.table.AccountTableDef.ACCOUNT; -import static com.mybatisflex.test.table.TenantAccountTableDef.TENANT_ACCOUNT; - public class TenantTester { public static void main(String[] args) { @@ -52,24 +46,22 @@ public class TenantTester { AuditManager.setMessageCollector(new ConsoleMessageCollector()); //配置 tenantFactory - TenantManager.setTenantFactory(new TenantFactory() { - @Override - public Object[] getTenantIds() { - return new Object[]{1, 2}; - } - }); + TenantManager.setTenantFactory(() -> new Object[]{1, 2}); - TenantAccountMapper mapper = MybatisFlexBootstrap.getInstance().getMapper(TenantAccountMapper.class); + TenantAccountMapper mapper = MybatisFlexBootstrap.getInstance() + .getMapper(TenantAccountMapper.class); - mapper.selectListByQuery(QueryWrapper.create() - .select(TENANT_ACCOUNT.ALL_COLUMNS) - .from(TENANT_ACCOUNT.as("c"), ACCOUNT.as("b")) - .where(TENANT_ACCOUNT.ID.eq(ACCOUNT.ID)) - .and(TENANT_ACCOUNT.ID.eq(1)) - .unionAll(select(TENANT_ACCOUNT.ALL_COLUMNS).from(TENANT_ACCOUNT) - .where(TENANT_ACCOUNT.ID.eq(2)) - ) - ); + mapper.selectAll().forEach(System.out::println); + +// mapper.selectListByQuery(QueryWrapper.create() +// .select(TENANT_ACCOUNT.ALL_COLUMNS) +// .from(TENANT_ACCOUNT.as("c"), ACCOUNT.as("b")) +// .where(TENANT_ACCOUNT.ID.eq(ACCOUNT.ID)) +// .and(TENANT_ACCOUNT.ID.eq(1)) +// .unionAll(select(TENANT_ACCOUNT.ALL_COLUMNS).from(TENANT_ACCOUNT) +// .where(TENANT_ACCOUNT.ID.eq(2)) +// ) +// ); // mapper.deleteBatchByIds(Arrays.asList(1, 2));