Files
WCTDataMiner/docs/data-model/entities/TxPanel维度.md

114 lines
2.6 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.
# 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
namespace WCTDataMiner.Models;
public class TxPanel
{
public Guid Id { get; set; } = Guid.NewGuid();
public string Name { get; set; } = null!;
public bool IsDeleted { get; set; } = false;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
// Navigation Properties
public ICollection<TestScenario> TestScenarios { get; set; } = [];
}
```
### 配置类
```csharp
// Data/Configurations/TxPanelConfiguration.cs
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WCTDataMiner.Models;
namespace WCTDataMiner.Data.Configurations;
public class TxPanelConfiguration : IEntityTypeConfiguration<TxPanel>
{
public void Configure(EntityTypeBuilder<TxPanel> builder)
{
builder.ToTable("tx_panel");
builder.HasKey(e => e.Id);
builder.Property(e => e.Id).HasColumnName("id");
builder.Property(e => e.Name)
.IsRequired()
.HasMaxLength(50)
.HasColumnName("name");
builder.Property(e => e.IsDeleted)
.IsRequired()
.HasDefaultValue(false)
.HasColumnName("is_deleted");
builder.Property(e => e.CreatedAt)
.IsRequired()
.HasDefaultValueSql("NOW()")
.HasColumnName("created_at");
builder.HasIndex(e => e.Name).IsUnique();
}
}
```
---
## 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" }
];
```