refactor(infrastructure): 将主键类型从 long 改为 string 并使用 Guid 生成唯一 ID
All checks were successful
Publish Platform NuGet Packages / build (push) Successful in 24s
All checks were successful
Publish Platform NuGet Packages / build (push) Successful in 24s
- 修改 GwServiceInstance 和 GwTenantRoute 的 Id 类型为 string
- 使用 Guid.CreateVersion7().ToString("N") 生成默认唯一标识值
- 更新 IInstanceStore、IRouteManager、IRouteStore 接口中的 FindByIdAsync 方法签名,使用 string? 替代 long?
- 调整 InstanceStore、RouteManager 和 RouteStore 中相应方法实现,支持新的 Id 类型
- 保证相关存储及查询接口兼容新的字符串形式主键
This commit is contained in:
parent
6426a13852
commit
6f1dbba4f0
@ -5,7 +5,7 @@ namespace Fengling.Platform.Domain.AggregatesModel.GatewayAggregate;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class GwServiceInstance
|
public class GwServiceInstance
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public string Id { get; set; } = Guid.CreateVersion7().ToString("N");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 集群ID
|
/// 集群ID
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace Fengling.Platform.Domain.AggregatesModel.GatewayAggregate;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class GwTenantRoute
|
public class GwTenantRoute
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public string Id { get; set; } = Guid.CreateVersion7().ToString("N");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 租户代码
|
/// 租户代码
|
||||||
|
|||||||
@ -9,7 +9,7 @@ namespace Fengling.Platform.Infrastructure;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IInstanceStore
|
public interface IInstanceStore
|
||||||
{
|
{
|
||||||
Task<GwServiceInstance?> FindByIdAsync(long? id, CancellationToken cancellationToken = default);
|
Task<GwServiceInstance?> FindByIdAsync(string? id, CancellationToken cancellationToken = default);
|
||||||
Task<GwServiceInstance?> FindByClusterIdAsync(string clusterId, CancellationToken cancellationToken = default);
|
Task<GwServiceInstance?> FindByClusterIdAsync(string clusterId, CancellationToken cancellationToken = default);
|
||||||
Task<GwServiceInstance?> FindByDestinationAsync(string clusterId, string destinationId, CancellationToken cancellationToken = default);
|
Task<GwServiceInstance?> FindByDestinationAsync(string clusterId, string destinationId, CancellationToken cancellationToken = default);
|
||||||
Task<IList<GwServiceInstance>> GetAllAsync(CancellationToken cancellationToken = default);
|
Task<IList<GwServiceInstance>> GetAllAsync(CancellationToken cancellationToken = default);
|
||||||
|
|||||||
@ -9,7 +9,7 @@ namespace Fengling.Platform.Infrastructure;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IRouteManager
|
public interface IRouteManager
|
||||||
{
|
{
|
||||||
Task<GwTenantRoute?> FindByIdAsync(long? id, CancellationToken cancellationToken = default);
|
Task<GwTenantRoute?> FindByIdAsync(string? id, CancellationToken cancellationToken = default);
|
||||||
Task<GwTenantRoute?> FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default);
|
Task<GwTenantRoute?> FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default);
|
||||||
Task<IList<GwTenantRoute>> GetAllAsync(CancellationToken cancellationToken = default);
|
Task<IList<GwTenantRoute>> GetAllAsync(CancellationToken cancellationToken = default);
|
||||||
Task<IdentityResult> CreateRouteAsync(GwTenantRoute route, CancellationToken cancellationToken = default);
|
Task<IdentityResult> CreateRouteAsync(GwTenantRoute route, CancellationToken cancellationToken = default);
|
||||||
|
|||||||
@ -9,7 +9,7 @@ namespace Fengling.Platform.Infrastructure;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IRouteStore
|
public interface IRouteStore
|
||||||
{
|
{
|
||||||
Task<GwTenantRoute?> FindByIdAsync(long? id, CancellationToken cancellationToken = default);
|
Task<GwTenantRoute?> FindByIdAsync(string? id, CancellationToken cancellationToken = default);
|
||||||
Task<GwTenantRoute?> FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default);
|
Task<GwTenantRoute?> FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default);
|
||||||
Task<GwTenantRoute?> FindByClusterIdAsync(string clusterId, CancellationToken cancellationToken = default);
|
Task<GwTenantRoute?> FindByClusterIdAsync(string clusterId, CancellationToken cancellationToken = default);
|
||||||
Task<IList<GwTenantRoute>> GetAllAsync(CancellationToken cancellationToken = default);
|
Task<IList<GwTenantRoute>> GetAllAsync(CancellationToken cancellationToken = default);
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public class InstanceStore<TContext> : IInstanceStore
|
|||||||
|
|
||||||
public void Dispose() { }
|
public void Dispose() { }
|
||||||
|
|
||||||
public virtual Task<GwServiceInstance?> FindByIdAsync(long? id, CancellationToken cancellationToken = default)
|
public virtual Task<GwServiceInstance?> FindByIdAsync(string? id, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
if (id == null) return Task.FromResult<GwServiceInstance?>(null);
|
if (id == null) return Task.FromResult<GwServiceInstance?>(null);
|
||||||
return _instances.FirstOrDefaultAsync(i => i.Id == id, cancellationToken);
|
return _instances.FirstOrDefaultAsync(i => i.Id == id, cancellationToken);
|
||||||
|
|||||||
@ -15,7 +15,7 @@ public class RouteManager : IRouteManager
|
|||||||
_store = store;
|
_store = store;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Task<GwTenantRoute?> FindByIdAsync(long? id, CancellationToken cancellationToken = default)
|
public virtual Task<GwTenantRoute?> FindByIdAsync(string? id, CancellationToken cancellationToken = default)
|
||||||
=> _store.FindByIdAsync(id, cancellationToken);
|
=> _store.FindByIdAsync(id, cancellationToken);
|
||||||
|
|
||||||
public virtual Task<GwTenantRoute?> FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default)
|
public virtual Task<GwTenantRoute?> FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default)
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public class RouteStore<TContext> : IRouteStore
|
|||||||
|
|
||||||
public void Dispose() { }
|
public void Dispose() { }
|
||||||
|
|
||||||
public virtual Task<GwTenantRoute?> FindByIdAsync(long? id, CancellationToken cancellationToken = default)
|
public virtual Task<GwTenantRoute?> FindByIdAsync(string? id, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
if (id == null) return Task.FromResult<GwTenantRoute?>(null);
|
if (id == null) return Task.FromResult<GwTenantRoute?>(null);
|
||||||
return _routes.FirstOrDefaultAsync(r => r.Id == id, cancellationToken);
|
return _routes.FirstOrDefaultAsync(r => r.Id == id, cancellationToken);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user