From a51ed78141eccc2dd0ad8f00fa95aee186b90842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E6=98=8E=E9=94=8B?= Date: Fri, 6 Oct 2023 14:40:26 +0800 Subject: [PATCH] =?UTF-8?q?wip:=20(identity)=20=E6=B7=BB=E5=8A=A0=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=97=A5=E5=BF=97=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FunctionAuthCacheBase.cs | 6 +++++- .../Identity/LoginLogController.cs | 21 +++++++++++++++---- .../Identity/Dtos/LoginLogOutputDto.cs | 6 ++++++ 3 files changed, 28 insertions(+), 5 deletions(-) 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 ///