com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler Java Examples
The following examples show how to use
com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TenantAutoConfigure.java From microservices-platform with Apache License 2.0 | 5 votes |
@Bean public TenantHandler tenantHandler() { return new TenantHandler() { /** * 获取租户id */ @Override public Expression getTenantId(boolean where) { String tenant = TenantContextHolder.getTenant(); if (tenant != null) { return new StringValue(TenantContextHolder.getTenant()); } return new NullValue(); } /** * 获取租户列名 */ @Override public String getTenantIdColumn() { return "tenant_id"; } /** * 过滤不需要根据租户隔离的表 * @param tableName 表名 */ @Override public boolean doTableFilter(String tableName) { return tenantProperties.getIgnoreTables().stream().anyMatch( (e) -> e.equalsIgnoreCase(tableName) ); } }; }
Example #2
Source File: TenantConfiguration.java From blade-tool with GNU Lesser General Public License v3.0 | 4 votes |
/** * 自定义租户处理器 * * @return TenantHandler */ @Bean @ConditionalOnMissingBean(TenantHandler.class) public TenantHandler bladeTenantHandler() { return new BladeTenantHandler(properties); }