😎代码优化

This commit is contained in:
zuohuaijun 2024-08-05 13:18:03 +08:00
parent 1978f608e3
commit fa5829faed
3 changed files with 14 additions and 3 deletions

View File

@ -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 () =>
{

View File

@ -55,7 +55,7 @@ public static class SqlSugarFilter
Scoped.Create((factory, scope) =>
{
var services = scope.ServiceProvider;
orgIds = services.GetService<SysOrgService>().GetUserOrgIdList().GetAwaiter().GetResult();
orgIds = services.GetRequiredService<SysOrgService>().GetUserOrgIdList().GetAwaiter().GetResult();
});
if (orgIds == null || orgIds.Count == 0) return;
@ -100,6 +100,17 @@ public static class SqlSugarFilter
// 获取用户最大数据范围---仅本人数据
maxDataScope = App.GetRequiredService<SysCacheService>().Get<int>(CacheConst.KeyRoleMaxDataScope + userId);
// 若为0则获取用户机构组织集合建立缓存
if (maxDataScope == 0)
{
// 获取用户所属机构,保证同一作用域
Scoped.Create((factory, scope) =>
{
var services = scope.ServiceProvider;
services.GetRequiredService<SysOrgService>().GetUserOrgIdList().GetAwaiter().GetResult();
maxDataScope = services.GetRequiredService<SysCacheService>().Get<int>(CacheConst.KeyRoleMaxDataScope + userId);
});
}
if (maxDataScope != (int)DataScopeEnum.Self) return maxDataScope;
// 配置用户数据范围缓存

View File

@ -42,7 +42,7 @@ public class SysApprovalService : ITransient
var funcName = path[2];
var typeName = path[3];
var list = await App.GetService<ApprovalFlowService>().FormRoutes();
var list = await App.GetRequiredService<ApprovalFlowService>().FormRoutes();
if (list.Any(u => u.Contains(funcName) && u.Contains(typeName)))
{
var approvalFlow = new ApprovalFlowRecord