diff --git a/Directory.Packages.props b/Directory.Packages.props
index 2cb65f2..d0dbd7e 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -23,6 +23,8 @@
+
+
diff --git a/src/Data/ConsoleDbContext.cs b/src/Data/ConsoleDbContext.cs
index 23bc7de..bb3cfe4 100644
--- a/src/Data/ConsoleDbContext.cs
+++ b/src/Data/ConsoleDbContext.cs
@@ -1,3 +1,4 @@
+using Fengling.Console.Models.Entities;
using Fengling.Platform.Domain.AggregatesModel.GatewayAggregate;
using Fengling.Platform.Domain.AggregatesModel.RoleAggregate;
using Fengling.Platform.Domain.AggregatesModel.TenantAggregate;
@@ -6,6 +7,7 @@ using Fengling.Platform.Infrastructure;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
+using System.Text.Json;
namespace Fengling.Console.Data;
@@ -19,16 +21,46 @@ public class ConsoleDbContext : PlatformDbContext
{
}
+ ///
+ /// 待确认配置表
+ ///
+ public DbSet PendingConfigs { get; set; } = null!;
+
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
- // ========== Gateway 模块 ==========
- modelBuilder.Entity(entity =>
+ // ========== PendingConfig 模块 ==========
+ modelBuilder.Entity(entity =>
{
- entity.ToTable("gw_tenant_routes");
+ entity.ToTable("gw_pending_configs");
+ entity.HasKey(e => e.Id);
+ entity.Property(e => e.Id).HasMaxLength(32);
+ entity.Property(e => e.SourceId).HasMaxLength(128);
+ entity.Property(e => e.ServiceName).HasMaxLength(256);
+ entity.Property(e => e.TenantCode).HasMaxLength(64);
+ entity.Property(e => e.ClusterId).HasMaxLength(64);
+ entity.Property(e => e.ConfirmedBy).HasMaxLength(128);
+ entity.Property(e => e.ConfigJson).HasColumnType("text");
+
+ // 创建索引
+ entity.HasIndex(e => e.Status);
+ entity.HasIndex(e => e.Source);
+ entity.HasIndex(e => e.Type);
+ entity.HasIndex(e => new { e.TenantCode, e.Status });
+ entity.HasIndex(e => new { e.ServiceName, e.Status });
});
+ // ========== Gateway 模块 ==========
+ // 忽略这些类型,让它们只作为 JSON 值对象使用(与 PlatformDbContext 保持一致)
+ modelBuilder.Ignore();
+ modelBuilder.Ignore();
+ modelBuilder.Ignore();
+ modelBuilder.Ignore();
+
+ // GwTenantRoute 已在 PlatformDbContext 中配置,这里只修改表名
+ modelBuilder.Entity().ToTable("gw_tenant_routes");
+
// ========== Tenant 模块 ==========
modelBuilder.Entity(entity =>
{
diff --git a/src/Fengling.Console.csproj b/src/Fengling.Console.csproj
index 4220245..ef36b75 100644
--- a/src/Fengling.Console.csproj
+++ b/src/Fengling.Console.csproj
@@ -29,6 +29,7 @@
+
diff --git a/src/Migrations/20260307161935_AddPendingConfig.Designer.cs b/src/Migrations/20260307161935_AddPendingConfig.Designer.cs
new file mode 100644
index 0000000..f16bc4a
--- /dev/null
+++ b/src/Migrations/20260307161935_AddPendingConfig.Designer.cs
@@ -0,0 +1,868 @@
+//
+using System;
+using System.Collections.Generic;
+using Fengling.Console.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace Fengling.Console.Migrations
+{
+ [DbContext(typeof(ConsoleDbContext))]
+ [Migration("20260307161935_AddPendingConfig")]
+ partial class AddPendingConfig
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "10.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("Fengling.Console.Models.Entities.PendingConfig", b =>
+ {
+ b.Property("Id")
+ .HasMaxLength(32)
+ .HasColumnType("character varying(32)");
+
+ b.Property("ClusterId")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("ConfigJson")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("ConfirmedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ConfirmedBy")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("IsModified")
+ .HasColumnType("boolean");
+
+ b.Property("IsNew")
+ .HasColumnType("boolean");
+
+ b.Property("ServiceName")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("Source")
+ .HasColumnType("integer");
+
+ b.Property("SourceId")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("TenantCode")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Source");
+
+ b.HasIndex("Status");
+
+ b.HasIndex("Type");
+
+ b.HasIndex("ServiceName", "Status");
+
+ b.HasIndex("TenantCode", "Status");
+
+ b.ToTable("gw_pending_configs", (string)null);
+ });
+
+ modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.GatewayAggregate.GwCluster", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("ClusterId")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("CreatedBy")
+ .HasColumnType("bigint");
+
+ b.Property("CreatedTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Description")
+ .HasMaxLength(500)
+ .HasColumnType("character varying(500)");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("LoadBalancingPolicy")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("bigint");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Version")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClusterId")
+ .IsUnique();
+
+ b.HasIndex("Name");
+
+ b.HasIndex("Status");
+
+ b.ToTable("GwClusters");
+ });
+
+ modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.GatewayAggregate.GwTenantRoute", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("AuthorizationPolicy")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("ClusterId")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("CorsPolicy")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("CreatedBy")
+ .HasColumnType("bigint");
+
+ b.Property("CreatedTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("IsGlobal")
+ .HasColumnType("boolean");
+
+ b.Property("LoadBalancingPolicy")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("Priority")
+ .HasColumnType("integer");
+
+ b.Property("RateLimiterPolicy")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("ServiceName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("TenantCode")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("TimeoutSeconds")
+ .HasColumnType("integer");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("bigint");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Version")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClusterId");
+
+ b.HasIndex("ServiceName");
+
+ b.HasIndex("TenantCode");
+
+ b.HasIndex("ServiceName", "IsGlobal", "Status");
+
+ b.ToTable("gw_tenant_routes", (string)null);
+ });
+
+ modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.RoleAggregate.ApplicationRole", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("text");
+
+ b.Property("CreatedTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Description")
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b.Property("DisplayName")
+ .HasColumnType("text");
+
+ b.Property("IsSystem")
+ .HasColumnType("boolean");
+
+ b.Property("Name")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.PrimitiveCollection>("Permissions")
+ .HasColumnType("text[]");
+
+ b.Property("TenantId")
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex");
+
+ b.ToTable("idn_roles", (string)null);
+ });
+
+ modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.TenantAggregate.Tenant", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ContactEmail")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("ContactName")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("ContactPhone")
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Description")
+ .HasMaxLength(500)
+ .HasColumnType("character varying(500)");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("MaxUsers")
+ .HasColumnType("integer");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("RowVersion")
+ .HasColumnType("bigint");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("TenantCode")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Status");
+
+ b.HasIndex("TenantCode")
+ .IsUnique();
+
+ b.ToTable("sys_tenants", (string)null);
+ });
+
+ modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.UserAggregate.AccessLog", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Action")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Duration")
+ .HasColumnType("integer");
+
+ b.Property("ErrorMessage")
+ .HasColumnType("text");
+
+ b.Property("IpAddress")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("Method")
+ .HasMaxLength(10)
+ .HasColumnType("character varying(10)");
+
+ b.Property("RequestData")
+ .HasColumnType("text");
+
+ b.Property("Resource")
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b.Property("ResponseData")
+ .HasColumnType("text");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property("TenantId")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("UserAgent")
+ .HasMaxLength(500)
+ .HasColumnType("character varying(500)");
+
+ b.Property("UserName")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Action");
+
+ b.HasIndex("CreatedAt");
+
+ b.HasIndex("Status");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("UserName");
+
+ b.ToTable("sys_access_logs", (string)null);
+ });
+
+ modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.UserAggregate.ApplicationUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("AccessFailedCount")
+ .HasColumnType("integer");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("text");
+
+ b.Property("CreatedTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Email")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("EmailConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("LockoutEnabled")
+ .HasColumnType("boolean");
+
+ b.Property("LockoutEnd")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("PasswordHash")
+ .HasColumnType("text");
+
+ b.Property("PhoneNumber")
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property("PhoneNumberConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property("RealName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("SecurityStamp")
+ .HasColumnType("text");
+
+ b.Property("TwoFactorEnabled")
+ .HasColumnType("boolean");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex");
+
+ b.HasIndex("PhoneNumber")
+ .IsUnique();
+
+ b.ToTable("idn_users", (string)null);
+ });
+
+ modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.UserAggregate.AuditLog", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Action")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Description")
+ .HasMaxLength(500)
+ .HasColumnType("character varying(500)");
+
+ b.Property("ErrorMessage")
+ .HasColumnType("text");
+
+ b.Property("IpAddress")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("NewValue")
+ .HasColumnType("text");
+
+ b.Property("OldValue")
+ .HasColumnType("text");
+
+ b.Property("Operation")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property("Operator")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property("TargetId")
+ .HasColumnType("bigint");
+
+ b.Property("TargetName")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("TargetType")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("TenantId")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Action");
+
+ b.HasIndex("CreatedAt");
+
+ b.HasIndex("Operation");
+
+ b.HasIndex("Operator");
+
+ b.HasIndex("TenantId");
+
+ b.ToTable("sys_audit_logs", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ClaimType")
+ .HasColumnType("text");
+
+ b.Property("ClaimValue")
+ .HasColumnType("text");
+
+ b.Property("RoleId")
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("idn_role_claims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ClaimType")
+ .HasColumnType("text");
+
+ b.Property("ClaimValue")
+ .HasColumnType("text");
+
+ b.Property("UserId")
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("idn_user_claims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.Property("LoginProvider")
+ .HasColumnType("text");
+
+ b.Property("ProviderKey")
+ .HasColumnType("text");
+
+ b.Property("ProviderDisplayName")
+ .HasColumnType("text");
+
+ b.Property("UserId")
+ .HasColumnType("bigint");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("idn_user_logins", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("bigint");
+
+ b.Property("RoleId")
+ .HasColumnType("bigint");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("idn_user_roles", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("bigint");
+
+ b.Property("LoginProvider")
+ .HasColumnType("text");
+
+ b.Property("Name")
+ .HasColumnType("text");
+
+ b.Property("Value")
+ .HasColumnType("text");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("idn_user_tokens", (string)null);
+ });
+
+ modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.GatewayAggregate.GwCluster", b =>
+ {
+ b.OwnsMany("Fengling.Platform.Domain.AggregatesModel.GatewayAggregate.GwDestination", "Destinations", b1 =>
+ {
+ b1.Property("ClusterId")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b1.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id"));
+
+ b1.Property("Address")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b1.Property("DestinationId")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b1.Property("Health")
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b1.Property("HealthStatus")
+ .HasColumnType("integer");
+
+ b1.Property("Status")
+ .HasColumnType("integer");
+
+ b1.Property("Weight")
+ .HasColumnType("integer");
+
+ b1.HasKey("ClusterId", "Id");
+
+ b1.HasIndex("ClusterId", "DestinationId");
+
+ b1.ToTable("GwDestination");
+
+ b1.WithOwner()
+ .HasForeignKey("ClusterId");
+ });
+
+ b.OwnsOne("Fengling.Platform.Domain.AggregatesModel.GatewayAggregate.GwHealthCheckConfig", "HealthCheck", b1 =>
+ {
+ b1.Property("GwClusterId");
+
+ b1.Property("Enabled");
+
+ b1.Property("IntervalSeconds");
+
+ b1.Property("Path");
+
+ b1.Property("TimeoutSeconds");
+
+ b1.HasKey("GwClusterId");
+
+ b1.ToTable("GwClusters");
+
+ b1.ToJson("HealthCheck");
+
+ b1.WithOwner()
+ .HasForeignKey("GwClusterId");
+ });
+
+ b.OwnsOne("Fengling.Platform.Domain.AggregatesModel.GatewayAggregate.GwSessionAffinityConfig", "SessionAffinity", b1 =>
+ {
+ b1.Property("GwClusterId");
+
+ b1.Property("AffinityKeyName")
+ .IsRequired();
+
+ b1.Property("Enabled");
+
+ b1.Property("Policy")
+ .IsRequired();
+
+ b1.HasKey("GwClusterId");
+
+ b1.ToTable("GwClusters");
+
+ b1.ToJson("SessionAffinity");
+
+ b1.WithOwner()
+ .HasForeignKey("GwClusterId");
+ });
+
+ b.Navigation("Destinations");
+
+ b.Navigation("HealthCheck");
+
+ b.Navigation("SessionAffinity");
+ });
+
+ modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.UserAggregate.ApplicationUser", b =>
+ {
+ b.OwnsOne("Fengling.Platform.Domain.AggregatesModel.TenantAggregate.TenantInfo", "TenantInfo", b1 =>
+ {
+ b1.Property("ApplicationUserId")
+ .HasColumnType("bigint");
+
+ b1.Property("TenantCode")
+ .HasColumnType("text")
+ .HasColumnName("TenantCode");
+
+ b1.Property("TenantId")
+ .HasColumnType("bigint")
+ .HasColumnName("TenantId");
+
+ b1.Property("TenantName")
+ .HasColumnType("text")
+ .HasColumnName("TenantName");
+
+ b1.HasKey("ApplicationUserId");
+
+ b1.ToTable("idn_users");
+
+ b1.WithOwner()
+ .HasForeignKey("ApplicationUserId");
+ });
+
+ b.Navigation("TenantInfo");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.HasOne("Fengling.Platform.Domain.AggregatesModel.RoleAggregate.ApplicationRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.HasOne("Fengling.Platform.Domain.AggregatesModel.UserAggregate.ApplicationUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.HasOne("Fengling.Platform.Domain.AggregatesModel.UserAggregate.ApplicationUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.HasOne("Fengling.Platform.Domain.AggregatesModel.RoleAggregate.ApplicationRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Fengling.Platform.Domain.AggregatesModel.UserAggregate.ApplicationUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.HasOne("Fengling.Platform.Domain.AggregatesModel.UserAggregate.ApplicationUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/Migrations/20260307161935_AddPendingConfig.cs b/src/Migrations/20260307161935_AddPendingConfig.cs
new file mode 100644
index 0000000..3745bea
--- /dev/null
+++ b/src/Migrations/20260307161935_AddPendingConfig.cs
@@ -0,0 +1,281 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace Fengling.Console.Migrations
+{
+ ///
+ public partial class AddPendingConfig : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "gw_service_instances");
+
+ migrationBuilder.DropTable(
+ name: "gw_tenants");
+
+ migrationBuilder.DropColumn(
+ name: "PathPattern",
+ table: "gw_tenant_routes");
+
+ migrationBuilder.AddColumn(
+ name: "AuthorizationPolicy",
+ table: "gw_tenant_routes",
+ type: "character varying(100)",
+ maxLength: 100,
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "CorsPolicy",
+ table: "gw_tenant_routes",
+ type: "character varying(100)",
+ maxLength: 100,
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "LoadBalancingPolicy",
+ table: "gw_tenant_routes",
+ type: "character varying(50)",
+ maxLength: 50,
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "RateLimiterPolicy",
+ table: "gw_tenant_routes",
+ type: "character varying(100)",
+ maxLength: 100,
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "TimeoutSeconds",
+ table: "gw_tenant_routes",
+ type: "integer",
+ nullable: true);
+
+ migrationBuilder.CreateTable(
+ name: "gw_pending_configs",
+ columns: table => new
+ {
+ Id = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
+ Type = table.Column(type: "integer", nullable: false),
+ Source = table.Column(type: "integer", nullable: false),
+ SourceId = table.Column(type: "character varying(128)", maxLength: 128, nullable: false),
+ ConfigJson = table.Column(type: "text", nullable: false),
+ ServiceName = table.Column(type: "character varying(256)", maxLength: 256, nullable: false),
+ TenantCode = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
+ ClusterId = table.Column(type: "character varying(64)", maxLength: 64, nullable: false),
+ Status = table.Column(type: "integer", nullable: false),
+ CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
+ ConfirmedAt = table.Column(type: "timestamp with time zone", nullable: true),
+ ConfirmedBy = table.Column(type: "character varying(128)", maxLength: 128, nullable: true),
+ IsNew = table.Column(type: "boolean", nullable: false),
+ IsModified = table.Column(type: "boolean", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_gw_pending_configs", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "GwClusters",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ ClusterId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
+ Name = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
+ Description = table.Column(type: "character varying(500)", maxLength: 500, nullable: true),
+ LoadBalancingPolicy = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
+ Status = table.Column(type: "integer", nullable: false),
+ CreatedBy = table.Column(type: "bigint", nullable: true),
+ CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
+ UpdatedBy = table.Column(type: "bigint", nullable: true),
+ UpdatedTime = table.Column(type: "timestamp with time zone", nullable: true),
+ IsDeleted = table.Column(type: "boolean", nullable: false),
+ Version = table.Column(type: "integer", nullable: false),
+ HealthCheck = table.Column(type: "jsonb", nullable: true),
+ SessionAffinity = table.Column(type: "jsonb", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_GwClusters", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "GwDestination",
+ columns: table => new
+ {
+ ClusterId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ DestinationId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
+ Address = table.Column(type: "character varying(200)", maxLength: 200, nullable: false),
+ Health = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
+ Weight = table.Column(type: "integer", nullable: false),
+ HealthStatus = table.Column(type: "integer", nullable: false),
+ Status = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_GwDestination", x => new { x.ClusterId, x.Id });
+ table.ForeignKey(
+ name: "FK_GwDestination_GwClusters_ClusterId",
+ column: x => x.ClusterId,
+ principalTable: "GwClusters",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_gw_pending_configs_ServiceName_Status",
+ table: "gw_pending_configs",
+ columns: new[] { "ServiceName", "Status" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_gw_pending_configs_Source",
+ table: "gw_pending_configs",
+ column: "Source");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_gw_pending_configs_Status",
+ table: "gw_pending_configs",
+ column: "Status");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_gw_pending_configs_TenantCode_Status",
+ table: "gw_pending_configs",
+ columns: new[] { "TenantCode", "Status" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_gw_pending_configs_Type",
+ table: "gw_pending_configs",
+ column: "Type");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_GwClusters_ClusterId",
+ table: "GwClusters",
+ column: "ClusterId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_GwClusters_Name",
+ table: "GwClusters",
+ column: "Name");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_GwClusters_Status",
+ table: "GwClusters",
+ column: "Status");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_GwDestination_ClusterId_DestinationId",
+ table: "GwDestination",
+ columns: new[] { "ClusterId", "DestinationId" });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "gw_pending_configs");
+
+ migrationBuilder.DropTable(
+ name: "GwDestination");
+
+ migrationBuilder.DropTable(
+ name: "GwClusters");
+
+ migrationBuilder.DropColumn(
+ name: "AuthorizationPolicy",
+ table: "gw_tenant_routes");
+
+ migrationBuilder.DropColumn(
+ name: "CorsPolicy",
+ table: "gw_tenant_routes");
+
+ migrationBuilder.DropColumn(
+ name: "LoadBalancingPolicy",
+ table: "gw_tenant_routes");
+
+ migrationBuilder.DropColumn(
+ name: "RateLimiterPolicy",
+ table: "gw_tenant_routes");
+
+ migrationBuilder.DropColumn(
+ name: "TimeoutSeconds",
+ table: "gw_tenant_routes");
+
+ migrationBuilder.AddColumn(
+ name: "PathPattern",
+ table: "gw_tenant_routes",
+ type: "character varying(200)",
+ maxLength: 200,
+ nullable: false,
+ defaultValue: "");
+
+ migrationBuilder.CreateTable(
+ name: "gw_service_instances",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ Address = table.Column(type: "character varying(200)", maxLength: 200, nullable: false),
+ ClusterId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
+ CreatedBy = table.Column(type: "bigint", nullable: true),
+ CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
+ DestinationId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
+ Health = table.Column(type: "integer", nullable: false),
+ IsDeleted = table.Column(type: "boolean", nullable: false),
+ Status = table.Column(type: "integer", nullable: false),
+ UpdatedBy = table.Column(type: "bigint", nullable: true),
+ UpdatedTime = table.Column(type: "timestamp with time zone", nullable: true),
+ Version = table.Column(type: "integer", nullable: false),
+ Weight = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_gw_service_instances", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "gw_tenants",
+ columns: table => new
+ {
+ Id = table.Column(type: "bigint", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ CreatedBy = table.Column(type: "bigint", nullable: true),
+ CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
+ IsDeleted = table.Column(type: "boolean", nullable: false),
+ Status = table.Column(type: "integer", nullable: false),
+ TenantCode = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
+ TenantName = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
+ UpdatedBy = table.Column(type: "bigint", nullable: true),
+ UpdatedTime = table.Column(type: "timestamp with time zone", nullable: true),
+ Version = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_gw_tenants", x => x.Id);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_gw_service_instances_ClusterId_DestinationId",
+ table: "gw_service_instances",
+ columns: new[] { "ClusterId", "DestinationId" },
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_gw_service_instances_Health",
+ table: "gw_service_instances",
+ column: "Health");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_gw_tenants_TenantCode",
+ table: "gw_tenants",
+ column: "TenantCode",
+ unique: true);
+ }
+ }
+}
diff --git a/src/Migrations/ConsoleDbContextModelSnapshot.cs b/src/Migrations/ConsoleDbContextModelSnapshot.cs
index 9a36b70..c102f32 100644
--- a/src/Migrations/ConsoleDbContextModelSnapshot.cs
+++ b/src/Migrations/ConsoleDbContextModelSnapshot.cs
@@ -23,16 +23,80 @@ namespace Fengling.Console.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
- modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.GatewayAggregate.GwServiceInstance", b =>
+ modelBuilder.Entity("Fengling.Console.Models.Entities.PendingConfig", b =>
+ {
+ b.Property("Id")
+ .HasMaxLength(32)
+ .HasColumnType("character varying(32)");
+
+ b.Property("ClusterId")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("ConfigJson")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("ConfirmedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ConfirmedBy")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("IsModified")
+ .HasColumnType("boolean");
+
+ b.Property