docs: 完善数据模型设计
- 重命名 log_file 为 test_scenario(测试场景) - 拆分维度表:tx_panel、tx_hardware、tx_software、rx_type - 采用星型模型设计,消除数据冗余 - 为所有表添加软删除字段 is_deleted - 更新关系说明,包含全局查询过滤器配置 - 更新 ER 图和查询示例 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
143
docs/architecture/模块划分.md
Normal file
143
docs/architecture/模块划分.md
Normal file
@@ -0,0 +1,143 @@
|
||||
# 模块划分
|
||||
|
||||
> 所属模块:[架构概览](./概览.md)
|
||||
|
||||
---
|
||||
|
||||
## 1. 模块总览
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ CLI Entry Point │
|
||||
│ (Program.cs / System.CommandLine) │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Service Layer │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ ParseService │ ErrorHandlingService │ ThresholdCalc │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Parser Layer │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ QfodParser │ PlossParser │ LogFileReader │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Data Layer │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Models │ WctMinerDbContext │ IDbContextFactory │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Infrastructure │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Configuration │ Serilog │ AppSettings │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. 模块职责
|
||||
|
||||
| 模块名 | 职责 | 依赖模块 |
|
||||
|--------|------|----------|
|
||||
| CLI Entry | 接收命令行参数、调度解析流程 | ParseService, Infrastructure |
|
||||
| ParseService | 协调解析流程、批量写入、统计更新 | Parser Layer, DbContext, Infrastructure |
|
||||
| LogFileReader | 读取日志文件、行过滤、文件遍历 | 无 |
|
||||
| QfodParser | 解析 Qfod 格式日志,返回 Record | LogFileReader |
|
||||
| PlossParser | 解析 Ploss 格式日志,返回 Record | LogFileReader |
|
||||
| Models | 定义数据实体结构 | 无 |
|
||||
| WctMinerDbContext | EF Core 数据库上下文 | Models |
|
||||
| Configuration | 加载配置文件 | 无 |
|
||||
| Serilog | 结构化日志输出 | 无 |
|
||||
| ErrorHandlingService | 解析错误记录、错误统计 | 无 |
|
||||
|
||||
---
|
||||
|
||||
## 3. 分层架构
|
||||
|
||||
### 3.1 分层定义
|
||||
|
||||
| 层级 | 职责 | 允许调用 |
|
||||
|------|------|----------|
|
||||
| CLI Entry | 接收参数、流程调度、结果输出 | Service, Infrastructure |
|
||||
| Service | 协调解析流程、批量写入、统计管理 | Parser, Data, Infrastructure |
|
||||
| Parser | 日志解析、数据提取、返回 Record | 无 |
|
||||
| Data | 数据持久化、DbContext 管理 | Infrastructure |
|
||||
| Infrastructure | 配置、日志、错误处理 | 无 |
|
||||
|
||||
### 3.2 依赖规则
|
||||
|
||||
- 上层可调用下层
|
||||
- 下层不可调用上层
|
||||
- Parser 之间不可互相调用(独立解析器)
|
||||
- Service 层协调 Parser 和 Data 层
|
||||
|
||||
---
|
||||
|
||||
## 4. 模块依赖图
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
CLI[CLI Entry] --> PS[ParseService]
|
||||
CLI --> Serilog
|
||||
CLI --> EHS[ErrorHandlingService]
|
||||
|
||||
PS --> QP[QfodParser]
|
||||
PS --> PP[PlossParser]
|
||||
PS --> DBM[WctMinerDbContext]
|
||||
PS --> EHS
|
||||
PS --> Serilog
|
||||
PS --> Config[Configuration]
|
||||
|
||||
QP --> LFR[LogFileReader]
|
||||
PP --> LFR
|
||||
|
||||
DBM --> Models[Models]
|
||||
|
||||
subgraph Parser Layer
|
||||
QP
|
||||
PP
|
||||
LFR
|
||||
end
|
||||
|
||||
subgraph Data Layer
|
||||
DBM
|
||||
Models
|
||||
end
|
||||
|
||||
subgraph Infrastructure
|
||||
Config
|
||||
Serilog
|
||||
EHS
|
||||
end
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. 目录结构
|
||||
|
||||
```
|
||||
src/WCTDataMiner/
|
||||
├── Parsers/
|
||||
│ ├── IParser.cs
|
||||
│ ├── QfodParser.cs
|
||||
│ ├── PlossParser.cs
|
||||
│ └── LogFileReader.cs
|
||||
├── Models/
|
||||
│ ├── LogFile.cs
|
||||
│ ├── QfodRecord.cs
|
||||
│ ├── PlossRecord.cs
|
||||
│ ├── ParseError.cs
|
||||
│ └── ParseStatus.cs
|
||||
├── Data/
|
||||
│ ├── WctMinerDbContext.cs
|
||||
│ └── IDbContextFactory.cs
|
||||
├── Services/
|
||||
│ ├── ParseService.cs
|
||||
│ ├── ThresholdCalculator.cs
|
||||
│ └── ErrorHandlingService.cs
|
||||
├── Configuration/
|
||||
│ ├── AppSettings.cs
|
||||
│ └── appsettings.json
|
||||
├── Commands/
|
||||
│ ├── ParseCommand.cs
|
||||
│ ├── StatsCommand.cs
|
||||
│ ├── ExportCommand.cs
|
||||
│ └── CleanCommand.cs
|
||||
└── Program.cs
|
||||
```
|
||||
Reference in New Issue
Block a user