| | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.Set; |
| | | |
| | |
| | | |
| | | @Override |
| | | public Expression getTenantId() { |
| | | Integer tenantId = SecurityUtils.getLoginUser().getTenantId(); |
| | | return new LongValue(tenantId); |
| | | try { |
| | | Long tenantId = SecurityUtils.getLoginUser().getTenantId(); |
| | | return new LongValue(tenantId); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 线程级临时忽略开关:某些 insert 场景下 jsqlparser 解析会抛 |
| | | * ClassCastException: SetOperationList cannot be cast to PlainSelect, |
| | | * 可在该线程内临时跳过租户插件(tenant_id 由 MybatisHandler 自动填充保证)。 |
| | | */ |
| | | public static final ThreadLocal<Boolean> TEMP_IGNORE = new ThreadLocal<>(); |
| | | |
| | | @Override |
| | | public boolean ignoreTable(String tableName) { |
| | | if (Boolean.TRUE.equals(TEMP_IGNORE.get())) { |
| | | return true; |
| | | } |
| | | // 指定不需要添加过滤条件的表 |
| | | Set<String> ignoreTables = IgnoreTableConfig.IGNORE_TABLES; |
| | | return ignoreTables.contains(tableName); |