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

155 lines
5.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
phase: 01-gateway-routing
plan: 02
type: execute
wave: 1
depends_on: []
files_modified:
- 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
autonomous: true
requirements:
- GATEWAY-01
- GATEWAY-02
- GATEWAY-03
must_haves:
truths:
- "Store 实现遵循 TenantStore 模式"
- "Manager 实现委托给 Stores"
- "DbContext 包含所有 Gateway DbSets"
artifacts:
- path: "Fengling.Platform.Infrastructure/GatewayDbContext.cs"
provides: "Gateway 实体的 EF Core DbContext"
exports: ["GwTenants", "GwTenantRoutes", "GwServiceInstances"]
- path: "Fengling.Platform.Infrastructure/IRouteStore.cs"
provides: "路由 CRUD 接口"
- path: "Fengling.Platform.Infrastructure/RouteStore.cs"
provides: "路由数据访问实现"
- path: "Fengling.Platform.Infrastructure/IRouteManager.cs"
provides: "路由业务操作"
- path: "Fengling.Platform.Infrastructure/RouteManager.cs"
provides: "路由业务逻辑"
key_links:
- from: "RouteManager"
to: "IRouteStore"
via: "构造函数注入"
pattern: "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)
## 任务
<task type="auto">
<name>任务 1: 创建 GatewayDbContext</name>
<files>Fengling.Platform.Infrastructure/GatewayDbContext.cs</files>
<action>
创建继承 DbContext 的 GatewayDbContext
- 添加 DbSet<GwTenant> GwTenants
- 添加 DbSet<GwTenantRoute> GwTenantRoutes
- 添加 DbSet<GwServiceInstance> GwServiceInstances
- 在 OnModelCreating 中配置索引 (参考源 ../fengling-gateway)
关键索引:
- GwTenant: TenantCode 唯一
- GwTenantRoute: TenantCode, ServiceName, ClusterId, 复合索引 (ServiceName, IsGlobal, Status)
- GwServiceInstance: 复合索引 (ClusterId, DestinationId) 唯一, Health 索引
</action>
<verify>dotnet build 通过</verify>
<done>GatewayDbContext 包含所有 DbSet 和索引配置</done>
</task>
<task type="auto">
<name>任务 2: 创建 IRouteStore 和 RouteStore</name>
<files>
Fengling.Platform.Infrastructure/IRouteStore.cs
Fengling.Platform.Infrastructure/RouteStore.cs
</files>
<action>
创建 IRouteStore 接口,包含方法:
- FindByIdAsync, FindByTenantCodeAsync, FindByClusterIdAsync
- GetAllAsync, GetPagedAsync, GetCountAsync
- CreateAsync, UpdateAsync, DeleteAsync (返回 IdentityResult)
创建实现 IRouteStore 的 RouteStore<TContext>
- 参考 TenantStore 模式
- 泛型约束: where TContext : GatewayDbContext
- 实现所有 CRUD 方法,支持软删除
</action>
<verify>dotnet build 通过</verify>
<done>IRouteStore 接口和 RouteStore 实现</done>
</task>
<task type="auto">
<name>任务 3: 创建 IRouteManager 和 RouteManager</name>
<files>
Fengling.Platform.Infrastructure/IRouteManager.cs
Fengling.Platform.Infrastructure/RouteManager.cs
</files>
<action>
创建 IRouteManager 接口,包含方法:
- FindByIdAsync, FindByTenantCodeAsync, GetAllAsync
- CreateRouteAsync, UpdateRouteAsync, DeleteRouteAsync
创建实现 IRouteManager 的 RouteManager
- 参考 TenantManager 模式
- 构造函数: public RouteManager(IRouteStore store)
- 委托给 IRouteStore 进行数据操作
</action>
<verify>dotnet build 通过</verify>
<done>IRouteManager 接口和 RouteManager 实现</done>
</task>
<task type="auto">
<name>任务 4: 创建 IInstanceStore 和 InstanceStore</name>
<files>
Fengling.Platform.Infrastructure/IInstanceStore.cs
Fengling.Platform.Infrastructure/InstanceStore.cs
</files>
<action>
创建 IInstanceStore 接口:
- FindByIdAsync, FindByClusterIdAsync, FindByDestinationAsync
- GetAllAsync, GetPagedAsync, GetCountAsync
- CreateAsync, UpdateAsync, DeleteAsync
创建实现 IInstanceStore 的 InstanceStore<TContext>
- 类似 RouteStore 的模式
- 重点在 ClusterId 和 DestinationId 查询
</action>
<verify>dotnet build 通过</verify>
<done>IInstanceStore 接口和 InstanceStore 实现</done>
</task>
</tasks>
## 验证
- [ ] GatewayDbContext 包含所有 DbSet 可编译
- [ ] Store 实现遵循 TenantStore 模式
- [ ] Manager 实现委托给 Stores
- [ ] Build 无错误通过
## 成功标准
基础设施层准备好进行 Extensions 集成。