From 6f1dbba4f0fea6cacb092415f73e7a868c29cfda Mon Sep 17 00:00:00 2001 From: movingsam Date: Sun, 1 Mar 2026 11:23:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(infrastructure):=20=E5=B0=86=E4=B8=BB?= =?UTF-8?q?=E9=94=AE=E7=B1=BB=E5=9E=8B=E4=BB=8E=20long=20=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=20string=20=E5=B9=B6=E4=BD=BF=E7=94=A8=20Guid=20?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=94=AF=E4=B8=80=20ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 GwServiceInstance 和 GwTenantRoute 的 Id 类型为 string - 使用 Guid.CreateVersion7().ToString("N") 生成默认唯一标识值 - 更新 IInstanceStore、IRouteManager、IRouteStore 接口中的 FindByIdAsync 方法签名,使用 string? 替代 long? - 调整 InstanceStore、RouteManager 和 RouteStore 中相应方法实现,支持新的 Id 类型 - 保证相关存储及查询接口兼容新的字符串形式主键 --- .../AggregatesModel/GatewayAggregate/GwServiceInstance.cs | 2 +- .../AggregatesModel/GatewayAggregate/GwTenantRoute.cs | 2 +- Fengling.Platform.Infrastructure/IInstanceStore.cs | 2 +- Fengling.Platform.Infrastructure/IRouteManager.cs | 2 +- Fengling.Platform.Infrastructure/IRouteStore.cs | 2 +- Fengling.Platform.Infrastructure/InstanceStore.cs | 2 +- Fengling.Platform.Infrastructure/RouteManager.cs | 2 +- Fengling.Platform.Infrastructure/RouteStore.cs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwServiceInstance.cs b/Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwServiceInstance.cs index 74033b4..23bcbbc 100644 --- a/Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwServiceInstance.cs +++ b/Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwServiceInstance.cs @@ -5,7 +5,7 @@ namespace Fengling.Platform.Domain.AggregatesModel.GatewayAggregate; /// public class GwServiceInstance { - public long Id { get; set; } + public string Id { get; set; } = Guid.CreateVersion7().ToString("N"); /// /// 集群ID diff --git a/Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwTenantRoute.cs b/Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwTenantRoute.cs index c372f88..1a37f93 100644 --- a/Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwTenantRoute.cs +++ b/Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwTenantRoute.cs @@ -5,7 +5,7 @@ namespace Fengling.Platform.Domain.AggregatesModel.GatewayAggregate; /// public class GwTenantRoute { - public long Id { get; set; } + public string Id { get; set; } = Guid.CreateVersion7().ToString("N"); /// /// 租户代码 diff --git a/Fengling.Platform.Infrastructure/IInstanceStore.cs b/Fengling.Platform.Infrastructure/IInstanceStore.cs index 362d705..7e145aa 100644 --- a/Fengling.Platform.Infrastructure/IInstanceStore.cs +++ b/Fengling.Platform.Infrastructure/IInstanceStore.cs @@ -9,7 +9,7 @@ namespace Fengling.Platform.Infrastructure; /// public interface IInstanceStore { - Task FindByIdAsync(long? id, CancellationToken cancellationToken = default); + Task FindByIdAsync(string? id, CancellationToken cancellationToken = default); Task FindByClusterIdAsync(string clusterId, CancellationToken cancellationToken = default); Task FindByDestinationAsync(string clusterId, string destinationId, CancellationToken cancellationToken = default); Task> GetAllAsync(CancellationToken cancellationToken = default); diff --git a/Fengling.Platform.Infrastructure/IRouteManager.cs b/Fengling.Platform.Infrastructure/IRouteManager.cs index ff5d44e..4bb7826 100644 --- a/Fengling.Platform.Infrastructure/IRouteManager.cs +++ b/Fengling.Platform.Infrastructure/IRouteManager.cs @@ -9,7 +9,7 @@ namespace Fengling.Platform.Infrastructure; /// public interface IRouteManager { - Task FindByIdAsync(long? id, CancellationToken cancellationToken = default); + Task FindByIdAsync(string? id, CancellationToken cancellationToken = default); Task FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default); Task> GetAllAsync(CancellationToken cancellationToken = default); Task CreateRouteAsync(GwTenantRoute route, CancellationToken cancellationToken = default); diff --git a/Fengling.Platform.Infrastructure/IRouteStore.cs b/Fengling.Platform.Infrastructure/IRouteStore.cs index 8b4bdc4..fadeff1 100644 --- a/Fengling.Platform.Infrastructure/IRouteStore.cs +++ b/Fengling.Platform.Infrastructure/IRouteStore.cs @@ -9,7 +9,7 @@ namespace Fengling.Platform.Infrastructure; /// public interface IRouteStore { - Task FindByIdAsync(long? id, CancellationToken cancellationToken = default); + Task FindByIdAsync(string? id, CancellationToken cancellationToken = default); Task FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default); Task FindByClusterIdAsync(string clusterId, CancellationToken cancellationToken = default); Task> GetAllAsync(CancellationToken cancellationToken = default); diff --git a/Fengling.Platform.Infrastructure/InstanceStore.cs b/Fengling.Platform.Infrastructure/InstanceStore.cs index 7fa5157..a48c7b5 100644 --- a/Fengling.Platform.Infrastructure/InstanceStore.cs +++ b/Fengling.Platform.Infrastructure/InstanceStore.cs @@ -21,7 +21,7 @@ public class InstanceStore : IInstanceStore public void Dispose() { } - public virtual Task FindByIdAsync(long? id, CancellationToken cancellationToken = default) + public virtual Task FindByIdAsync(string? id, CancellationToken cancellationToken = default) { if (id == null) return Task.FromResult(null); return _instances.FirstOrDefaultAsync(i => i.Id == id, cancellationToken); diff --git a/Fengling.Platform.Infrastructure/RouteManager.cs b/Fengling.Platform.Infrastructure/RouteManager.cs index 7df7f40..aefed8a 100644 --- a/Fengling.Platform.Infrastructure/RouteManager.cs +++ b/Fengling.Platform.Infrastructure/RouteManager.cs @@ -15,7 +15,7 @@ public class RouteManager : IRouteManager _store = store; } - public virtual Task FindByIdAsync(long? id, CancellationToken cancellationToken = default) + public virtual Task FindByIdAsync(string? id, CancellationToken cancellationToken = default) => _store.FindByIdAsync(id, cancellationToken); public virtual Task FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default) diff --git a/Fengling.Platform.Infrastructure/RouteStore.cs b/Fengling.Platform.Infrastructure/RouteStore.cs index 5e4dd5d..20aeb68 100644 --- a/Fengling.Platform.Infrastructure/RouteStore.cs +++ b/Fengling.Platform.Infrastructure/RouteStore.cs @@ -21,7 +21,7 @@ public class RouteStore : IRouteStore public void Dispose() { } - public virtual Task FindByIdAsync(long? id, CancellationToken cancellationToken = default) + public virtual Task FindByIdAsync(string? id, CancellationToken cancellationToken = default) { if (id == null) return Task.FromResult(null); return _routes.FirstOrDefaultAsync(r => r.Id == id, cancellationToken);