diff --git a/ZR.Admin.WebApi/Program.cs b/ZR.Admin.WebApi/Program.cs index 1ba7715..5df3ff0 100644 --- a/ZR.Admin.WebApi/Program.cs +++ b/ZR.Admin.WebApi/Program.cs @@ -2,6 +2,7 @@ using AspNetCoreRateLimit; using Infrastructure.Converter; using Microsoft.AspNetCore.DataProtection; using NLog.Web; +using SqlSugar; using System.Text.Json; using ZR.Admin.WebApi.Extensions; using ZR.Common.Cache; @@ -82,7 +83,12 @@ InternalApp.Configuration = builder.Configuration; InternalApp.WebHostEnvironment = app.Environment; //初始化db builder.Services.AddDb(app.Environment); - +var workId = builder.Configuration["workId"].ParseToInt(); +if (app.Environment.IsDevelopment()) +{ + workId += 1; +} +SnowFlakeSingle.WorkId = workId; //使用全局异常中间件 app.UseMiddleware(); diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json index 671e1f8..665e190 100644 --- a/ZR.Admin.WebApi/appsettings.json +++ b/ZR.Admin.WebApi/appsettings.json @@ -30,14 +30,15 @@ "Audience": "ZRAdmin.NET", //指该token是服务于哪个群体的(群体范围) "SecretKey": "SecretKey-ZRADMIN.NET-20210101", "Expire": 1440, //jwt登录过期时间(分) - "RefreshTokenTime": 30,//分钟 + "RefreshTokenTime": 30, //分钟 "TokenType": "Bearer" }, "InjectClass": [ "ZR.Repository", "ZR.Service", "ZR.Tasks", "ZR.ServiceCore" ], //自动注入类 "ShowDbLog": true, //是否打印db日志 "InitDb": false, //是否初始化db "DemoMode": false, //是否演示模式 - "SingleLogin": false,//是否允许多设备/浏览器登录 + "SingleLogin": false, //是否允许多设备/浏览器登录 + "workId": 1, //雪花id唯一数字 "Upload": { "uploadUrl": "http://localhost:8888", //本地存储资源访问路径 "localSavePath": "", //本地上传默认文件存储目录 wwwroot