fengling-platform/.planning/phases/01-gateway-routing/01-gateway-routing-02-PLAN.md
movingsam 1b8c937aa4
Some checks failed
Build and Push Docker / build (push) Failing after 23s
Publish NuGet Packages / build (push) Failing after 8s
feat: 添加 Gateway 路由实体到 Platform
- 新增 GatewayAggregate 领域实体 (GwTenant, GwTenantRoute, GwServiceInstance)
- 新增 IRouteStore, RouteStore, IInstanceStore, InstanceStore
- 新增 IRouteManager, RouteManager
- 合并 GatewayDbContext 到 PlatformDbContext
- 统一 Extensions.AddPlatformCore 注册所有服务
2026-02-28 23:53:00 +08:00

5.0 KiB
Raw Blame History

phase plan type wave depends_on files_modified autonomous requirements must_haves
01-gateway-routing 02 execute 1
Fengling.Platform.Infrastructure/GatewayDbContext.cs
Fengling.Platform.Infrastructure/IRouteStore.cs
Fengling.Platform.Infrastructure/RouteStore.cs
Fengling.Platform.Infrastructure/IRouteManager.cs
Fengling.Platform.Infrastructure/RouteManager.cs
Fengling.Platform.Infrastructure/IInstanceStore.cs
Fengling.Platform.Infrastructure/InstanceStore.cs
true
GATEWAY-01
GATEWAY-02
GATEWAY-03
truths artifacts key_links
Store 实现遵循 TenantStore 模式
Manager 实现委托给 Stores
DbContext 包含所有 Gateway DbSets
path provides exports
Fengling.Platform.Infrastructure/GatewayDbContext.cs Gateway 实体的 EF Core DbContext
GwTenants
GwTenantRoutes
GwServiceInstances
path provides
Fengling.Platform.Infrastructure/IRouteStore.cs 路由 CRUD 接口
path provides
Fengling.Platform.Infrastructure/RouteStore.cs 路由数据访问实现
path provides
Fengling.Platform.Infrastructure/IRouteManager.cs 路由业务操作
path provides
Fengling.Platform.Infrastructure/RouteManager.cs 路由业务逻辑
from to via pattern
RouteManager IRouteStore 构造函数注入 public RouteManager(IRouteStore store)

计划 02: 网关基础设施

目标

创建网关路由的基础设施层 - Store、Manager 和 DbContext。

目的: 实现数据访问和业务逻辑,遵循 Tenant 管理模式。

输出: GatewayDbContext、Store 接口/实现、Manager 接口/实现。

上下文

@Fengling.Platform.Infrastructure/Extensions.cs (DI 注册模式) @Fengling.Platform.Infrastructure/TenantStore.cs (Store 模式参考) @Fengling.Platform.Infrastructure/TenantManager.cs (Manager 模式参考) @../fengling-gateway/src/Data/GatewayDbContext.cs (源 DbContext)

任务

任务 1: 创建 GatewayDbContext Fengling.Platform.Infrastructure/GatewayDbContext.cs 创建继承 DbContext 的 GatewayDbContext - 添加 DbSet GwTenants - 添加 DbSet GwTenantRoutes - 添加 DbSet GwServiceInstances - 在 OnModelCreating 中配置索引 (参考源 ../fengling-gateway)

关键索引:

  • GwTenant: TenantCode 唯一
  • GwTenantRoute: TenantCode, ServiceName, ClusterId, 复合索引 (ServiceName, IsGlobal, Status)
  • GwServiceInstance: 复合索引 (ClusterId, DestinationId) 唯一, Health 索引 dotnet build 通过 GatewayDbContext 包含所有 DbSet 和索引配置
任务 2: 创建 IRouteStore 和 RouteStore Fengling.Platform.Infrastructure/IRouteStore.cs Fengling.Platform.Infrastructure/RouteStore.cs 创建 IRouteStore 接口,包含方法: - FindByIdAsync, FindByTenantCodeAsync, FindByClusterIdAsync - GetAllAsync, GetPagedAsync, GetCountAsync - CreateAsync, UpdateAsync, DeleteAsync (返回 IdentityResult)

创建实现 IRouteStore 的 RouteStore

  • 参考 TenantStore 模式
  • 泛型约束: where TContext : GatewayDbContext
  • 实现所有 CRUD 方法,支持软删除 dotnet build 通过 IRouteStore 接口和 RouteStore 实现
任务 3: 创建 IRouteManager 和 RouteManager Fengling.Platform.Infrastructure/IRouteManager.cs Fengling.Platform.Infrastructure/RouteManager.cs 创建 IRouteManager 接口,包含方法: - FindByIdAsync, FindByTenantCodeAsync, GetAllAsync - CreateRouteAsync, UpdateRouteAsync, DeleteRouteAsync

创建实现 IRouteManager 的 RouteManager

  • 参考 TenantManager 模式
  • 构造函数: public RouteManager(IRouteStore store)
  • 委托给 IRouteStore 进行数据操作 dotnet build 通过 IRouteManager 接口和 RouteManager 实现
任务 4: 创建 IInstanceStore 和 InstanceStore Fengling.Platform.Infrastructure/IInstanceStore.cs Fengling.Platform.Infrastructure/InstanceStore.cs 创建 IInstanceStore 接口: - FindByIdAsync, FindByClusterIdAsync, FindByDestinationAsync - GetAllAsync, GetPagedAsync, GetCountAsync - CreateAsync, UpdateAsync, DeleteAsync

创建实现 IInstanceStore 的 InstanceStore

  • 类似 RouteStore 的模式
  • 重点在 ClusterId 和 DestinationId 查询 dotnet build 通过 IInstanceStore 接口和 InstanceStore 实现

验证

  • GatewayDbContext 包含所有 DbSet 可编译
  • Store 实现遵循 TenantStore 模式
  • Manager 实现委托给 Stores
  • Build 无错误通过

成功标准

基础设施层准备好进行 Extensions 集成。