From fa5829faedd84cdd1cf3d9d46397558e5fca167e Mon Sep 17 00:00:00 2001 From: zuohuaijun Date: Mon, 5 Aug 2024 13:18:03 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8E=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EventBus/RetryEventHandlerExecutor.cs | 2 +- Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarFilter.cs | 13 ++++++++++++- .../Service/SysApproval/SysApprovalService.cs | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Admin.NET/Admin.NET.Core/EventBus/RetryEventHandlerExecutor.cs b/Admin.NET/Admin.NET.Core/EventBus/RetryEventHandlerExecutor.cs index 4e575123..59f9cec1 100644 --- a/Admin.NET/Admin.NET.Core/EventBus/RetryEventHandlerExecutor.cs +++ b/Admin.NET/Admin.NET.Core/EventBus/RetryEventHandlerExecutor.cs @@ -17,7 +17,7 @@ public class RetryEventHandlerExecutor : IEventHandlerExecutor // 判断是否自定义了重试失败回调服务 var fallbackPolicyService = eventSubscribeAttribute?.FallbackPolicy == null ? null - : App.GetService(eventSubscribeAttribute.FallbackPolicy) as IEventFallbackPolicy; + : App.GetRequiredService(eventSubscribeAttribute.FallbackPolicy) as IEventFallbackPolicy; await Retry.InvokeAsync(async () => { diff --git a/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarFilter.cs b/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarFilter.cs index 0fc1996c..0dc45b4c 100644 --- a/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarFilter.cs +++ b/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarFilter.cs @@ -55,7 +55,7 @@ public static class SqlSugarFilter Scoped.Create((factory, scope) => { var services = scope.ServiceProvider; - orgIds = services.GetService().GetUserOrgIdList().GetAwaiter().GetResult(); + orgIds = services.GetRequiredService().GetUserOrgIdList().GetAwaiter().GetResult(); }); if (orgIds == null || orgIds.Count == 0) return; @@ -100,6 +100,17 @@ public static class SqlSugarFilter // 获取用户最大数据范围---仅本人数据 maxDataScope = App.GetRequiredService().Get(CacheConst.KeyRoleMaxDataScope + userId); + // 若为0则获取用户机构组织集合建立缓存 + if (maxDataScope == 0) + { + // 获取用户所属机构,保证同一作用域 + Scoped.Create((factory, scope) => + { + var services = scope.ServiceProvider; + services.GetRequiredService().GetUserOrgIdList().GetAwaiter().GetResult(); + maxDataScope = services.GetRequiredService().Get(CacheConst.KeyRoleMaxDataScope + userId); + }); + } if (maxDataScope != (int)DataScopeEnum.Self) return maxDataScope; // 配置用户数据范围缓存 diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/SysApproval/SysApprovalService.cs b/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/SysApproval/SysApprovalService.cs index 11c8d88b..9d8abb99 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/SysApproval/SysApprovalService.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/SysApproval/SysApprovalService.cs @@ -42,7 +42,7 @@ public class SysApprovalService : ITransient var funcName = path[2]; var typeName = path[3]; - var list = await App.GetService().FormRoutes(); + var list = await App.GetRequiredService().FormRoutes(); if (list.Any(u => u.Contains(funcName) && u.Contains(typeName))) { var approvalFlow = new ApprovalFlowRecord