- 新增 GatewayAggregate 领域实体 (GwTenant, GwTenantRoute, GwServiceInstance) - 新增 IRouteStore, RouteStore, IInstanceStore, InstanceStore - 新增 IRouteManager, RouteManager - 合并 GatewayDbContext 到 PlatformDbContext - 统一 Extensions.AddPlatformCore 注册所有服务
139 lines
4.5 KiB
Markdown
139 lines
4.5 KiB
Markdown
# 代码库结构
|
||
|
||
**分析日期:** 2026-02-28
|
||
|
||
## 目录布局
|
||
|
||
```
|
||
fengling-platform/
|
||
├── Fengling.Platform.Domain/
|
||
│ ├── AggregatesModel/
|
||
│ │ ├── UserAggregate/
|
||
│ │ │ ├── ApplicationUser.cs
|
||
│ │ │ ├── AuditLog.cs
|
||
│ │ │ └── AccessLog.cs
|
||
│ │ ├── RoleAggregate/
|
||
│ │ │ └── ApplicationRole.cs
|
||
│ │ └── TenantAggregate/
|
||
│ │ ├── Tenant.cs
|
||
│ │ └── TenantInfo.cs
|
||
│ ├── GlobalUsings.cs
|
||
│ └── Fengling.Platform.Domain.csproj
|
||
├── Fengling.Platform.Infrastructure/
|
||
│ ├── Configurations/
|
||
│ │ └── TenantConfiguration.cs
|
||
│ ├── Migrations/
|
||
│ │ ├── 20260221065049_Initial.cs
|
||
│ │ ├── 20260221065049_Initial.Designer.cs
|
||
│ │ ├── 20260221071055_OpenIddict.cs
|
||
│ │ ├── 20260221071055_OpenIddict.Designer.cs
|
||
│ │ └── PlatformDbContextModelSnapshot.cs
|
||
│ ├── Extensions.cs
|
||
│ ├── GlobalUsings.cs
|
||
│ ├── ITenantStore.cs
|
||
│ ├── TenantManager.cs
|
||
│ ├── TenantStore.cs
|
||
│ ├── PlatformDbContext.cs
|
||
│ ├── SeedData.cs
|
||
│ ├── DesignTimeApplicationDbContextFactory.cs
|
||
│ └── Fengling.Platform.Infrastructure.csproj
|
||
├── Directory.Packages.props
|
||
├── NuGet.Config
|
||
├── Dockerfile
|
||
└── AGENTS.md
|
||
```
|
||
|
||
## 目录用途
|
||
|
||
**Fengling.Platform.Domain:**
|
||
- 目的: 包含核心业务实体的领域层
|
||
- 包含: 聚合(Tenant、User、Role)、值对象
|
||
- 关键文件: `AggregatesModel/*/*.cs`
|
||
|
||
**Fengling.Platform.Infrastructure:**
|
||
- 目的: 数据访问和外部关注的基础设施层
|
||
- 包含: DbContext、Stores、Managers、EF 配置、迁移
|
||
- 关键文件: `PlatformDbContext.cs`、`TenantStore.cs`、`TenantManager.cs`
|
||
|
||
**迁移:**
|
||
- 目的: EF Core 数据库迁移
|
||
- 已生成: 是(基于时间戳)
|
||
- 已提交: 是
|
||
|
||
## 关键文件位置
|
||
|
||
**入口点:**
|
||
- `Fengling.Platform.Infrastructure/Extensions.cs`: DI 注册入口点
|
||
- `Fengling.Platform.Infrastructure/PlatformDbContext.cs`: 数据库上下文
|
||
|
||
**配置:**
|
||
- `Directory.Packages.props`: 集中包版本管理
|
||
- `Fengling.Platform.Infrastructure/Configurations/TenantConfiguration.cs`: EF 租户配置
|
||
|
||
**核心逻辑:**
|
||
- `Fengling.Platform.Domain/AggregatesModel/TenantAggregate/Tenant.cs`: 租户实体
|
||
- `Fengling.Platform.Domain/AggregatesModel/UserAggregate/ApplicationUser.cs`: 用户实体
|
||
- `Fengling.Platform.Infrastructure/TenantStore.cs`: 租户数据访问
|
||
- `Fengling.Platform.Infrastructure/TenantManager.cs`: 租户业务逻辑
|
||
|
||
## 命名约定
|
||
|
||
**文件:**
|
||
- 实体: `{EntityName}.cs`(如 `Tenant.cs`、`ApplicationUser.cs`)
|
||
- 接口: `I{InterfaceName}.cs`(如 `ITenantStore.cs`、`ITenantManager.cs`)
|
||
- 实现: `{InterfaceName}.cs`(如 `TenantStore.cs`)
|
||
|
||
**目录:**
|
||
- 聚合: `*Aggregate/`(如 `TenantAggregate/`)
|
||
- 配置: `Configurations/`
|
||
- 迁移: `Migrations/`
|
||
|
||
**类:**
|
||
- 实体: PascalCase(如 `ApplicationUser`、`Tenant`)
|
||
- 枚举: PascalCase(如 `TenantStatus`)
|
||
- 值对象: PascalCase 记录(如 `TenantInfo`)
|
||
|
||
## 新增代码位置
|
||
|
||
**新聚合:**
|
||
- 领域实体: `Fengling.Platform.Domain/AggregatesModel/{AggregateName}/`
|
||
- Store 接口: `Fengling.Platform.Infrastructure/I{EntityName}Store.cs`
|
||
- Store 实现: `Fengling.Platform.Infrastructure/{EntityName}Store.cs`
|
||
- Manager 接口: `Fengling.Platform.Infrastructure/I{EntityName}Manager.cs`
|
||
- Manager 实现: `Fengling.Platform.Infrastructure/{EntityName}Manager.cs`
|
||
- EF 配置: `Fengling.Platform.Infrastructure/Configurations/`
|
||
|
||
**新实体属性:**
|
||
- 领域: 在 `AggregatesModel/` 中的现有实体添加
|
||
- 基础设施: 在 `Configurations/` 中添加配置或在 `PlatformDbContext.OnModelCreating()` 中添加
|
||
|
||
**新迁移:**
|
||
- 位置: `Fengling.Platform.Infrastructure/Migrations/`
|
||
- 通过以下方式生成: 从 Infrastructure 目录运行 `dotnet ef migrations add`
|
||
|
||
## 特殊目录
|
||
|
||
**迁移:**
|
||
- 目的: EF Core 数据库模式迁移
|
||
- 已生成: 是(由 dotnet ef 自动生成)
|
||
- 已提交: 是(纳入版本控制)
|
||
|
||
**配置:**
|
||
- 目的: EF Core 实体配置
|
||
- 包含: IEntityTypeConfiguration 实现
|
||
|
||
## 依赖关系
|
||
|
||
**Domain → Infrastructure:**
|
||
- Domain 引用: Microsoft.AspNetCore.Identity(仅接口)
|
||
- Domain 不引用 EF Core
|
||
|
||
**Infrastructure → Domain:**
|
||
- Infrastructure 引用: Fengling.Platform.Domain
|
||
- Infrastructure 引用: Microsoft.EntityFrameworkCore
|
||
- Infrastructure 引用: Npgsql.EntityFrameworkCore.PostgreSQL
|
||
|
||
---
|
||
|
||
*结构分析: 2026-02-28*
|