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:
89
docs/data-model/entities/TxPanel维度.md
Normal file
89
docs/data-model/entities/TxPanel维度.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# tx_panel 维度表
|
||||
|
||||
> 所属模块:[数据模型概览](../概览.md)
|
||||
|
||||
---
|
||||
|
||||
## 1. 表定义
|
||||
|
||||
**表名**:`tx_panel`
|
||||
|
||||
**描述**:TX面板类型维度表,存储所有可用的面板类型
|
||||
|
||||
---
|
||||
|
||||
## 2. 字段定义
|
||||
|
||||
| 列名 | 类型 | 约束 | 说明 |
|
||||
|------|------|------|------|
|
||||
| id | UUID | PK, NOT NULL | 主键,自动生成 |
|
||||
| name | VARCHAR(50) | UNIQUE, NOT NULL | 面板类型名称 |
|
||||
| is_deleted | BOOLEAN | NOT NULL, DEFAULT FALSE | 软删除标记 |
|
||||
| created_at | TIMESTAMP | NOT NULL, DEFAULT NOW() | 创建时间 |
|
||||
|
||||
---
|
||||
|
||||
## 3. 面板类型枚举值
|
||||
|
||||
| name | 说明 |
|
||||
|------|------|
|
||||
| none | 无面板 |
|
||||
| single-mold | 单充模具面板 |
|
||||
| single-rapid | 单充快速成型面板 |
|
||||
| single-3d | 单充3D打印面板 |
|
||||
| dual-mold | 双充模具面板 |
|
||||
| dual-rapid | 双充快速成型面板 |
|
||||
| dual-3d | 双充3D打印面板 |
|
||||
|
||||
---
|
||||
|
||||
## 4. EF Core 模型
|
||||
|
||||
```csharp
|
||||
// Models/TxPanel.cs
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace WCTDataMiner.Models;
|
||||
|
||||
[Table("tx_panel")]
|
||||
public class TxPanel
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
[Column("name")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Required]
|
||||
[Column("is_deleted")]
|
||||
public bool IsDeleted { get; set; } = false;
|
||||
|
||||
[Required]
|
||||
[Column("created_at")]
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation Properties
|
||||
public ICollection<TestScenario> TestScenarios { get; set; } = [];
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. 初始化数据
|
||||
|
||||
```csharp
|
||||
// Data/SeedData.cs
|
||||
public static readonly TxPanel[] DefaultTxPanels = [
|
||||
new() { Name = "none" },
|
||||
new() { Name = "single-mold" },
|
||||
new() { Name = "single-rapid" },
|
||||
new() { Name = "single-3d" },
|
||||
new() { Name = "dual-mold" },
|
||||
new() { Name = "dual-rapid" },
|
||||
new() { Name = "dual-3d" }
|
||||
];
|
||||
```
|
||||
Reference in New Issue
Block a user