feat: 实现动态租户解析与移除菜单回退逻辑

1. 新增 ITenantCodeResolver 接口和 DatabaseTenantCodeResolver 实现
2. 修改 TenantResolutionMiddleware 支持从数据库动态解析租户编码
3. ITenantRepository 新增 FindIdByCodeAsync 方法
4. 移除 EfMenuRepository 中危险的系统菜单回退逻辑
5. 调整服务注册顺序确保依赖正确注入

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
MSuMshk
2026-02-03 13:05:52 +08:00
parent cfacbf8363
commit e88c41c11e
10 changed files with 103 additions and 49 deletions

View File

@@ -85,8 +85,7 @@ if (isDevelopment)
});
}
// 5. 注册多租户解析、鉴权授权与权限策略
builder.Services.AddTenantResolution(builder.Configuration);
// 5. 注册鉴权授权与权限策略
builder.Services.AddJwtAuthentication(builder.Configuration);
builder.Services.AddAuthorization();
builder.Services.AddPermissionAuthorization();
@@ -98,6 +97,9 @@ builder.Services.AddIdentityApplication(enableMiniSupport: false);
builder.Services.AddAppInfrastructure(builder.Configuration);
builder.Services.AddIdentityInfrastructure(builder.Configuration, enableMiniFeatures: false, enableAdminSeed: false);
// 7. 注册多租户解析(依赖 ITenantRepository需在 Infrastructure 之后)
builder.Services.AddTenantResolution(builder.Configuration);
// 6. (空行后) 注册字典模块(系统参数、字典项、缓存等)
builder.Services.AddDictionaryApplication();
builder.Services.AddDictionaryInfrastructure(builder.Configuration);

View File

@@ -56,7 +56,9 @@
"/health",
"/healthz"
],
"RootDomain": ""
"RootDomain": "laosankeji.com",
"CodeTenantMap": {},
"ThrowIfUnresolved": false
},
"Cors": {
"Tenant": []