diff --git a/src/OSharp.Authorization.Functions/FunctionAuthCacheBase.cs b/src/OSharp.Authorization.Functions/FunctionAuthCacheBase.cs index 8f03c908..2155669a 100644 --- a/src/OSharp.Authorization.Functions/FunctionAuthCacheBase.cs +++ b/src/OSharp.Authorization.Functions/FunctionAuthCacheBase.cs @@ -29,7 +29,7 @@ public abstract class FunctionAuthCacheBase where TUserKey : IEquatable { - private readonly Random _random = new Random(); + private readonly Random _random = new(); private readonly IServiceProvider _serviceProvider; private readonly IDistributedCache _cache; private readonly ILogger _logger; @@ -103,6 +103,10 @@ public string[] GetFunctionRoles(Guid functionId, IServiceProvider scopeProvider string key = GetFunctionRolesKey(functionId); IFunctionHandler functionHandler = _serviceProvider.GetRequiredService(); var function = functionHandler.GetFunction(functionId); + if (function == null) + { + return Array.Empty(); + } string[] roleNames; if (!forceRefresh) { diff --git a/src/OSharp.Hosting.Apis/Areas/Admin/Controllers/Identity/LoginLogController.cs b/src/OSharp.Hosting.Apis/Areas/Admin/Controllers/Identity/LoginLogController.cs index 19cccf8c..43b987b7 100644 --- a/src/OSharp.Hosting.Apis/Areas/Admin/Controllers/Identity/LoginLogController.cs +++ b/src/OSharp.Hosting.Apis/Areas/Admin/Controllers/Identity/LoginLogController.cs @@ -43,11 +43,24 @@ public AjaxResult Read(PageRequest request) D = m, User = new { m.User.UserName, m.User.NickName } }).ToPageResult(data => data.Select(m => new LoginLogOutputDto(m.D) - { - UserName = m.User.UserName, - NickName = m.User.NickName, -}).ToArray()); + { + UserName = m.User.UserName, + NickName = m.User.NickName, + }).ToArray()); return new AjaxResult(page.ToPageData()); } + + //删除登录日志信息 + [HttpPost] + [ModuleInfo] + [UnitOfWork] + [Description("删除")] + public async Task Delete(Guid[] ids) + { + Check.NotNull(ids, nameof(ids)); + + OperationResult result = await IdentityContract.DeleteLoginLogs(ids); + return result.ToAjaxResult(); + } } diff --git a/src/OSharp.Hosting.Core/Identity/Dtos/LoginLogOutputDto.cs b/src/OSharp.Hosting.Core/Identity/Dtos/LoginLogOutputDto.cs index e24e644a..6115dbcf 100644 --- a/src/OSharp.Hosting.Core/Identity/Dtos/LoginLogOutputDto.cs +++ b/src/OSharp.Hosting.Core/Identity/Dtos/LoginLogOutputDto.cs @@ -29,6 +29,7 @@ public LoginLogOutputDto() /// public LoginLogOutputDto(LoginLog e) { + Id = e.Id; Ip = e.Ip; UserAgent = e.UserAgent; LogoutTime = e.LogoutTime; @@ -36,6 +37,11 @@ public LoginLogOutputDto(LoginLog e) UserId = e.UserId; } + /// + /// 获取或设置 编号 + /// + public Guid Id { get; set; } + /// /// 获取或设置 登录IP ///