feat: 添加登录日志自定义搜索
This commit is contained in:
parent
b6cd8ddcdd
commit
943c620c55
|
@ -0,0 +1,8 @@
|
|||
<div class="row g-3 form-inline">
|
||||
<div class="col-sm-6 col-md-6">
|
||||
<DateTimeRange @bind-Value="Value.LogTime" ShowLabel="true" AllowNull="false" />
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-6">
|
||||
<BootstrapInput @bind-Value="Value.IP" ShowLabel="true" />
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,20 @@
|
|||
using BootstrapAdmin.Web.Models;
|
||||
|
||||
namespace BootstrapAdmin.Web.Components;
|
||||
|
||||
public partial class LoginLogSearch
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
[NotNull]
|
||||
public LoginLogModel? Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
[NotNull]
|
||||
public EventCallback<LoginLogModel>? ValueChanged { get; set; }
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
using BootstrapAdmin.DataAccess.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BootstrapAdmin.Web.Models;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class LoginLogModel : ITableSearchModel
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[DisplayName("起止时间")]
|
||||
public DateTimeRangeValue? LogTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[DisplayName("请求IP")]
|
||||
public string? IP { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public LoginLogModel()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<IFilterAction> GetSearchs()
|
||||
{
|
||||
var ret = new List<IFilterAction>();
|
||||
|
||||
if (!string.IsNullOrEmpty(IP))
|
||||
{
|
||||
ret.Add(new SearchFilterAction(nameof(LoginLog.Ip), IP));
|
||||
}
|
||||
|
||||
if (LogTime != null)
|
||||
{
|
||||
ret.Add(new SearchFilterAction(nameof(LoginLog.LoginTime), LogTime.Start, FilterAction.LessThanOrEqual));
|
||||
ret.Add(new SearchFilterAction(nameof(LoginLog.LoginTime), LogTime.End, FilterAction.GreaterThanOrEqual));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
LogTime = new DateTimeRangeValue
|
||||
{
|
||||
Start = DateTime.Now,
|
||||
End = DateTime.Now.AddDays(-7)
|
||||
};
|
||||
IP = null;
|
||||
}
|
||||
}
|
|
@ -1,14 +1,15 @@
|
|||
@page "/admin/logins"
|
||||
|
||||
<AdminTable TItem="LoginLog" IsPagination="true" ShowDefaultButtons="false" ShowExtendButtons="false">
|
||||
<AdminTable TItem="LoginLog" IsPagination="true" CustomerSearchModel="@TableSearchModel"
|
||||
ShowDefaultButtons="false" ShowExtendButtons="false" IsFixedHeader="false">
|
||||
<TableColumns>
|
||||
<TableColumn @bind-Field="@context.UserName" Filterable="true"></TableColumn>
|
||||
<TableColumn @bind-Field="@context.UserName" Filterable="true" Searchable="true"></TableColumn>
|
||||
<TableColumn @bind-Field="@context.LoginTime" Filterable="true"></TableColumn>
|
||||
<TableColumn @bind-Field="@context.Ip" Filterable="true"></TableColumn>
|
||||
<TableColumn @bind-Field="@context.City" Filterable="true"></TableColumn>
|
||||
<TableColumn @bind-Field="@context.Ip" Filterable="true" Searchable="true"></TableColumn>
|
||||
<TableColumn @bind-Field="@context.City" Filterable="true" Searchable="true"></TableColumn>
|
||||
<TableColumn @bind-Field="@context.Browser" Filterable="true"></TableColumn>
|
||||
<TableColumn @bind-Field="@context.OS" Filterable="true"></TableColumn>
|
||||
<TableColumn @bind-Field="@context.Result" Filterable="true">
|
||||
<TableColumn @bind-Field="@context.Result" Filterable="true" Searchable="true">
|
||||
<Template Context="v">
|
||||
@if (v.Value == "登录成功")
|
||||
{
|
||||
|
@ -21,4 +22,10 @@
|
|||
</Template>
|
||||
</TableColumn>
|
||||
</TableColumns>
|
||||
<CustomerSearchTemplate Context="v">
|
||||
@if (v is LoginLogModel m)
|
||||
{
|
||||
<LoginLogSearch @bind-Value="m"></LoginLogSearch>
|
||||
}
|
||||
</CustomerSearchTemplate>
|
||||
</AdminTable>
|
|
@ -0,0 +1,11 @@
|
|||
using BootstrapAdmin.Web.Models;
|
||||
|
||||
namespace BootstrapAdmin.Web.Pages.Admin;
|
||||
|
||||
public partial class Logins
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public ITableSearchModel TableSearchModel { get; set; } = new LoginLogModel();
|
||||
}
|
Loading…
Reference in New Issue