mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 17:48:25 +08:00
fix: 测试多租户表名参数。
This commit is contained in:
parent
cd993b01d5
commit
1319e71115
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.mybatisflex.test;
|
package com.mybatisflex.test;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Column;
|
||||||
import com.mybatisflex.annotation.ColumnMask;
|
import com.mybatisflex.annotation.ColumnMask;
|
||||||
import com.mybatisflex.annotation.Id;
|
import com.mybatisflex.annotation.Id;
|
||||||
import com.mybatisflex.annotation.KeyType;
|
import com.mybatisflex.annotation.KeyType;
|
||||||
@ -37,7 +38,7 @@ public class TenantAccount {
|
|||||||
|
|
||||||
private Date birthday;
|
private Date birthday;
|
||||||
|
|
||||||
// @Column(tenantId = true)
|
@Column(tenantId = true)
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
|
|||||||
@ -17,16 +17,13 @@
|
|||||||
package com.mybatisflex.test;
|
package com.mybatisflex.test;
|
||||||
|
|
||||||
import com.mybatisflex.core.MybatisFlexBootstrap;
|
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.core.tenant.TenantManager;
|
||||||
import com.mybatisflex.mapper.TenantAccountMapper;
|
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.EmbeddedDatabaseBuilder;
|
||||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TenantManagerTester {
|
public class TenantManagerTester {
|
||||||
|
|
||||||
@ -40,18 +37,16 @@ public class TenantManagerTester {
|
|||||||
MybatisFlexBootstrap.getInstance()
|
MybatisFlexBootstrap.getInstance()
|
||||||
.setDataSource(dataSource)
|
.setDataSource(dataSource)
|
||||||
.addMapper(TenantAccountMapper.class)
|
.addMapper(TenantAccountMapper.class)
|
||||||
|
.setLogImpl(StdOutImpl.class)
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
//输出日志
|
// 配置 tenantFactory
|
||||||
AuditManager.setAuditEnable(true);
|
|
||||||
AuditManager.setMessageCollector(new ConsoleMessageCollector());
|
|
||||||
|
|
||||||
//配置 tenantFactory
|
|
||||||
TenantManager.setTenantFactory(() -> new Object[]{1});
|
TenantManager.setTenantFactory(() -> new Object[]{1});
|
||||||
|
|
||||||
TenantAccountMapper mapper = MybatisFlexBootstrap.getInstance().getMapper(TenantAccountMapper.class);
|
MybatisFlexBootstrap.getInstance()
|
||||||
List<TenantAccount> tenantAccounts = TenantManager.withoutTenantCondition(mapper::selectAll);
|
.getMapper(TenantAccountMapper.class)
|
||||||
System.out.println(tenantAccounts);
|
.selectAll()
|
||||||
|
.forEach(System.out::println);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user