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