新增雪花workID配置

This commit is contained in:
不做码农 2023-12-07 11:24:55 +08:00
parent d8504a194e
commit 0bcdb1cdfc
2 changed files with 10 additions and 3 deletions

View File

@ -2,6 +2,7 @@ using AspNetCoreRateLimit;
using Infrastructure.Converter; using Infrastructure.Converter;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using NLog.Web; using NLog.Web;
using SqlSugar;
using System.Text.Json; using System.Text.Json;
using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Extensions;
using ZR.Common.Cache; using ZR.Common.Cache;
@ -82,7 +83,12 @@ InternalApp.Configuration = builder.Configuration;
InternalApp.WebHostEnvironment = app.Environment; InternalApp.WebHostEnvironment = app.Environment;
//初始化db //初始化db
builder.Services.AddDb(app.Environment); builder.Services.AddDb(app.Environment);
var workId = builder.Configuration["workId"].ParseToInt();
if (app.Environment.IsDevelopment())
{
workId += 1;
}
SnowFlakeSingle.WorkId = workId;
//使用全局异常中间件 //使用全局异常中间件
app.UseMiddleware<GlobalExceptionMiddleware>(); app.UseMiddleware<GlobalExceptionMiddleware>();

View File

@ -30,14 +30,15 @@
"Audience": "ZRAdmin.NET", //token "Audience": "ZRAdmin.NET", //token
"SecretKey": "SecretKey-ZRADMIN.NET-20210101", "SecretKey": "SecretKey-ZRADMIN.NET-20210101",
"Expire": 1440, //jwt "Expire": 1440, //jwt
"RefreshTokenTime": 30,// "RefreshTokenTime": 30, //
"TokenType": "Bearer" "TokenType": "Bearer"
}, },
"InjectClass": [ "ZR.Repository", "ZR.Service", "ZR.Tasks", "ZR.ServiceCore" ], // "InjectClass": [ "ZR.Repository", "ZR.Service", "ZR.Tasks", "ZR.ServiceCore" ], //
"ShowDbLog": true, //db "ShowDbLog": true, //db
"InitDb": false, //db "InitDb": false, //db
"DemoMode": false, // "DemoMode": false, //
"SingleLogin": false,/// "SingleLogin": false, ///
"workId": 1, //id
"Upload": { "Upload": {
"uploadUrl": "http://localhost:8888", //访 "uploadUrl": "http://localhost:8888", //访
"localSavePath": "", // wwwroot "localSavePath": "", // wwwroot