From f0f2da4edf33021e196c531989c5145528285410 Mon Sep 17 00:00:00 2001 From: zhontai <361243234@qq.com> Date: Fri, 15 Mar 2024 13:53:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=86=E5=B8=83=E5=BC=8FId?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=99=A8=E8=87=AA=E5=8A=A8=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ZhonTai.Admin/Core/Extensions/IdGeneratorExtensions.cs | 2 ++ src/platform/ZhonTai.Admin/Core/HostApp.cs | 4 ++-- src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj | 2 +- src/platform/ZhonTai.Common/ZhonTai.Common.csproj | 2 +- src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj | 4 ++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/platform/ZhonTai.Admin/Core/Extensions/IdGeneratorExtensions.cs b/src/platform/ZhonTai.Admin/Core/Extensions/IdGeneratorExtensions.cs index 3801581f..c9b46aa8 100644 --- a/src/platform/ZhonTai.Admin/Core/Extensions/IdGeneratorExtensions.cs +++ b/src/platform/ZhonTai.Admin/Core/Extensions/IdGeneratorExtensions.cs @@ -30,6 +30,8 @@ public static void AddIdGenerator(this IServiceCollection services) if (_isSet) throw new InvalidOperationException("只允许添加一次Id生成器"); + Task.Delay(new Random().Next(10, 100)).Wait(); + SetIdGenerator(idGeneratorConfig); _isSet = true; diff --git a/src/platform/ZhonTai.Admin/Core/HostApp.cs b/src/platform/ZhonTai.Admin/Core/HostApp.cs index 90f69758..34fa82be 100644 --- a/src/platform/ZhonTai.Admin/Core/HostApp.cs +++ b/src/platform/ZhonTai.Admin/Core/HostApp.cs @@ -311,7 +311,7 @@ private void ConfigureServices(IServiceCollection services, IWebHostEnvironment services.AddSingleton(); //分布式Redis缓存 services.AddSingleton(new DistributedCache(redis)); - //分布式雪花漂移Id + //分布式Id生成器 services.AddIdGenerator(); } else @@ -320,7 +320,7 @@ private void ConfigureServices(IServiceCollection services, IWebHostEnvironment services.AddSingleton(); //分布式内存缓存 services.AddDistributedMemoryCache(); - //雪花漂移Id + //Id生成器 YitIdHelper.SetIdGenerator(appConfig.IdGenerator); } diff --git a/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj b/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj index f5bde7dd..e050f024 100644 --- a/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj +++ b/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/platform/ZhonTai.Common/ZhonTai.Common.csproj b/src/platform/ZhonTai.Common/ZhonTai.Common.csproj index 1ad6e180..ac08ba10 100644 --- a/src/platform/ZhonTai.Common/ZhonTai.Common.csproj +++ b/src/platform/ZhonTai.Common/ZhonTai.Common.csproj @@ -25,7 +25,7 @@ - + diff --git a/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj b/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj index d38ab0bb..0fd66e93 100644 --- a/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj +++ b/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj @@ -19,8 +19,8 @@ - - + +