29 changed files with 1574 additions and 67 deletions
@ -0,0 +1,582 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using CellularManagement.Infrastructure.Context; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace X1.Infrastructure.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(AppDbContext))] |
||||
|
[Migration("20250705173130_InitProtocolVersionAndDevice")] |
||||
|
partial class InitProtocolVersionAndDevice |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("ProductVersion", "8.0.0") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63); |
||||
|
|
||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.AppRole", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("角色ID,主键"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("并发控制戳"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("创建时间"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(500) |
||||
|
.HasColumnType("character varying(500)") |
||||
|
.HasComment("角色描述"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("角色名称"); |
||||
|
|
||||
|
b.Property<string>("NormalizedName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("标准化角色名称(大写)"); |
||||
|
|
||||
|
b.Property<DateTime>("UpdatedAt") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("更新时间"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_Roles_Name"); |
||||
|
|
||||
|
b.HasIndex("NormalizedName") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("RoleNameIndex"); |
||||
|
|
||||
|
b.ToTable("Roles", null, t => |
||||
|
{ |
||||
|
t.HasComment("角色表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.AppUser", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("用户ID,主键"); |
||||
|
|
||||
|
b.Property<int>("AccessFailedCount") |
||||
|
.HasColumnType("integer") |
||||
|
.HasComment("登录失败次数"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("并发控制戳"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedTime") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("创建时间"); |
||||
|
|
||||
|
b.Property<string>("Email") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("电子邮箱"); |
||||
|
|
||||
|
b.Property<bool>("EmailConfirmed") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("邮箱是否已验证"); |
||||
|
|
||||
|
b.Property<bool>("IsActive") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("boolean") |
||||
|
.HasDefaultValue(true) |
||||
|
.HasComment("用户状态(true: 启用, false: 禁用)"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("boolean") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasComment("是否已删除"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastLoginTime") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("最后登录时间"); |
||||
|
|
||||
|
b.Property<bool>("LockoutEnabled") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("是否启用账户锁定"); |
||||
|
|
||||
|
b.Property<DateTimeOffset?>("LockoutEnd") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("账户锁定结束时间"); |
||||
|
|
||||
|
b.Property<DateTime?>("ModifiedTime") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("修改时间"); |
||||
|
|
||||
|
b.Property<string>("NormalizedEmail") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("标准化电子邮箱(大写)"); |
||||
|
|
||||
|
b.Property<string>("NormalizedUserName") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("标准化账号(大写)"); |
||||
|
|
||||
|
b.Property<string>("PasswordHash") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("密码哈希值"); |
||||
|
|
||||
|
b.Property<string>("PhoneNumber") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("电话号码"); |
||||
|
|
||||
|
b.Property<bool>("PhoneNumberConfirmed") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("电话号码是否已验证"); |
||||
|
|
||||
|
b.Property<string>("RealName") |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)") |
||||
|
.HasComment("用户名"); |
||||
|
|
||||
|
b.Property<string>("SecurityStamp") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("安全戳,用于并发控制"); |
||||
|
|
||||
|
b.Property<bool>("TwoFactorEnabled") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("是否启用双因素认证"); |
||||
|
|
||||
|
b.Property<string>("UserName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("账号"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Email") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_Users_Email"); |
||||
|
|
||||
|
b.HasIndex("NormalizedEmail") |
||||
|
.HasDatabaseName("EmailIndex"); |
||||
|
|
||||
|
b.HasIndex("NormalizedUserName") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("UserNameIndex"); |
||||
|
|
||||
|
b.HasIndex("PhoneNumber") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_Users_PhoneNumber"); |
||||
|
|
||||
|
b.HasIndex("UserName") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_Users_UserName"); |
||||
|
|
||||
|
b.ToTable("Users", null, t => |
||||
|
{ |
||||
|
t.HasComment("用户表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Device.CellularDevice", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("设备ID"); |
||||
|
|
||||
|
b.Property<int>("AgentPort") |
||||
|
.HasColumnType("integer") |
||||
|
.HasComment("Agent端口"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("创建时间"); |
||||
|
|
||||
|
b.Property<string>("CreatedBy") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(500) |
||||
|
.HasColumnType("character varying(500)") |
||||
|
.HasComment("设备描述"); |
||||
|
|
||||
|
b.Property<string>("IpAddress") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(45) |
||||
|
.HasColumnType("character varying(45)"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.HasColumnType("boolean"); |
||||
|
|
||||
|
b.Property<bool>("IsEnabled") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("是否启用"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("character varying(100)") |
||||
|
.HasComment("设备名称"); |
||||
|
|
||||
|
b.Property<string>("ProtocolVersionId") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)") |
||||
|
.HasComment("协议版本ID"); |
||||
|
|
||||
|
b.Property<string>("SerialNumber") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)") |
||||
|
.HasComment("序列号"); |
||||
|
|
||||
|
b.Property<DateTime?>("UpdatedAt") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("更新时间"); |
||||
|
|
||||
|
b.Property<string>("UpdatedBy") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("ProtocolVersionId") |
||||
|
.HasDatabaseName("IX_CellularDevices_ProtocolVersionId"); |
||||
|
|
||||
|
b.HasIndex("SerialNumber") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_CellularDevices_SerialNumber"); |
||||
|
|
||||
|
b.ToTable("CellularDevices", null, t => |
||||
|
{ |
||||
|
t.HasComment("蜂窝设备表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Device.ProtocolVersion", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("版本ID"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("创建时间"); |
||||
|
|
||||
|
b.Property<string>("CreatedBy") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(500) |
||||
|
.HasColumnType("character varying(500)") |
||||
|
.HasComment("版本描述"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.HasColumnType("boolean"); |
||||
|
|
||||
|
b.Property<bool>("IsEnabled") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("是否启用"); |
||||
|
|
||||
|
b.Property<bool>("IsForceUpdate") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("是否强制更新"); |
||||
|
|
||||
|
b.Property<string>("MinimumSupportedVersion") |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("character varying(20)") |
||||
|
.HasComment("最低支持版本"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)") |
||||
|
.HasComment("版本名称"); |
||||
|
|
||||
|
b.Property<DateTime?>("ReleaseDate") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("发布日期"); |
||||
|
|
||||
|
b.Property<DateTime?>("UpdatedAt") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("更新时间"); |
||||
|
|
||||
|
b.Property<string>("UpdatedBy") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("Version") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("character varying(20)") |
||||
|
.HasComment("版本号"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Version") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_ProtocolVersions_Version"); |
||||
|
|
||||
|
b.ToTable("ProtocolVersions", null, t => |
||||
|
{ |
||||
|
t.HasComment("协议版本表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Logging.LoginLog", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("日志ID"); |
||||
|
|
||||
|
b.Property<string>("Browser") |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("character varying(100)") |
||||
|
.HasComment("浏览器信息"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone"); |
||||
|
|
||||
|
b.Property<string>("FailureReason") |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnType("character varying(200)") |
||||
|
.HasComment("失败原因"); |
||||
|
|
||||
|
b.Property<string>("IpAddress") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)") |
||||
|
.HasComment("登录IP"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.HasColumnType("boolean"); |
||||
|
|
||||
|
b.Property<bool>("IsSuccess") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("登录状态(成功/失败)"); |
||||
|
|
||||
|
b.Property<string>("Location") |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnType("character varying(200)") |
||||
|
.HasComment("登录位置"); |
||||
|
|
||||
|
b.Property<string>("LoginSource") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)"); |
||||
|
|
||||
|
b.Property<DateTime>("LoginTime") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("登录时间"); |
||||
|
|
||||
|
b.Property<string>("LoginType") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)"); |
||||
|
|
||||
|
b.Property<string>("OperatingSystem") |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("character varying(100)") |
||||
|
.HasComment("操作系统信息"); |
||||
|
|
||||
|
b.Property<string>("SessionId") |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("character varying(100)"); |
||||
|
|
||||
|
b.Property<DateTime?>("UpdatedAt") |
||||
|
.HasColumnType("timestamp with time zone"); |
||||
|
|
||||
|
b.Property<string>("UserAgent") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(500) |
||||
|
.HasColumnType("character varying(500)") |
||||
|
.HasComment("设备信息"); |
||||
|
|
||||
|
b.Property<string>("UserId") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(450) |
||||
|
.HasColumnType("character varying(450)") |
||||
|
.HasComment("用户ID"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("IpAddress") |
||||
|
.HasDatabaseName("IX_LoginLogs_IpAddress"); |
||||
|
|
||||
|
b.HasIndex("LoginTime") |
||||
|
.HasDatabaseName("IX_LoginLogs_LoginTime"); |
||||
|
|
||||
|
b.HasIndex("UserId") |
||||
|
.HasDatabaseName("IX_LoginLogs_UserId"); |
||||
|
|
||||
|
b.HasIndex("UserId", "LoginTime") |
||||
|
.HasDatabaseName("IX_LoginLogs_UserId_LoginTime"); |
||||
|
|
||||
|
b.ToTable("LoginLogs", null, t => |
||||
|
{ |
||||
|
t.HasComment("用户登录日志表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Permission", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("Code") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnType("character varying(200)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)"); |
||||
|
|
||||
|
b.Property<string>("Type") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("Permissions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.RolePermission", b => |
||||
|
{ |
||||
|
b.Property<string>("RoleId") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("PermissionId") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone"); |
||||
|
|
||||
|
b.HasKey("RoleId", "PermissionId"); |
||||
|
|
||||
|
b.HasIndex("PermissionId"); |
||||
|
|
||||
|
b.ToTable("RolePermissions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.UserRole", b => |
||||
|
{ |
||||
|
b.Property<string>("UserId") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("RoleId") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.HasKey("UserId", "RoleId"); |
||||
|
|
||||
|
b.HasIndex("RoleId"); |
||||
|
|
||||
|
b.ToTable("UserRoles", null, t => |
||||
|
{ |
||||
|
t.HasComment("用户角色关系表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Device.CellularDevice", b => |
||||
|
{ |
||||
|
b.HasOne("CellularManagement.Domain.Entities.Device.ProtocolVersion", "ProtocolVersion") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("ProtocolVersionId") |
||||
|
.OnDelete(DeleteBehavior.Restrict) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.Navigation("ProtocolVersion"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Logging.LoginLog", b => |
||||
|
{ |
||||
|
b.HasOne("CellularManagement.Domain.Entities.AppUser", null) |
||||
|
.WithMany() |
||||
|
.HasForeignKey("UserId") |
||||
|
.OnDelete(DeleteBehavior.Restrict) |
||||
|
.IsRequired(); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.RolePermission", b => |
||||
|
{ |
||||
|
b.HasOne("CellularManagement.Domain.Entities.Permission", "Permission") |
||||
|
.WithMany("RolePermissions") |
||||
|
.HasForeignKey("PermissionId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.HasOne("CellularManagement.Domain.Entities.AppRole", "Role") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("RoleId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.Navigation("Permission"); |
||||
|
|
||||
|
b.Navigation("Role"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.UserRole", b => |
||||
|
{ |
||||
|
b.HasOne("CellularManagement.Domain.Entities.AppRole", "Role") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("RoleId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.HasOne("CellularManagement.Domain.Entities.AppUser", "User") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("UserId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.Navigation("Role"); |
||||
|
|
||||
|
b.Navigation("User"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Permission", b => |
||||
|
{ |
||||
|
b.Navigation("RolePermissions"); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,183 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace X1.Infrastructure.Migrations |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
public partial class InitProtocolVersionAndDevice : Migration |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "ProtocolType", |
||||
|
table: "ProtocolVersions"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "Version", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "character varying(20)", |
||||
|
maxLength: 20, |
||||
|
nullable: false, |
||||
|
comment: "版本号", |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(50)", |
||||
|
oldMaxLength: 50, |
||||
|
oldComment: "版本号"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<DateTime>( |
||||
|
name: "ReleaseDate", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "timestamp with time zone", |
||||
|
nullable: true, |
||||
|
comment: "发布日期", |
||||
|
oldClrType: typeof(DateTime), |
||||
|
oldType: "timestamp with time zone", |
||||
|
oldNullable: true); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "Name", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "character varying(50)", |
||||
|
maxLength: 50, |
||||
|
nullable: false, |
||||
|
comment: "版本名称", |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(50)", |
||||
|
oldMaxLength: 50); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "MinimumSupportedVersion", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "character varying(20)", |
||||
|
maxLength: 20, |
||||
|
nullable: true, |
||||
|
comment: "最低支持版本", |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(20)", |
||||
|
oldMaxLength: 20, |
||||
|
oldNullable: true); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<bool>( |
||||
|
name: "IsForceUpdate", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "boolean", |
||||
|
nullable: false, |
||||
|
comment: "是否强制更新", |
||||
|
oldClrType: typeof(bool), |
||||
|
oldType: "boolean"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<bool>( |
||||
|
name: "IsEnabled", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "boolean", |
||||
|
nullable: false, |
||||
|
comment: "是否启用", |
||||
|
oldClrType: typeof(bool), |
||||
|
oldType: "boolean"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "Description", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "character varying(500)", |
||||
|
maxLength: 500, |
||||
|
nullable: true, |
||||
|
comment: "版本描述", |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(200)", |
||||
|
oldMaxLength: 200, |
||||
|
oldNullable: true, |
||||
|
oldComment: "版本描述"); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "Version", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "character varying(50)", |
||||
|
maxLength: 50, |
||||
|
nullable: false, |
||||
|
comment: "版本号", |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(20)", |
||||
|
oldMaxLength: 20, |
||||
|
oldComment: "版本号"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<DateTime>( |
||||
|
name: "ReleaseDate", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "timestamp with time zone", |
||||
|
nullable: true, |
||||
|
oldClrType: typeof(DateTime), |
||||
|
oldType: "timestamp with time zone", |
||||
|
oldNullable: true, |
||||
|
oldComment: "发布日期"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "Name", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "character varying(50)", |
||||
|
maxLength: 50, |
||||
|
nullable: false, |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(50)", |
||||
|
oldMaxLength: 50, |
||||
|
oldComment: "版本名称"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "MinimumSupportedVersion", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "character varying(20)", |
||||
|
maxLength: 20, |
||||
|
nullable: true, |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(20)", |
||||
|
oldMaxLength: 20, |
||||
|
oldNullable: true, |
||||
|
oldComment: "最低支持版本"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<bool>( |
||||
|
name: "IsForceUpdate", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "boolean", |
||||
|
nullable: false, |
||||
|
oldClrType: typeof(bool), |
||||
|
oldType: "boolean", |
||||
|
oldComment: "是否强制更新"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<bool>( |
||||
|
name: "IsEnabled", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "boolean", |
||||
|
nullable: false, |
||||
|
oldClrType: typeof(bool), |
||||
|
oldType: "boolean", |
||||
|
oldComment: "是否启用"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "Description", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "character varying(200)", |
||||
|
maxLength: 200, |
||||
|
nullable: true, |
||||
|
comment: "版本描述", |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(500)", |
||||
|
oldMaxLength: 500, |
||||
|
oldNullable: true, |
||||
|
oldComment: "版本描述"); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "ProtocolType", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "character varying(50)", |
||||
|
maxLength: 50, |
||||
|
nullable: false, |
||||
|
defaultValue: ""); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,583 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using CellularManagement.Infrastructure.Context; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace X1.Infrastructure.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(AppDbContext))] |
||||
|
[Migration("20250705174217_UpdateProtocolVersionAndCellularDevice")] |
||||
|
partial class UpdateProtocolVersionAndCellularDevice |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("ProductVersion", "8.0.0") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63); |
||||
|
|
||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.AppRole", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("角色ID,主键"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("并发控制戳"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("创建时间"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(500) |
||||
|
.HasColumnType("character varying(500)") |
||||
|
.HasComment("角色描述"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("角色名称"); |
||||
|
|
||||
|
b.Property<string>("NormalizedName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("标准化角色名称(大写)"); |
||||
|
|
||||
|
b.Property<DateTime>("UpdatedAt") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("更新时间"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_Roles_Name"); |
||||
|
|
||||
|
b.HasIndex("NormalizedName") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("RoleNameIndex"); |
||||
|
|
||||
|
b.ToTable("Roles", null, t => |
||||
|
{ |
||||
|
t.HasComment("角色表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.AppUser", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("用户ID,主键"); |
||||
|
|
||||
|
b.Property<int>("AccessFailedCount") |
||||
|
.HasColumnType("integer") |
||||
|
.HasComment("登录失败次数"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("并发控制戳"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedTime") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("创建时间"); |
||||
|
|
||||
|
b.Property<string>("Email") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("电子邮箱"); |
||||
|
|
||||
|
b.Property<bool>("EmailConfirmed") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("邮箱是否已验证"); |
||||
|
|
||||
|
b.Property<bool>("IsActive") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("boolean") |
||||
|
.HasDefaultValue(true) |
||||
|
.HasComment("用户状态(true: 启用, false: 禁用)"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("boolean") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasComment("是否已删除"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastLoginTime") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("最后登录时间"); |
||||
|
|
||||
|
b.Property<bool>("LockoutEnabled") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("是否启用账户锁定"); |
||||
|
|
||||
|
b.Property<DateTimeOffset?>("LockoutEnd") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("账户锁定结束时间"); |
||||
|
|
||||
|
b.Property<DateTime?>("ModifiedTime") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("修改时间"); |
||||
|
|
||||
|
b.Property<string>("NormalizedEmail") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("标准化电子邮箱(大写)"); |
||||
|
|
||||
|
b.Property<string>("NormalizedUserName") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("标准化账号(大写)"); |
||||
|
|
||||
|
b.Property<string>("PasswordHash") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("密码哈希值"); |
||||
|
|
||||
|
b.Property<string>("PhoneNumber") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("电话号码"); |
||||
|
|
||||
|
b.Property<bool>("PhoneNumberConfirmed") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("电话号码是否已验证"); |
||||
|
|
||||
|
b.Property<string>("RealName") |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)") |
||||
|
.HasComment("用户名"); |
||||
|
|
||||
|
b.Property<string>("SecurityStamp") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("安全戳,用于并发控制"); |
||||
|
|
||||
|
b.Property<bool>("TwoFactorEnabled") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("是否启用双因素认证"); |
||||
|
|
||||
|
b.Property<string>("UserName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("character varying(256)") |
||||
|
.HasComment("账号"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Email") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_Users_Email"); |
||||
|
|
||||
|
b.HasIndex("NormalizedEmail") |
||||
|
.HasDatabaseName("EmailIndex"); |
||||
|
|
||||
|
b.HasIndex("NormalizedUserName") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("UserNameIndex"); |
||||
|
|
||||
|
b.HasIndex("PhoneNumber") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_Users_PhoneNumber"); |
||||
|
|
||||
|
b.HasIndex("UserName") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_Users_UserName"); |
||||
|
|
||||
|
b.ToTable("Users", null, t => |
||||
|
{ |
||||
|
t.HasComment("用户表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Device.CellularDevice", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("设备ID"); |
||||
|
|
||||
|
b.Property<int>("AgentPort") |
||||
|
.HasColumnType("integer") |
||||
|
.HasComment("Agent端口"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("创建时间"); |
||||
|
|
||||
|
b.Property<string>("CreatedBy") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(500) |
||||
|
.HasColumnType("character varying(500)") |
||||
|
.HasComment("设备描述"); |
||||
|
|
||||
|
b.Property<string>("IpAddress") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(45) |
||||
|
.HasColumnType("character varying(45)") |
||||
|
.HasComment("IP地址"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.HasColumnType("boolean"); |
||||
|
|
||||
|
b.Property<bool>("IsEnabled") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("是否启用"); |
||||
|
|
||||
|
b.Property<bool>("IsRunning") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("设备状态(启动/未启动)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("character varying(100)") |
||||
|
.HasComment("设备名称"); |
||||
|
|
||||
|
b.Property<string>("ProtocolVersionId") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)") |
||||
|
.HasComment("协议版本ID"); |
||||
|
|
||||
|
b.Property<string>("SerialNumber") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)") |
||||
|
.HasComment("序列号"); |
||||
|
|
||||
|
b.Property<DateTime?>("UpdatedAt") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("更新时间"); |
||||
|
|
||||
|
b.Property<string>("UpdatedBy") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("ProtocolVersionId") |
||||
|
.HasDatabaseName("IX_CellularDevices_ProtocolVersionId"); |
||||
|
|
||||
|
b.HasIndex("SerialNumber") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_CellularDevices_SerialNumber"); |
||||
|
|
||||
|
b.ToTable("CellularDevices", null, t => |
||||
|
{ |
||||
|
t.HasComment("蜂窝设备表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Device.ProtocolVersion", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("版本ID"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("创建时间"); |
||||
|
|
||||
|
b.Property<string>("CreatedBy") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(500) |
||||
|
.HasColumnType("character varying(500)") |
||||
|
.HasComment("版本描述"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.HasColumnType("boolean"); |
||||
|
|
||||
|
b.Property<bool>("IsEnabled") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("是否启用"); |
||||
|
|
||||
|
b.Property<string>("MinimumSupportedVersion") |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("character varying(20)") |
||||
|
.HasComment("最低支持版本"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)") |
||||
|
.HasComment("版本名称"); |
||||
|
|
||||
|
b.Property<DateTime?>("ReleaseDate") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("发布日期"); |
||||
|
|
||||
|
b.Property<DateTime?>("UpdatedAt") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("更新时间"); |
||||
|
|
||||
|
b.Property<string>("UpdatedBy") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("Version") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("character varying(20)") |
||||
|
.HasComment("版本号"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Version") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_ProtocolVersions_Version"); |
||||
|
|
||||
|
b.ToTable("ProtocolVersions", null, t => |
||||
|
{ |
||||
|
t.HasComment("协议版本表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Logging.LoginLog", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text") |
||||
|
.HasComment("日志ID"); |
||||
|
|
||||
|
b.Property<string>("Browser") |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("character varying(100)") |
||||
|
.HasComment("浏览器信息"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone"); |
||||
|
|
||||
|
b.Property<string>("FailureReason") |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnType("character varying(200)") |
||||
|
.HasComment("失败原因"); |
||||
|
|
||||
|
b.Property<string>("IpAddress") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)") |
||||
|
.HasComment("登录IP"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.HasColumnType("boolean"); |
||||
|
|
||||
|
b.Property<bool>("IsSuccess") |
||||
|
.HasColumnType("boolean") |
||||
|
.HasComment("登录状态(成功/失败)"); |
||||
|
|
||||
|
b.Property<string>("Location") |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnType("character varying(200)") |
||||
|
.HasComment("登录位置"); |
||||
|
|
||||
|
b.Property<string>("LoginSource") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)"); |
||||
|
|
||||
|
b.Property<DateTime>("LoginTime") |
||||
|
.HasColumnType("timestamp with time zone") |
||||
|
.HasComment("登录时间"); |
||||
|
|
||||
|
b.Property<string>("LoginType") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)"); |
||||
|
|
||||
|
b.Property<string>("OperatingSystem") |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("character varying(100)") |
||||
|
.HasComment("操作系统信息"); |
||||
|
|
||||
|
b.Property<string>("SessionId") |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("character varying(100)"); |
||||
|
|
||||
|
b.Property<DateTime?>("UpdatedAt") |
||||
|
.HasColumnType("timestamp with time zone"); |
||||
|
|
||||
|
b.Property<string>("UserAgent") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(500) |
||||
|
.HasColumnType("character varying(500)") |
||||
|
.HasComment("设备信息"); |
||||
|
|
||||
|
b.Property<string>("UserId") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(450) |
||||
|
.HasColumnType("character varying(450)") |
||||
|
.HasComment("用户ID"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("IpAddress") |
||||
|
.HasDatabaseName("IX_LoginLogs_IpAddress"); |
||||
|
|
||||
|
b.HasIndex("LoginTime") |
||||
|
.HasDatabaseName("IX_LoginLogs_LoginTime"); |
||||
|
|
||||
|
b.HasIndex("UserId") |
||||
|
.HasDatabaseName("IX_LoginLogs_UserId"); |
||||
|
|
||||
|
b.HasIndex("UserId", "LoginTime") |
||||
|
.HasDatabaseName("IX_LoginLogs_UserId_LoginTime"); |
||||
|
|
||||
|
b.ToTable("LoginLogs", null, t => |
||||
|
{ |
||||
|
t.HasComment("用户登录日志表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Permission", b => |
||||
|
{ |
||||
|
b.Property<string>("Id") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("Code") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnType("character varying(200)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)"); |
||||
|
|
||||
|
b.Property<string>("Type") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("character varying(50)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("Permissions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.RolePermission", b => |
||||
|
{ |
||||
|
b.Property<string>("RoleId") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("PermissionId") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("timestamp with time zone"); |
||||
|
|
||||
|
b.HasKey("RoleId", "PermissionId"); |
||||
|
|
||||
|
b.HasIndex("PermissionId"); |
||||
|
|
||||
|
b.ToTable("RolePermissions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.UserRole", b => |
||||
|
{ |
||||
|
b.Property<string>("UserId") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.Property<string>("RoleId") |
||||
|
.HasColumnType("text"); |
||||
|
|
||||
|
b.HasKey("UserId", "RoleId"); |
||||
|
|
||||
|
b.HasIndex("RoleId"); |
||||
|
|
||||
|
b.ToTable("UserRoles", null, t => |
||||
|
{ |
||||
|
t.HasComment("用户角色关系表"); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Device.CellularDevice", b => |
||||
|
{ |
||||
|
b.HasOne("CellularManagement.Domain.Entities.Device.ProtocolVersion", "ProtocolVersion") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("ProtocolVersionId") |
||||
|
.OnDelete(DeleteBehavior.Restrict) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.Navigation("ProtocolVersion"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Logging.LoginLog", b => |
||||
|
{ |
||||
|
b.HasOne("CellularManagement.Domain.Entities.AppUser", null) |
||||
|
.WithMany() |
||||
|
.HasForeignKey("UserId") |
||||
|
.OnDelete(DeleteBehavior.Restrict) |
||||
|
.IsRequired(); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.RolePermission", b => |
||||
|
{ |
||||
|
b.HasOne("CellularManagement.Domain.Entities.Permission", "Permission") |
||||
|
.WithMany("RolePermissions") |
||||
|
.HasForeignKey("PermissionId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.HasOne("CellularManagement.Domain.Entities.AppRole", "Role") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("RoleId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.Navigation("Permission"); |
||||
|
|
||||
|
b.Navigation("Role"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.UserRole", b => |
||||
|
{ |
||||
|
b.HasOne("CellularManagement.Domain.Entities.AppRole", "Role") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("RoleId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.HasOne("CellularManagement.Domain.Entities.AppUser", "User") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("UserId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.Navigation("Role"); |
||||
|
|
||||
|
b.Navigation("User"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("CellularManagement.Domain.Entities.Permission", b => |
||||
|
{ |
||||
|
b.Navigation("RolePermissions"); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,64 @@ |
|||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace X1.Infrastructure.Migrations |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
public partial class UpdateProtocolVersionAndCellularDevice : Migration |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "IsForceUpdate", |
||||
|
table: "ProtocolVersions"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "IpAddress", |
||||
|
table: "CellularDevices", |
||||
|
type: "character varying(45)", |
||||
|
maxLength: 45, |
||||
|
nullable: false, |
||||
|
comment: "IP地址", |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(45)", |
||||
|
oldMaxLength: 45); |
||||
|
|
||||
|
migrationBuilder.AddColumn<bool>( |
||||
|
name: "IsRunning", |
||||
|
table: "CellularDevices", |
||||
|
type: "boolean", |
||||
|
nullable: false, |
||||
|
defaultValue: false, |
||||
|
comment: "设备状态(启动/未启动)"); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "IsRunning", |
||||
|
table: "CellularDevices"); |
||||
|
|
||||
|
migrationBuilder.AddColumn<bool>( |
||||
|
name: "IsForceUpdate", |
||||
|
table: "ProtocolVersions", |
||||
|
type: "boolean", |
||||
|
nullable: false, |
||||
|
defaultValue: false, |
||||
|
comment: "是否强制更新"); |
||||
|
|
||||
|
migrationBuilder.AlterColumn<string>( |
||||
|
name: "IpAddress", |
||||
|
table: "CellularDevices", |
||||
|
type: "character varying(45)", |
||||
|
maxLength: 45, |
||||
|
nullable: false, |
||||
|
oldClrType: typeof(string), |
||||
|
oldType: "character varying(45)", |
||||
|
oldMaxLength: 45, |
||||
|
oldComment: "IP地址"); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,73 @@ |
|||||
|
### 设备 CRUD API 测试 |
||||
|
|
||||
|
### 1. 创建设备 |
||||
|
POST {{baseUrl}}/api/devices |
||||
|
Content-Type: application/json |
||||
|
Authorization: Bearer {{token}} |
||||
|
|
||||
|
{ |
||||
|
"deviceName": "测试设备1", |
||||
|
"serialNumber": "SN001", |
||||
|
"description": "这是一个测试设备", |
||||
|
"protocolVersionId": "{{protocolVersionId}}", |
||||
|
"agentPort": 8080, |
||||
|
"ipAddress": "192.168.1.100", |
||||
|
"isEnabled": true, |
||||
|
"isRunning": false |
||||
|
} |
||||
|
|
||||
|
### 2. 创建另一个设备 |
||||
|
POST {{baseUrl}}/api/devices |
||||
|
Content-Type: application/json |
||||
|
Authorization: Bearer {{token}} |
||||
|
|
||||
|
{ |
||||
|
"deviceName": "测试设备2", |
||||
|
"serialNumber": "SN002", |
||||
|
"description": "这是另一个测试设备", |
||||
|
"protocolVersionId": "{{protocolVersionId}}", |
||||
|
"agentPort": 8081, |
||||
|
"ipAddress": "192.168.1.101", |
||||
|
"isEnabled": true, |
||||
|
"isRunning": true |
||||
|
} |
||||
|
|
||||
|
### 3. 获取设备列表 |
||||
|
GET {{baseUrl}}/api/devices?pageNumber=1&pageSize=10 |
||||
|
Authorization: Bearer {{token}} |
||||
|
|
||||
|
### 4. 搜索设备 |
||||
|
GET {{baseUrl}}/api/devices?searchTerm=测试&pageNumber=1&pageSize=10 |
||||
|
Authorization: Bearer {{token}} |
||||
|
|
||||
|
### 5. 根据ID获取设备 |
||||
|
GET {{baseUrl}}/api/devices/{{deviceId}} |
||||
|
Authorization: Bearer {{token}} |
||||
|
|
||||
|
### 6. 更新设备 |
||||
|
PUT {{baseUrl}}/api/devices/{{deviceId}} |
||||
|
Content-Type: application/json |
||||
|
Authorization: Bearer {{token}} |
||||
|
|
||||
|
{ |
||||
|
"deviceId": "{{deviceId}}", |
||||
|
"deviceName": "测试设备1(已更新)", |
||||
|
"serialNumber": "SN001-UPDATED", |
||||
|
"description": "这是一个已更新的测试设备", |
||||
|
"protocolVersionId": "{{protocolVersionId}}", |
||||
|
"agentPort": 8082, |
||||
|
"ipAddress": "192.168.1.102", |
||||
|
"isEnabled": true, |
||||
|
"isRunning": true |
||||
|
} |
||||
|
|
||||
|
### 7. 删除设备 |
||||
|
DELETE {{baseUrl}}/api/devices/{{deviceId}} |
||||
|
Authorization: Bearer {{token}} |
||||
|
|
||||
|
### 环境变量设置 |
||||
|
# 在 VS Code 的 REST Client 扩展中设置以下变量: |
||||
|
# baseUrl: http://localhost:5000 |
||||
|
# token: 你的JWT令牌 |
||||
|
# protocolVersionId: 从协议版本创建响应中获取的协议版本ID |
||||
|
# deviceId: 从设备创建响应中获取的设备ID |
Loading…
Reference in new issue