mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 17:18:24 +08:00
fix: 测试多租户表名参数。
This commit is contained in:
parent
cd993b01d5
commit
1319e71115
@ -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() {
|
||||
|
||||
@ -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<TenantAccount> tenantAccounts = TenantManager.withoutTenantCondition(mapper::selectAll);
|
||||
System.out.println(tenantAccounts);
|
||||
MybatisFlexBootstrap.getInstance()
|
||||
.getMapper(TenantAccountMapper.class)
|
||||
.selectAll()
|
||||
.forEach(System.out::println);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user