From c1de3b2987a8e29b5bc5ce9b622cadb1c6ebc54f Mon Sep 17 00:00:00 2001 From: yzp Date: Wed, 5 Mar 2025 10:49:08 +0800 Subject: [PATCH] =?UTF-8?q?BUG:=E5=88=A0=E9=99=A4=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=90=8E=E4=B8=8D=E9=87=8D=E5=90=AF=E6=9C=8D=E5=8A=A1=E4=BC=9A?= =?UTF-8?q?=E7=99=BB=E9=99=86=E4=B8=8D=E4=BA=86=20FIX:=E5=AF=B9API?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=BF=9B=E8=A1=8C=E6=8E=92=E5=BA=8F=EF=BC=8C?= =?UTF-8?q?=E6=96=B9=E4=BE=BF=E6=8E=92=E6=9F=A5=E6=9D=83=E9=99=90=E6=97=B6?= =?UTF-8?q?=E5=BF=AB=E5=B8=A6=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs | 8 +++++++- Admin.NET/Admin.NET.Core/Service/Role/SysRoleService.cs | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs b/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs index a3a9f224..540dd5ed 100644 --- a/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs @@ -59,7 +59,13 @@ public class SysAuthService : IDynamicApiController, ITransient if (passwordErrorTimes > passwordMaxErrorTimes) throw Oops.Oh(ErrorCodeEnum.D1027); // 判断是否开启验证码并校验 - var tenant = _sysCacheService.Get>(CacheConst.KeyTenant)?.WhereIF(input.TenantId > 0, u => u.Id == input.TenantId).FirstOrDefault(); + var tenant = _sysCacheService.Get>(CacheConst.KeyTenant)?.WhereIF(input.TenantId > 0, u => u.Id == input.TenantId).FirstOrDefault(); + // 缓存被清服务不重启这里tenant会为空,出错 + if (tenant==null && input.TenantId==0) + { + await App.GetRequiredService().CacheTenant(); + tenant = _sysCacheService.Get>(CacheConst.KeyTenant)?.WhereIF(input.TenantId > 0, u => u.Id == input.TenantId).FirstOrDefault(); + } if (tenant.Captcha == true && !_captcha.Validate(input.CodeId.ToString(), input.Code)) throw Oops.Oh(ErrorCodeEnum.D0008); diff --git a/Admin.NET/Admin.NET.Core/Service/Role/SysRoleService.cs b/Admin.NET/Admin.NET.Core/Service/Role/SysRoleService.cs index dfa6d9fd..f5b76f58 100644 --- a/Admin.NET/Admin.NET.Core/Service/Role/SysRoleService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Role/SysRoleService.cs @@ -393,7 +393,9 @@ public class SysRoleService : IDynamicApiController, ITransient var roleApiList = await _sysRoleApiService.GetRoleApiList(roleIdList); apiList[1].AddRange(roleApiList); } - _sysCacheService.Set(CacheConst.KeyUserApi + userId, apiList, TimeSpan.FromDays(7)); // 缓存7天 + _sysCacheService.Set(CacheConst.KeyUserApi + userId, apiList, TimeSpan.FromDays(7)); // 缓存7天 + foreach (var lst in apiList) + lst.Sort(); return apiList; }