diff --git a/Admin.NET/Admin.NET.Core/Extension/YitIdHelperExtension.cs b/Admin.NET/Admin.NET.Core/Extension/YitIdHelperExtension.cs index d2f8b831..403498b7 100644 --- a/Admin.NET/Admin.NET.Core/Extension/YitIdHelperExtension.cs +++ b/Admin.NET/Admin.NET.Core/Extension/YitIdHelperExtension.cs @@ -19,6 +19,14 @@ public static class YitIdHelperExtension public static void AddYitIdHelper(this IServiceCollection services, SnowIdOptions options) { + if (App.GetConfig("Cache", true).CacheType == CacheTypeEnum.Memory.ToString()) + { + YitIdHelper.SetIdGenerator(options); + SnowFlakeSingle.WorkId = options.WorkerId; + Console.WriteLine($"###########当前应用WorkId:【{options.WorkerId}】###########"); + return; + } + _options = options; // 排除开发环境和Windows服务器 diff --git a/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs b/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs index 46c110d2..6ac5d636 100644 --- a/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs +++ b/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs @@ -22,15 +22,8 @@ public static class SqlSugarSetup { // 注册雪花Id var snowIdOpt = App.GetConfig("SnowId", true); - if (App.GetConfig("Cache", true).CacheType == CacheTypeEnum.Memory.ToString()) - { - YitIdHelper.SetIdGenerator(snowIdOpt); - SnowFlakeSingle.WorkId = snowIdOpt.WorkerId; - } - else - { - services.AddYitIdHelper(snowIdOpt); - } + + services.AddYitIdHelper(snowIdOpt); StaticConfig.CustomSnowFlakeFunc = () => {