You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.5 KiB
94 lines
2.5 KiB
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using CellularManagement.Domain.Entities.Device;
|
|
|
|
namespace CellularManagement.Infrastructure.Configurations.Device;
|
|
|
|
/// <summary>
|
|
/// 用例数据库配置
|
|
/// </summary>
|
|
public class TestCaseConfiguration : IEntityTypeConfiguration<TestCase>
|
|
{
|
|
/// <summary>
|
|
/// 配置用例实体
|
|
/// </summary>
|
|
public void Configure(EntityTypeBuilder<TestCase> builder)
|
|
{
|
|
// 表名
|
|
builder.ToTable("TestCases");
|
|
|
|
// 主键
|
|
builder.HasKey(x => x.Id);
|
|
|
|
// 属性配置
|
|
builder.Property(x => x.Id)
|
|
.HasMaxLength(50)
|
|
.IsRequired();
|
|
|
|
builder.Property(x => x.Code)
|
|
.HasMaxLength(50)
|
|
.IsRequired();
|
|
|
|
builder.Property(x => x.Name)
|
|
.HasMaxLength(100)
|
|
.IsRequired();
|
|
|
|
builder.Property(x => x.UserCount)
|
|
.IsRequired()
|
|
.HasDefaultValue(1);
|
|
|
|
builder.Property(x => x.UserInfoList)
|
|
.HasMaxLength(4000);
|
|
|
|
builder.Property(x => x.LatencyThresholdCount)
|
|
.IsRequired()
|
|
.HasDefaultValue(0);
|
|
|
|
builder.Property(x => x.LatencyThresholdList)
|
|
.HasMaxLength(2000);
|
|
|
|
builder.Property(x => x.ThroughputThresholdCount)
|
|
.IsRequired()
|
|
.HasDefaultValue(0);
|
|
|
|
builder.Property(x => x.ThroughputThresholdList)
|
|
.HasMaxLength(2000);
|
|
|
|
builder.Property(x => x.Description)
|
|
.HasMaxLength(1000);
|
|
|
|
builder.Property(x => x.Version)
|
|
.HasMaxLength(20)
|
|
.IsRequired();
|
|
|
|
builder.Property(x => x.VersionUpdateInfo)
|
|
.HasMaxLength(500);
|
|
|
|
builder.Property(x => x.IsDisabled)
|
|
.IsRequired()
|
|
.HasDefaultValue(false);
|
|
|
|
builder.Property(x => x.Remarks)
|
|
.HasMaxLength(1000);
|
|
|
|
// 索引
|
|
builder.HasIndex(x => x.Code)
|
|
.IsUnique()
|
|
.HasFilter("\"IsDeleted\" = false");
|
|
|
|
builder.HasIndex(x => x.Version)
|
|
.HasFilter("\"IsDeleted\" = false");
|
|
|
|
builder.HasIndex(x => x.Name)
|
|
.HasFilter("\"IsDeleted\" = false");
|
|
|
|
builder.HasIndex(x => x.IsDisabled)
|
|
.HasFilter("\"IsDeleted\" = false");
|
|
|
|
builder.HasIndex(x => x.CreatedAt)
|
|
.HasFilter("\"IsDeleted\" = false");
|
|
|
|
// 软删除过滤器
|
|
builder.HasQueryFilter(x => !x.IsDeleted);
|
|
}
|
|
}
|