Skip to content

Commit

Permalink
wip: (identity) 添加登录日志删除功能
Browse files Browse the repository at this point in the history
  • Loading branch information
gmf520 committed Oct 6, 2023
1 parent 6cedc0d commit a51ed78
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/OSharp.Authorization.Functions/FunctionAuthCacheBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class FunctionAuthCacheBase<TModuleFunction, TModuleRole, TModul
where TUser : UserBase<TUserKey>
where TUserKey : IEquatable<TUserKey>
{
private readonly Random _random = new Random();
private readonly Random _random = new();
private readonly IServiceProvider _serviceProvider;
private readonly IDistributedCache _cache;
private readonly ILogger _logger;
Expand Down Expand Up @@ -103,6 +103,10 @@ public string[] GetFunctionRoles(Guid functionId, IServiceProvider scopeProvider
string key = GetFunctionRolesKey(functionId);
IFunctionHandler functionHandler = _serviceProvider.GetRequiredService<IFunctionHandler>();
var function = functionHandler.GetFunction(functionId);
if (function == null)
{
return Array.Empty<string>();
}
string[] roleNames;
if (!forceRefresh)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AjaxResult> Delete(Guid[] ids)
{
Check.NotNull(ids, nameof(ids));

OperationResult result = await IdentityContract.DeleteLoginLogs(ids);
return result.ToAjaxResult();
}
}
6 changes: 6 additions & 0 deletions src/OSharp.Hosting.Core/Identity/Dtos/LoginLogOutputDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ public LoginLogOutputDto()
/// </summary>
public LoginLogOutputDto(LoginLog e)
{
Id = e.Id;
Ip = e.Ip;
UserAgent = e.UserAgent;
LogoutTime = e.LogoutTime;
CreatedTime = e.CreatedTime;
UserId = e.UserId;
}

/// <summary>
/// 获取或设置 编号
/// </summary>
public Guid Id { get; set; }

/// <summary>
/// 获取或设置 登录IP
/// </summary>
Expand Down

0 comments on commit a51ed78

Please sign in to comment.