refactor: 移除X-Tenant-Group相关代码
- TenantGatewayFilter简化为仅记录日志 - 移除application.yml和application-docker.yml中的tenant-group-header配置
This commit is contained in:
parent
f3b7576bf1
commit
a8450d181f
@ -1,2 +1,2 @@
|
||||
#Thu Feb 19 19:13:53 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771499633540
|
||||
#Fri Feb 20 11:21:39 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771557699084
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#Thu Feb 19 19:13:53 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771499633542
|
||||
#Fri Feb 20 11:21:39 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771557699091
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#Thu Feb 19 19:13:53 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771499633545
|
||||
#Fri Feb 20 11:21:39 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771557699097
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#Thu Feb 19 19:13:53 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771499633544
|
||||
#Fri Feb 20 11:21:39 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771557699096
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#Thu Feb 19 19:13:53 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771499633543
|
||||
#Fri Feb 20 11:21:39 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771557699093
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#Thu Feb 19 19:13:53 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771499633542
|
||||
#Fri Feb 20 11:21:39 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771557699090
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#Thu Feb 19 19:13:53 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771499633545
|
||||
#Fri Feb 20 11:21:39 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771557699098
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#Thu Feb 19 19:13:53 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771499633543
|
||||
#Fri Feb 20 11:21:39 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771557699092
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#Thu Feb 19 19:13:53 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771499633544
|
||||
#Fri Feb 20 11:21:39 CST 2026
|
||||
central|https\://repo1.maven.org/maven2|null=1771557699094
|
||||
|
||||
@ -16,8 +16,8 @@ import java.util.List;
|
||||
/**
|
||||
* 租户信息全局过滤器
|
||||
*
|
||||
* <p>从请求头中获取用户信息(由TokenAuthFilter解析),构建租户组信息</p>
|
||||
* <p>在TokenAuthFilter之后执行,用于多租户路由</p>
|
||||
* <p>从请求头中获取用户信息(由TokenAuthFilter解析)</p>
|
||||
* <p>在TokenAuthFilter之后执行,用于日志记录</p>
|
||||
*/
|
||||
@Component
|
||||
public class TenantGatewayFilter implements GlobalFilter, Ordered {
|
||||
@ -26,7 +26,6 @@ public class TenantGatewayFilter implements GlobalFilter, Ordered {
|
||||
|
||||
// Header 名称(由TokenAuthFilter设置)
|
||||
public static final String HEADER_TENANT_ID = "X-Tenant-Id";
|
||||
public static final String HEADER_TENANT_GROUP = "X-Tenant-Group";
|
||||
public static final String HEADER_USER_ID = "X-User-Id";
|
||||
public static final String HEADER_USERNAME = "X-Username";
|
||||
|
||||
@ -51,18 +50,10 @@ public class TenantGatewayFilter implements GlobalFilter, Ordered {
|
||||
String userId = request.getHeaders().getFirst(HEADER_USER_ID);
|
||||
String username = request.getHeaders().getFirst(HEADER_USERNAME);
|
||||
|
||||
// 构建租户组信息
|
||||
String tenantGroup = buildTenantGroup(tenantId);
|
||||
logger.debug("[TenantGateway] 租户ID: {}, 用户ID: {}, 用户名: {}, 路径: {}",
|
||||
tenantId, userId, username, path);
|
||||
|
||||
// 将租户组信息写入请求头
|
||||
ServerHttpRequest mutatedRequest = request.mutate()
|
||||
.header(HEADER_TENANT_GROUP, tenantGroup)
|
||||
.build();
|
||||
|
||||
logger.debug("[TenantGateway] 租户ID: {}, 租户组: {}, 用户: {}, 路径: {}",
|
||||
tenantId, tenantGroup, username, path);
|
||||
|
||||
return chain.filter(exchange.mutate().request(mutatedRequest).build());
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,16 +63,6 @@ public class TenantGatewayFilter implements GlobalFilter, Ordered {
|
||||
return WHITE_LIST.stream().anyMatch(path::startsWith);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建租户组名称
|
||||
*/
|
||||
private String buildTenantGroup(String tenantId) {
|
||||
if (tenantId == null || tenantId.isEmpty()) {
|
||||
return "DEFAULT";
|
||||
}
|
||||
return "TENANT_" + tenantId.toUpperCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE + 2; // 在TokenAuthFilter之后执行
|
||||
|
||||
@ -73,7 +73,6 @@ tenant:
|
||||
routing:
|
||||
enabled: true
|
||||
tenant-header: X-Tenant-Id
|
||||
tenant-group-header: X-Tenant-Group
|
||||
default-tenant-id: "1"
|
||||
shared-services:
|
||||
- fund-gateway
|
||||
|
||||
@ -76,12 +76,11 @@ logging:
|
||||
pattern:
|
||||
console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
|
||||
|
||||
# 多租户路由配置(服务实例只需声明自己的租户组)
|
||||
# 多租户路由配置
|
||||
tenant:
|
||||
routing:
|
||||
enabled: true
|
||||
tenant-header: X-Tenant-Id
|
||||
tenant-group-header: X-Tenant-Group
|
||||
default-tenant-id: "1"
|
||||
# 共享服务列表
|
||||
shared-services:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user