docs: 更新项目架构与数据模型文档
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,27 +4,31 @@
|
||||
|
||||
---
|
||||
|
||||
## 1. 配置文件结构
|
||||
## 1. 配置文件
|
||||
|
||||
```json
|
||||
// Configuration/appsettings.json
|
||||
{
|
||||
"Database": {
|
||||
"Type": "sqlite",
|
||||
"Path": "./data/database/wctminer.db"
|
||||
"LocalPath": "./data/database/local.db",
|
||||
"ReleasePath": "./data/database/release.db"
|
||||
},
|
||||
"Parser": {
|
||||
"BatchSize": 1000
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Gpulse.WCT.DataAnalyzer": "Debug"
|
||||
}
|
||||
},
|
||||
"Paths": {
|
||||
"LogDir": "./data/logs",
|
||||
"OutputDir": "./data/output"
|
||||
},
|
||||
"Aggregation": {
|
||||
"TxPanelMappings": {
|
||||
"single-mold": "奇瑞",
|
||||
"dual-rapid": "智己"
|
||||
},
|
||||
"CarModelMappings": {
|
||||
"L6": "L6",
|
||||
"CM3": "CM3"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -34,8 +38,8 @@
|
||||
## 2. 配置类定义
|
||||
|
||||
```csharp
|
||||
// Configuration/AppSettings.cs
|
||||
namespace Gpulse.WCT.DataAnalyzer.Configuration;
|
||||
// Infrastructure/Configuration/AppSettings.cs
|
||||
namespace Gpulse.WCT.DataAnalyzer.Core.Infrastructure.Configuration;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
@@ -47,8 +51,9 @@ public class AppSettings
|
||||
public class DatabaseSettings
|
||||
{
|
||||
public string Type { get; set; } = "sqlite";
|
||||
public string Path { get; set; } = "./data/database/wctminer.db";
|
||||
|
||||
public string LocalPath { get; set; } = "./data/database/local.db";
|
||||
public string ReleasePath { get; set; } = "./data/database/release.db";
|
||||
|
||||
// PostgreSQL 配置(可选)
|
||||
public string? Host { get; set; }
|
||||
public int Port { get; set; } = 5432;
|
||||
@@ -71,35 +76,51 @@ public class PathSettings
|
||||
|
||||
---
|
||||
|
||||
## 3. 配置加载
|
||||
## 3. 数据库配置说明
|
||||
|
||||
```csharp
|
||||
// Program.cs 配置加载部分
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Gpulse.WCT.DataAnalyzer.Configuration;
|
||||
### 双数据库路径
|
||||
|
||||
var builder = Host.CreateDefaultBuilder(args);
|
||||
| 配置键 | 默认值 | 说明 |
|
||||
|--------|--------|------|
|
||||
| `Database:LocalPath` | `./data/database/local.db` | 本地解析库 |
|
||||
| `Database:ReleasePath` | `./data/database/release.db` | 正式发布库 |
|
||||
|
||||
builder.ConfigureAppConfiguration(config =>
|
||||
两个数据库独立配置,可以位于不同路径,也可以使用不同类型的数据库。
|
||||
|
||||
### 兼容旧配置
|
||||
|
||||
`Database:Path` 仍然作为 local 数据库的 fallback 路径,推荐使用 `Database:LocalPath`。
|
||||
|
||||
### PostgreSQL 支持
|
||||
|
||||
当 `Database:Type` 设为 `postgresql` 时,local 和 release 都可以使用独立的 PostgreSQL 连接:
|
||||
|
||||
```json
|
||||
{
|
||||
config.AddJsonFile("appsettings.json", optional: false);
|
||||
config.AddJsonFile($"appsettings.{environment}.json", optional: true);
|
||||
config.AddEnvironmentVariables();
|
||||
config.AddCommandLine(args);
|
||||
});
|
||||
"Database": {
|
||||
"Type": "postgresql",
|
||||
"Host": "localhost",
|
||||
"Port": 5432,
|
||||
"Name": "wct_local",
|
||||
"User": "wct_user",
|
||||
"Password": "...",
|
||||
"ReleaseHost": "db-server",
|
||||
"ReleaseName": "wct_charging_parameters",
|
||||
"ReleaseUser": "wct_release",
|
||||
"ReleasePassword": "..."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
builder.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.Configure<AppSettings>(context.Configuration.GetSection(""));
|
||||
|
||||
// 注册数据库服务
|
||||
services.AddDatabaseServices(context.Configuration);
|
||||
|
||||
// 注册其他服务
|
||||
services.AddScoped<QfodParser>();
|
||||
services.AddScoped<PlossParser>();
|
||||
services.AddScoped<ParseService>();
|
||||
services.AddScoped<ErrorHandlingService>();
|
||||
});
|
||||
```
|
||||
Release 数据库的 PostgreSQL 配置前缀为 `Release*`,未设置时回退到 local 的对应配置。
|
||||
|
||||
---
|
||||
|
||||
## 4. 聚合配置
|
||||
|
||||
| 配置键 | 说明 |
|
||||
|--------|------|
|
||||
| `Aggregation:TxPanelMappings` | TxPanel 名称 → 车厂名称的映射表 |
|
||||
| `Aggregation:CarModelMappings` | TxHardware 版本 → 车型名称的映射表 |
|
||||
|
||||
未配置映射时,直接使用 TxPanel.Name 和 TxHardware.Version 作为最终值。手机品牌/型号从 RxType.Name 自动拆分(分隔符 `/_:`)。
|
||||
Reference in New Issue
Block a user