From 1319e711159c3fa8de79926133b1c277933d57d0 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Mon, 18 Mar 2024 14:45:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95=E5=A4=9A=E7=A7=9F?= =?UTF-8?q?=E6=88=B7=E8=A1=A8=E5=90=8D=E5=8F=82=E6=95=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mybatisflex/test/TenantAccount.java | 3 ++- .../mybatisflex/test/TenantManagerTester.java | 19 +++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) 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 58b0bbdf..3e94a6d4 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,6 +16,7 @@ package com.mybatisflex.test; +import com.mybatisflex.annotation.Column; import com.mybatisflex.annotation.ColumnMask; import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.KeyType; @@ -37,7 +38,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/TenantManagerTester.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/TenantManagerTester.java index 14c51a8d..6fa6038c 100644 --- a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/TenantManagerTester.java +++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/TenantManagerTester.java @@ -17,16 +17,13 @@ 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.tenant.TenantFactory; import com.mybatisflex.core.tenant.TenantManager; import com.mybatisflex.mapper.TenantAccountMapper; +import org.apache.ibatis.logging.stdout.StdOutImpl; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import javax.sql.DataSource; -import java.util.List; public class TenantManagerTester { @@ -40,18 +37,16 @@ public class TenantManagerTester { MybatisFlexBootstrap.getInstance() .setDataSource(dataSource) .addMapper(TenantAccountMapper.class) + .setLogImpl(StdOutImpl.class) .start(); - //输出日志 - AuditManager.setAuditEnable(true); - AuditManager.setMessageCollector(new ConsoleMessageCollector()); - - //配置 tenantFactory + // 配置 tenantFactory TenantManager.setTenantFactory(() -> new Object[]{1}); - TenantAccountMapper mapper = MybatisFlexBootstrap.getInstance().getMapper(TenantAccountMapper.class); - List tenantAccounts = TenantManager.withoutTenantCondition(mapper::selectAll); - System.out.println(tenantAccounts); + MybatisFlexBootstrap.getInstance() + .getMapper(TenantAccountMapper.class) + .selectAll() + .forEach(System.out::println); } }