feat: Blazor 操作日志功能完成
This commit is contained in:
parent
f0fff56a6b
commit
e13b87d202
|
@ -0,0 +1,28 @@
|
|||
using Bootstrap.Admin.Pages.Components;
|
||||
using PetaPoco;
|
||||
|
||||
namespace Bootstrap.Admin.Pages.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Pages 扩展操作类
|
||||
/// </summary>
|
||||
public static class PagesExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Pages 转化为 QueryData 实例方法
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="pages"></param>
|
||||
/// <returns></returns>
|
||||
public static QueryData<T> ToQueryData<T>(this Page<T> pages)
|
||||
{
|
||||
return new QueryData<T>()
|
||||
{
|
||||
Items = pages.Items,
|
||||
PageIndex = (int)pages.CurrentPage,
|
||||
PageItems = (int)pages.ItemsPerPage,
|
||||
TotalCount = (int)pages.TotalItems,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using Bootstrap.Admin.Pages.Components;
|
||||
using Longbow.Web.Mvc;
|
||||
|
||||
namespace Bootstrap.Admin.Pages.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// QueryPageOptions 扩展操作类
|
||||
/// </summary>
|
||||
public static class QueryPageOptionsExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// QueryPageOptions 转换为 PaginationOption 方法
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
public static PaginationOption ToPaginationOption(this QueryPageOptions options)
|
||||
{
|
||||
return new PaginationOption()
|
||||
{
|
||||
Limit = options.PageItems,
|
||||
Offset = (options.PageIndex - 1) * options.PageItems,
|
||||
Order = options.SortOrder == SortOrder.Unset ? "" : options.SortOrder.ToString(),
|
||||
Sort = options.SortName,
|
||||
Search = options.SearchText
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
@inherits LogsBase
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<span>查询结果</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<Table Id="logs" TItem="Bootstrap.DataAccess.Log" ShowToolBar="true" ShowSearch="true" ShowRefresh="true" QueryModel="QueryModel" EditModel="DataContext" OnQuery="Query" OnResetSearch="ResetSearch">
|
||||
<TableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.CRUD"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.UserName"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="DateTime" @bind-Value="@context.LogTime"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.Ip"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.City"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.Browser"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.OS"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.RequestUrl"></LgbTableHeader>
|
||||
</TableHeader>
|
||||
<RowTemplate>
|
||||
<td>@context.CRUD</td>
|
||||
<td>@context.UserName</td>
|
||||
<td>@context.LogTime</td>
|
||||
<td>@context.Ip</td>
|
||||
<td>@context.City</td>
|
||||
<td>@context.Browser</td>
|
||||
<td>@context.OS</td>
|
||||
<td>@context.RequestUrl</td>
|
||||
</RowTemplate>
|
||||
<ButtonTemplate>
|
||||
<button class='btn btn-sm btn-info'><i class='fa fa-info'></i><span>明细</span></button>
|
||||
</ButtonTemplate>
|
||||
<SearchTemplate>
|
||||
<LgbInputText ColumnClass="col-12" @bind-Value="@context.CRUD" maxlength="50" />
|
||||
</SearchTemplate>
|
||||
</Table>
|
||||
</div>
|
||||
</div>
|
|
@ -190,9 +190,7 @@
|
|||
</ConditionComponent>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="d-flex align-items-center">
|
||||
<span class="flex-fill">网站缓存</span>
|
||||
</div>
|
||||
<span>网站缓存</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<Table Id="settings-cache" TItem="Longbow.Cache.ICacheItem" EditModel="ConsoleCaCheModel" OnDataSourceQuery="QueryData">
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
using Bootstrap.Admin.Pages.Components;
|
||||
using Bootstrap.Admin.Pages.Extensions;
|
||||
using Bootstrap.DataAccess;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
|
||||
namespace Bootstrap.Admin.Pages.Views.Admin.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// 部门维护组件
|
||||
/// </summary>
|
||||
public class LogsBase : ComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 获得/设置 编辑类型实例
|
||||
/// </summary>
|
||||
protected Log DataContext { get; set; } = new Log();
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 查询绑定类型实例
|
||||
/// </summary>
|
||||
protected Log QueryModel { get; set; } = new Log();
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 开始时间
|
||||
/// </summary>
|
||||
protected DateTime? StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 开始时间
|
||||
/// </summary>
|
||||
protected DateTime? EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据查询方法
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
protected QueryData<Log> Query(QueryPageOptions options)
|
||||
{
|
||||
var data = LogHelper.RetrievePages(options.ToPaginationOption(), StartTime, EndTime, QueryModel.CRUD);
|
||||
return data.ToQueryData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置搜索方法
|
||||
/// </summary>
|
||||
protected void ResetSearch()
|
||||
{
|
||||
QueryModel.CRUD = "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
using PetaPoco;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
|
@ -14,6 +15,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <summary>
|
||||
/// 获得/设置 操作类型
|
||||
/// </summary>
|
||||
[DisplayName("操作类型")]
|
||||
public string CRUD { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using PetaPoco;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
|
@ -19,46 +20,55 @@ namespace Bootstrap.DataAccess
|
|||
/// <summary>
|
||||
/// 获得/设置 用户名称
|
||||
/// </summary>
|
||||
[DisplayName("用户名称")]
|
||||
public string UserName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 操作时间
|
||||
/// </summary>
|
||||
[DisplayName("操作时间")]
|
||||
public DateTime LogTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 客户端IP
|
||||
/// </summary>
|
||||
[DisplayName("登录主机")]
|
||||
public string Ip { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 客户端地点
|
||||
/// </summary>
|
||||
[DisplayName("操作地点")]
|
||||
public string City { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 客户端浏览器
|
||||
/// </summary>
|
||||
[DisplayName("浏览器")]
|
||||
public string Browser { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 客户端操作系统
|
||||
/// </summary>
|
||||
[DisplayName("操作系统")]
|
||||
public string OS { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 获取/设置 请求网址
|
||||
/// </summary>
|
||||
[DisplayName("操作页面")]
|
||||
public string RequestUrl { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 客户端 UserAgent
|
||||
/// </summary>
|
||||
[DisplayName("UserAgent")]
|
||||
public string UserAgent { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 客户端 Referer
|
||||
/// </summary>
|
||||
[DisplayName("Referer")]
|
||||
public string Referer { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue