Commit 7e3f92c3a320c9fada0f7bee84afee5dd955b2db
1 parent
6f7fe84c
【优化】忽略多租户的表,兼容表名带有包裹符号的情况
Showing
1 changed file
with
2 additions
and
1 deletions
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/db/TenantDatabaseInterceptor.java
| @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; | @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; | ||
| 4 | import cn.iocoder.yudao.framework.tenant.config.TenantProperties; | 4 | import cn.iocoder.yudao.framework.tenant.config.TenantProperties; |
| 5 | import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; | 5 | import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; |
| 6 | import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; | 6 | import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; |
| 7 | +import com.baomidou.mybatisplus.extension.toolkit.SqlParserUtils; | ||
| 7 | import net.sf.jsqlparser.expression.Expression; | 8 | import net.sf.jsqlparser.expression.Expression; |
| 8 | import net.sf.jsqlparser.expression.LongValue; | 9 | import net.sf.jsqlparser.expression.LongValue; |
| 9 | 10 | ||
| @@ -37,7 +38,7 @@ public class TenantDatabaseInterceptor implements TenantLineHandler { | @@ -37,7 +38,7 @@ public class TenantDatabaseInterceptor implements TenantLineHandler { | ||
| 37 | @Override | 38 | @Override |
| 38 | public boolean ignoreTable(String tableName) { | 39 | public boolean ignoreTable(String tableName) { |
| 39 | return TenantContextHolder.isIgnore() // 情况一,全局忽略多租户 | 40 | return TenantContextHolder.isIgnore() // 情况一,全局忽略多租户 |
| 40 | - || CollUtil.contains(ignoreTables, tableName); // 情况二,忽略多租户的表 | 41 | + || CollUtil.contains(ignoreTables, SqlParserUtils.removeWrapperSymbol(tableName)); // 情况二,忽略多租户的表 |
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | } | 44 | } |