build: continew-starter 2.13.1 => 2.13.2-SNAPSHOT

1.移除 DefaultTenantLineHandler
2.Starter 里调整了租户拦截器优先级
This commit is contained in:
2025-07-19 23:59:43 +08:00
parent dec5d611be
commit 2f445d9150
4 changed files with 9 additions and 98 deletions

View File

@@ -1,73 +0,0 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.continew.admin.tenant.config;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;
import net.sf.jsqlparser.expression.NullValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.continew.starter.extension.tenant.autoconfigure.TenantProperties;
import top.continew.starter.extension.tenant.context.TenantContextHolder;
import top.continew.starter.extension.tenant.enums.TenantIsolationLevel;
/**
* 默认租户行级隔离处理器,等待 ContiNew Starter 2.13.2 发布后替换
*
* @author Charles7c
* @since 2025/7/9 11:40
*/
public class DefaultTenantLineHandler implements TenantLineHandler {
private static final Logger log = LoggerFactory.getLogger(DefaultTenantLineHandler.class);
private final TenantProperties tenantProperties;
public DefaultTenantLineHandler(TenantProperties tenantProperties) {
this.tenantProperties = tenantProperties;
}
@Override
public Expression getTenantId() {
Long tenantId = TenantContextHolder.getTenantId();
if (tenantId != null) {
return new LongValue(tenantId);
}
log.warn("Tenant ID not found in current context.");
return new NullValue();
}
@Override
public String getTenantIdColumn() {
return tenantProperties.getTenantIdColumn();
}
@Override
public boolean ignoreTable(String tableName) {
// 忽略租户
if (TenantContextHolder.isIgnore()) {
return true;
}
// 忽略数据源级隔离
if (TenantIsolationLevel.DATASOURCE.equals(TenantContextHolder.getIsolationLevel())) {
return true;
}
// 忽略指定表
return CollUtil.contains(tenantProperties.getIgnoreTables(), tableName);
}
}

View File

@@ -16,14 +16,11 @@
package top.continew.admin.tenant.config;
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.continew.admin.tenant.service.TenantService;
import top.continew.starter.extension.tenant.annotation.ConditionalOnEnabledTenant;
import top.continew.starter.extension.tenant.autoconfigure.TenantProperties;
import top.continew.starter.extension.tenant.config.TenantProvider;
/**
@@ -35,17 +32,6 @@ import top.continew.starter.extension.tenant.config.TenantProvider;
@Configuration
public class TenantConfiguration {
@Autowired(required = false)
private TenantProperties tenantProperties;
/**
* API 文档分组配置
*/
@Bean
public GroupedOpenApi tenantApi() {
return GroupedOpenApi.builder().group("tenant").displayName("租户管理").pathsToMatch("/tenant/**").build();
}
/**
* 租户扩展配置属性
*/
@@ -54,15 +40,6 @@ public class TenantConfiguration {
return new TenantExtensionProperties();
}
/**
* 租户行级隔离处理器(默认),等待 ContiNew Starter 2.13.2 发布后替换
*/
@Bean
@ConditionalOnEnabledTenant
public TenantLineHandler tenantLineHandler() {
return new DefaultTenantLineHandler(tenantProperties);
}
/**
* 租户提供者
*/
@@ -72,4 +49,12 @@ public class TenantConfiguration {
TenantService tenantService) {
return new DefaultTenantProvider(tenantExtensionProperties, tenantService);
}
/**
* API 文档分组配置
*/
@Bean
public GroupedOpenApi tenantApi() {
return GroupedOpenApi.builder().group("tenant").displayName("租户管理").pathsToMatch("/tenant/**").build();
}
}