Skip to content

Commit

Permalink
HostApp配置,新增配置雪花漂移算法
Browse files Browse the repository at this point in the history
  • Loading branch information
zhontai committed Jul 18, 2022
1 parent 358e989 commit ef0bab3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/platform/ZhonTai.Admin/Core/HostApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ private void ConfigureServices(IServiceCollection services, IWebHostEnvironment
_hostAppOptions?.ConfigurePreServices?.Invoke(hostAppContext);

//雪花漂移算法
YitIdHelper.SetIdGenerator(new IdGeneratorOptions(1) { WorkerIdBitLength = 6 });
var idGeneratorOptions = new IdGeneratorOptions(1) { WorkerIdBitLength = 6 };
_hostAppOptions?.ConfigureIdGenerator?.Invoke(idGeneratorOptions);
YitIdHelper.SetIdGenerator(idGeneratorOptions);

//权限处理
services.AddScoped<IPermissionHandler, PermissionHandler>();
Expand Down
7 changes: 7 additions & 0 deletions src/platform/ZhonTai.Admin/Core/Startup/HostAppOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FreeSql;
using System;
using Yitter.IdGenerator;
using ZhonTai.DynamicApi;

namespace ZhonTai.Admin.Core.Startup
Expand Down Expand Up @@ -53,5 +54,11 @@ public class HostAppOptions
/// 配置动态Api
/// </summary>
public Action<DynamicApiOptions> ConfigureDynamicApi { get; set; }

/// <summary>
/// 配置雪花漂移算法
/// </summary>
public Action<IdGeneratorOptions> ConfigureIdGenerator { get; set; }

}
}
5 changes: 5 additions & 0 deletions src/platform/ZhonTai.Admin/ZhonTai.Admin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ef0bab3

Please sign in to comment.