diff --git a/Directory.Packages.props b/Directory.Packages.props
index 745bc7b..b0c5c35 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -4,7 +4,7 @@
-
+
@@ -13,6 +13,7 @@
+
@@ -26,4 +27,4 @@
-
\ No newline at end of file
+
diff --git a/src/Controllers/GatewayController.cs b/src/Controllers/GatewayController.cs
index 7c58dcb..a63adf9 100644
--- a/src/Controllers/GatewayController.cs
+++ b/src/Controllers/GatewayController.cs
@@ -285,7 +285,7 @@ public class GatewayController(IGatewayService gatewayService, ILogger RemoveInstance(long instanceId)
+ public async Task RemoveInstance(string instanceId)
{
try
{
@@ -317,7 +317,7 @@ public class GatewayController(IGatewayService gatewayService, ILogger UpdateWeight(long instanceId, [FromBody] GatewayUpdateWeightDto dto)
+ public async Task UpdateWeight(string instanceId, [FromBody] GatewayUpdateWeightDto dto)
{
try
{
diff --git a/src/Data/ConsoleDbContext.cs b/src/Data/ConsoleDbContext.cs
new file mode 100644
index 0000000..2bf61df
--- /dev/null
+++ b/src/Data/ConsoleDbContext.cs
@@ -0,0 +1,77 @@
+using Fengling.Platform.Domain.AggregatesModel.GatewayAggregate;
+using Fengling.Platform.Domain.AggregatesModel.RoleAggregate;
+using Fengling.Platform.Domain.AggregatesModel.TenantAggregate;
+using Fengling.Platform.Domain.AggregatesModel.UserAggregate;
+using Fengling.Platform.Infrastructure;
+using Microsoft.AspNetCore.Identity;
+using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
+
+namespace Fengling.Console.Data;
+
+///
+/// Console 项目的 DbContext,继承 PlatformDbContext 并配置表命名规范
+/// PostgreSQL 命名规范:小写字母 + 下划线,模块前缀
+///
+public class ConsoleDbContext : PlatformDbContext
+{
+ public ConsoleDbContext(DbContextOptions options) : base(options)
+ {
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+
+ // ========== Gateway 模块 ==========
+ modelBuilder.Entity(entity =>
+ {
+ entity.ToTable("gw_tenants");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.ToTable("gw_tenant_routes");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.ToTable("gw_service_instances");
+ });
+
+ // ========== Tenant 模块 ==========
+ modelBuilder.Entity(entity =>
+ {
+ entity.ToTable("sys_tenants");
+ });
+
+ // ========== Audit 模块 ==========
+ modelBuilder.Entity(entity =>
+ {
+ entity.ToTable("sys_access_logs");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.ToTable("sys_audit_logs");
+ });
+
+ // ========== Identity 模块 ==========
+ modelBuilder.Entity(entity =>
+ {
+ entity.ToTable("idn_users");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.ToTable("idn_roles");
+ });
+
+ // Identity tables - custom names
+ modelBuilder.Entity>(entity => entity.ToTable("idn_user_claims"));
+ modelBuilder.Entity>(entity => entity.ToTable("idn_role_claims"));
+ modelBuilder.Entity>(entity => entity.ToTable("idn_user_logins"));
+ modelBuilder.Entity>(entity => entity.ToTable("idn_user_tokens"));
+ modelBuilder.Entity>(entity => entity.ToTable("idn_user_roles"));
+ }
+}
diff --git a/src/Data/DesignTimeDbContextFactory.cs b/src/Data/DesignTimeDbContextFactory.cs
new file mode 100644
index 0000000..c63631c
--- /dev/null
+++ b/src/Data/DesignTimeDbContextFactory.cs
@@ -0,0 +1,15 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Design;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+
+namespace Fengling.Console.Data;
+
+public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory
+{
+ public ConsoleDbContext CreateDbContext(string[] args)
+ {
+ var optionsBuilder = new DbContextOptionsBuilder();
+ optionsBuilder.UseNpgsql("Host=81.68.223.70;Port=15432;Database=fengling_auth;Username=movingsam;Password=sl52788542");
+ return new ConsoleDbContext(optionsBuilder.Options);
+ }
+}
diff --git a/src/Fengling.Console.csproj b/src/Fengling.Console.csproj
index b8e14d5..4220245 100644
--- a/src/Fengling.Console.csproj
+++ b/src/Fengling.Console.csproj
@@ -19,6 +19,7 @@
+
@@ -33,5 +34,4 @@
-
diff --git a/src/Fengling.Console/Migrations/sql/initial.sql b/src/Fengling.Console/Migrations/sql/initial.sql
new file mode 100644
index 0000000..1552bb5
--- /dev/null
+++ b/src/Fengling.Console/Migrations/sql/initial.sql
@@ -0,0 +1,254 @@
+CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" (
+ "MigrationId" character varying(150) NOT NULL,
+ "ProductVersion" character varying(32) NOT NULL,
+ CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId")
+);
+
+START TRANSACTION;
+CREATE TABLE gw_service_instances (
+ "Id" text NOT NULL,
+ "ClusterId" character varying(100) NOT NULL,
+ "DestinationId" character varying(100) NOT NULL,
+ "Address" character varying(200) NOT NULL,
+ "Health" integer NOT NULL,
+ "Weight" integer NOT NULL,
+ "Status" integer NOT NULL,
+ "CreatedBy" bigint,
+ "CreatedTime" timestamp with time zone NOT NULL,
+ "UpdatedBy" bigint,
+ "UpdatedTime" timestamp with time zone,
+ "IsDeleted" boolean NOT NULL,
+ "Version" integer NOT NULL,
+ CONSTRAINT "PK_gw_service_instances" PRIMARY KEY ("Id")
+);
+
+CREATE TABLE gw_tenant_routes (
+ "Id" text NOT NULL,
+ "TenantCode" character varying(50) NOT NULL,
+ "ServiceName" character varying(100) NOT NULL,
+ "ClusterId" character varying(100) NOT NULL,
+ "PathPattern" character varying(200) NOT NULL,
+ "Priority" integer NOT NULL,
+ "Status" integer NOT NULL,
+ "IsGlobal" boolean NOT NULL,
+ "CreatedBy" bigint,
+ "CreatedTime" timestamp with time zone NOT NULL,
+ "UpdatedBy" bigint,
+ "UpdatedTime" timestamp with time zone,
+ "IsDeleted" boolean NOT NULL,
+ "Version" integer NOT NULL,
+ CONSTRAINT "PK_gw_tenant_routes" PRIMARY KEY ("Id")
+);
+
+CREATE TABLE gw_tenants (
+ "Id" bigint GENERATED BY DEFAULT AS IDENTITY,
+ "TenantCode" character varying(50) NOT NULL,
+ "TenantName" character varying(100) NOT NULL,
+ "Status" integer NOT NULL,
+ "CreatedBy" bigint,
+ "CreatedTime" timestamp with time zone NOT NULL,
+ "UpdatedBy" bigint,
+ "UpdatedTime" timestamp with time zone,
+ "IsDeleted" boolean NOT NULL,
+ "Version" integer NOT NULL,
+ CONSTRAINT "PK_gw_tenants" PRIMARY KEY ("Id")
+);
+
+CREATE TABLE idn_roles (
+ "Id" bigint GENERATED BY DEFAULT AS IDENTITY,
+ "Description" character varying(200),
+ "CreatedTime" timestamp with time zone NOT NULL,
+ "TenantId" bigint,
+ "IsSystem" boolean NOT NULL,
+ "DisplayName" text,
+ "Permissions" text[],
+ "Name" character varying(256),
+ "NormalizedName" character varying(256),
+ "ConcurrencyStamp" text,
+ CONSTRAINT "PK_idn_roles" PRIMARY KEY ("Id")
+);
+
+CREATE TABLE idn_users (
+ "Id" bigint GENERATED BY DEFAULT AS IDENTITY,
+ "RealName" text NOT NULL,
+ "TenantId" bigint,
+ "TenantCode" text,
+ "TenantName" text,
+ "CreatedTime" timestamp with time zone NOT NULL,
+ "UpdatedTime" timestamp with time zone,
+ "IsDeleted" boolean NOT NULL,
+ "UserName" character varying(256),
+ "NormalizedUserName" character varying(256),
+ "Email" character varying(256),
+ "NormalizedEmail" character varying(256),
+ "EmailConfirmed" boolean NOT NULL,
+ "PasswordHash" text,
+ "SecurityStamp" text,
+ "ConcurrencyStamp" text,
+ "PhoneNumber" character varying(20),
+ "PhoneNumberConfirmed" boolean NOT NULL,
+ "TwoFactorEnabled" boolean NOT NULL,
+ "LockoutEnd" timestamp with time zone,
+ "LockoutEnabled" boolean NOT NULL,
+ "AccessFailedCount" integer NOT NULL,
+ CONSTRAINT "PK_idn_users" PRIMARY KEY ("Id")
+);
+
+CREATE TABLE sys_access_logs (
+ "Id" bigint GENERATED BY DEFAULT AS IDENTITY,
+ "UserName" character varying(50),
+ "TenantId" character varying(50),
+ "Action" character varying(20) NOT NULL,
+ "Resource" character varying(200),
+ "Method" character varying(10),
+ "IpAddress" character varying(50),
+ "UserAgent" character varying(500),
+ "Status" character varying(20) NOT NULL,
+ "Duration" integer NOT NULL,
+ "RequestData" text,
+ "ResponseData" text,
+ "ErrorMessage" text,
+ "CreatedAt" timestamp with time zone NOT NULL,
+ CONSTRAINT "PK_sys_access_logs" PRIMARY KEY ("Id")
+);
+
+CREATE TABLE sys_audit_logs (
+ "Id" bigint GENERATED BY DEFAULT AS IDENTITY,
+ "Operator" character varying(50) NOT NULL,
+ "TenantId" character varying(50),
+ "Operation" character varying(20) NOT NULL,
+ "Action" character varying(20) NOT NULL,
+ "TargetType" character varying(50),
+ "TargetId" bigint,
+ "TargetName" character varying(100),
+ "IpAddress" character varying(50) NOT NULL,
+ "Description" character varying(500),
+ "OldValue" text,
+ "NewValue" text,
+ "ErrorMessage" text,
+ "Status" character varying(20) NOT NULL,
+ "CreatedAt" timestamp with time zone NOT NULL,
+ CONSTRAINT "PK_sys_audit_logs" PRIMARY KEY ("Id")
+);
+
+CREATE TABLE sys_tenants (
+ "Id" bigint GENERATED BY DEFAULT AS IDENTITY,
+ "TenantCode" character varying(50) NOT NULL,
+ "Name" character varying(100) NOT NULL,
+ "ContactName" character varying(50) NOT NULL,
+ "ContactEmail" character varying(100) NOT NULL,
+ "ContactPhone" character varying(20),
+ "MaxUsers" integer,
+ "CreatedAt" timestamp with time zone NOT NULL,
+ "UpdatedAt" timestamp with time zone,
+ "ExpiresAt" timestamp with time zone,
+ "Description" character varying(500),
+ "Status" integer NOT NULL,
+ "IsDeleted" boolean NOT NULL,
+ "RowVersion" bigint NOT NULL,
+ CONSTRAINT "PK_sys_tenants" PRIMARY KEY ("Id")
+);
+
+CREATE TABLE idn_role_claims (
+ "Id" integer GENERATED BY DEFAULT AS IDENTITY,
+ "RoleId" bigint NOT NULL,
+ "ClaimType" text,
+ "ClaimValue" text,
+ CONSTRAINT "PK_idn_role_claims" PRIMARY KEY ("Id"),
+ CONSTRAINT "FK_idn_role_claims_idn_roles_RoleId" FOREIGN KEY ("RoleId") REFERENCES idn_roles ("Id") ON DELETE CASCADE
+);
+
+CREATE TABLE idn_user_claims (
+ "Id" integer GENERATED BY DEFAULT AS IDENTITY,
+ "UserId" bigint NOT NULL,
+ "ClaimType" text,
+ "ClaimValue" text,
+ CONSTRAINT "PK_idn_user_claims" PRIMARY KEY ("Id"),
+ CONSTRAINT "FK_idn_user_claims_idn_users_UserId" FOREIGN KEY ("UserId") REFERENCES idn_users ("Id") ON DELETE CASCADE
+);
+
+CREATE TABLE idn_user_logins (
+ "LoginProvider" text NOT NULL,
+ "ProviderKey" text NOT NULL,
+ "ProviderDisplayName" text,
+ "UserId" bigint NOT NULL,
+ CONSTRAINT "PK_idn_user_logins" PRIMARY KEY ("LoginProvider", "ProviderKey"),
+ CONSTRAINT "FK_idn_user_logins_idn_users_UserId" FOREIGN KEY ("UserId") REFERENCES idn_users ("Id") ON DELETE CASCADE
+);
+
+CREATE TABLE idn_user_roles (
+ "UserId" bigint NOT NULL,
+ "RoleId" bigint NOT NULL,
+ CONSTRAINT "PK_idn_user_roles" PRIMARY KEY ("UserId", "RoleId"),
+ CONSTRAINT "FK_idn_user_roles_idn_roles_RoleId" FOREIGN KEY ("RoleId") REFERENCES idn_roles ("Id") ON DELETE CASCADE,
+ CONSTRAINT "FK_idn_user_roles_idn_users_UserId" FOREIGN KEY ("UserId") REFERENCES idn_users ("Id") ON DELETE CASCADE
+);
+
+CREATE TABLE idn_user_tokens (
+ "UserId" bigint NOT NULL,
+ "LoginProvider" text NOT NULL,
+ "Name" text NOT NULL,
+ "Value" text,
+ CONSTRAINT "PK_idn_user_tokens" PRIMARY KEY ("UserId", "LoginProvider", "Name"),
+ CONSTRAINT "FK_idn_user_tokens_idn_users_UserId" FOREIGN KEY ("UserId") REFERENCES idn_users ("Id") ON DELETE CASCADE
+);
+
+CREATE UNIQUE INDEX "IX_gw_service_instances_ClusterId_DestinationId" ON gw_service_instances ("ClusterId", "DestinationId");
+
+CREATE INDEX "IX_gw_service_instances_Health" ON gw_service_instances ("Health");
+
+CREATE INDEX "IX_gw_tenant_routes_ClusterId" ON gw_tenant_routes ("ClusterId");
+
+CREATE INDEX "IX_gw_tenant_routes_ServiceName" ON gw_tenant_routes ("ServiceName");
+
+CREATE INDEX "IX_gw_tenant_routes_ServiceName_IsGlobal_Status" ON gw_tenant_routes ("ServiceName", "IsGlobal", "Status");
+
+CREATE INDEX "IX_gw_tenant_routes_TenantCode" ON gw_tenant_routes ("TenantCode");
+
+CREATE UNIQUE INDEX "IX_gw_tenants_TenantCode" ON gw_tenants ("TenantCode");
+
+CREATE INDEX "IX_idn_role_claims_RoleId" ON idn_role_claims ("RoleId");
+
+CREATE UNIQUE INDEX "RoleNameIndex" ON idn_roles ("NormalizedName");
+
+CREATE INDEX "IX_idn_user_claims_UserId" ON idn_user_claims ("UserId");
+
+CREATE INDEX "IX_idn_user_logins_UserId" ON idn_user_logins ("UserId");
+
+CREATE INDEX "IX_idn_user_roles_RoleId" ON idn_user_roles ("RoleId");
+
+CREATE INDEX "EmailIndex" ON idn_users ("NormalizedEmail");
+
+CREATE UNIQUE INDEX "IX_idn_users_PhoneNumber" ON idn_users ("PhoneNumber");
+
+CREATE UNIQUE INDEX "UserNameIndex" ON idn_users ("NormalizedUserName");
+
+CREATE INDEX "IX_sys_access_logs_Action" ON sys_access_logs ("Action");
+
+CREATE INDEX "IX_sys_access_logs_CreatedAt" ON sys_access_logs ("CreatedAt");
+
+CREATE INDEX "IX_sys_access_logs_Status" ON sys_access_logs ("Status");
+
+CREATE INDEX "IX_sys_access_logs_TenantId" ON sys_access_logs ("TenantId");
+
+CREATE INDEX "IX_sys_access_logs_UserName" ON sys_access_logs ("UserName");
+
+CREATE INDEX "IX_sys_audit_logs_Action" ON sys_audit_logs ("Action");
+
+CREATE INDEX "IX_sys_audit_logs_CreatedAt" ON sys_audit_logs ("CreatedAt");
+
+CREATE INDEX "IX_sys_audit_logs_Operation" ON sys_audit_logs ("Operation");
+
+CREATE INDEX "IX_sys_audit_logs_Operator" ON sys_audit_logs ("Operator");
+
+CREATE INDEX "IX_sys_audit_logs_TenantId" ON sys_audit_logs ("TenantId");
+
+CREATE INDEX "IX_sys_tenants_Status" ON sys_tenants ("Status");
+
+CREATE UNIQUE INDEX "IX_sys_tenants_TenantCode" ON sys_tenants ("TenantCode");
+
+INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
+VALUES ('20260301040647_Initial', '10.0.3');
+
+COMMIT;
+
diff --git a/src/Migrations/20260301040647_Initial.Designer.cs b/src/Migrations/20260301040647_Initial.Designer.cs
new file mode 100644
index 0000000..c10cade
--- /dev/null
+++ b/src/Migrations/20260301040647_Initial.Designer.cs
@@ -0,0 +1,734 @@
+//
+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("20260301040647_Initial")]
+ partial class Initial
+ {
+ ///
+ 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.Platform.Domain.AggregatesModel.GatewayAggregate.GwServiceInstance", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("Address")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ 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("DestinationId")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("Health")
+ .HasColumnType("integer");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("bigint");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Version")
+ .HasColumnType("integer");
+
+ b.Property("Weight")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Health");
+
+ b.HasIndex("ClusterId", "DestinationId")
+ .IsUnique();
+
+ b.ToTable("gw_service_instances", (string)null);
+ });
+
+ modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.GatewayAggregate.GwTenant", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("CreatedBy")
+ .HasColumnType("bigint");
+
+ b.Property("CreatedTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("TenantCode")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property("TenantName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("bigint");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Version")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantCode")
+ .IsUnique();
+
+ b.ToTable("gw_tenants", (string)null);
+ });
+
+ modelBuilder.Entity("Fengling.Platform.Domain.AggregatesModel.GatewayAggregate.GwTenantRoute", 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("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("IsGlobal")
+ .HasColumnType("boolean");
+
+ b.Property("PathPattern")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b.Property("Priority")
+ .HasColumnType("integer");
+
+ 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("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.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/20260301040647_Initial.cs b/src/Migrations/20260301040647_Initial.cs
new file mode 100644
index 0000000..ac5332d
--- /dev/null
+++ b/src/Migrations/20260301040647_Initial.cs
@@ -0,0 +1,505 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace Fengling.Console.Migrations
+{
+ ///
+ public partial class Initial : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "gw_service_instances",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ ClusterId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
+ 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: "integer", nullable: false),
+ Weight = table.Column(type: "integer", 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)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_gw_service_instances", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "gw_tenant_routes",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ TenantCode = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
+ ServiceName = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
+ ClusterId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
+ PathPattern = table.Column(type: "character varying(200)", maxLength: 200, nullable: false),
+ Priority = table.Column(type: "integer", nullable: false),
+ Status = table.Column(type: "integer", nullable: false),
+ IsGlobal = table.Column(type: "boolean", 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)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_gw_tenant_routes", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "gw_tenants",
+ columns: table => new
+ {
+ Id = table.Column(type: "bigint", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ TenantCode = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
+ TenantName = table.Column(type: "character varying(100)", maxLength: 100, 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)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_gw_tenants", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "idn_roles",
+ columns: table => new
+ {
+ Id = table.Column(type: "bigint", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Description = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
+ CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
+ TenantId = table.Column(type: "bigint", nullable: true),
+ IsSystem = table.Column(type: "boolean", nullable: false),
+ DisplayName = table.Column(type: "text", nullable: true),
+ Permissions = table.Column>(type: "text[]", nullable: true),
+ Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
+ NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
+ ConcurrencyStamp = table.Column(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_idn_roles", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "idn_users",
+ columns: table => new
+ {
+ Id = table.Column(type: "bigint", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ RealName = table.Column(type: "text", nullable: false),
+ TenantId = table.Column(type: "bigint", nullable: true),
+ TenantCode = table.Column(type: "text", nullable: true),
+ TenantName = table.Column(type: "text", nullable: true),
+ CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
+ UpdatedTime = table.Column(type: "timestamp with time zone", nullable: true),
+ IsDeleted = table.Column(type: "boolean", nullable: false),
+ UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
+ NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
+ Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
+ NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
+ EmailConfirmed = table.Column(type: "boolean", nullable: false),
+ PasswordHash = table.Column(type: "text", nullable: true),
+ SecurityStamp = table.Column(type: "text", nullable: true),
+ ConcurrencyStamp = table.Column(type: "text", nullable: true),
+ PhoneNumber = table.Column(type: "character varying(20)", maxLength: 20, nullable: true),
+ PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false),
+ TwoFactorEnabled = table.Column(type: "boolean", nullable: false),
+ LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true),
+ LockoutEnabled = table.Column(type: "boolean", nullable: false),
+ AccessFailedCount = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_idn_users", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "sys_access_logs",
+ columns: table => new
+ {
+ Id = table.Column(type: "bigint", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ UserName = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ TenantId = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ Action = table.Column(type: "character varying(20)", maxLength: 20, nullable: false),
+ Resource = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
+ Method = table.Column(type: "character varying(10)", maxLength: 10, nullable: true),
+ IpAddress = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
+ UserAgent = table.Column(type: "character varying(500)", maxLength: 500, nullable: true),
+ Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false),
+ Duration = table.Column(type: "integer", nullable: false),
+ RequestData = table.Column(type: "text", nullable: true),
+ ResponseData = table.Column(type: "text", nullable: true),
+ ErrorMessage = table.Column(type: "text", nullable: true),
+ CreatedAt = table.Column(type: "timestamp with time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_sys_access_logs", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "sys_audit_logs",
+ columns: table => new
+ {
+ Id = table.Column(type: "bigint", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Operator = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
+ TenantId = table.Column