feat: Blazor 增加 SQL日志功能
This commit is contained in:
parent
364c718cd2
commit
79175dcbe2
|
@ -0,0 +1,24 @@
|
|||
@inherits SQLBase
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<span>查询结果</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<Table Id="logs" TItem="Bootstrap.DataAccess.DBLog" ShowToolBar="true" ShowSearch="true" ShowRefresh="true" QueryModel="QueryModel" EditModel="DataContext" OnQuery="Query" OnResetSearch="ResetSearch">
|
||||
<TableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.UserName" class="text-nowrap"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="DateTime" @bind-Value="@context.LogTime" class="text-nowrap datetime"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.SQL"></LgbTableHeader>
|
||||
</TableHeader>
|
||||
<RowTemplate>
|
||||
<td>@context.UserName</td>
|
||||
<td>@context.LogTime</td>
|
||||
<td>@context.SQL</td>
|
||||
</RowTemplate>
|
||||
<SearchTemplate>
|
||||
<LgbInputText ColumnClass="col-12" @bind-Value="@context.UserName" maxlength="50" />
|
||||
</SearchTemplate>
|
||||
</Table>
|
||||
</div>
|
||||
</div>
|
|
@ -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 SQLBase : ComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 获得/设置 编辑类型实例
|
||||
/// </summary>
|
||||
protected DBLog DataContext { get; set; } = new DBLog();
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 查询绑定类型实例
|
||||
/// </summary>
|
||||
protected DBLog QueryModel { get; set; } = new DBLog();
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 开始时间
|
||||
/// </summary>
|
||||
protected DateTime? StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 开始时间
|
||||
/// </summary>
|
||||
protected DateTime? EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据查询方法
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
protected QueryData<DBLog> Query(QueryPageOptions options)
|
||||
{
|
||||
var data = LogHelper.RetrieveDBLogs(options.ToPaginationOption(), StartTime, EndTime, QueryModel.UserName);
|
||||
return data.ToQueryData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置搜索方法
|
||||
/// </summary>
|
||||
protected void ResetSearch()
|
||||
{
|
||||
QueryModel.UserName = "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -156,6 +156,10 @@ nav .dropdown .nav-link-close.dropdown-toggle:after {
|
|||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.bootstrap-table .datetime {
|
||||
min-width: 154px;
|
||||
}
|
||||
|
||||
.bootstrap-table .sortable {
|
||||
padding-right: 30px;
|
||||
cursor: pointer;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using Longbow.Web.Mvc;
|
||||
using PetaPoco;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
|
@ -19,16 +20,19 @@ namespace Bootstrap.DataAccess
|
|||
/// <summary>
|
||||
/// 获得/设置 当前登陆名
|
||||
/// </summary>
|
||||
[DisplayName("所属用户")]
|
||||
public string? UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 数据库执行脚本
|
||||
/// </summary>
|
||||
[DisplayName("脚本内容")]
|
||||
public string SQL { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 获取/设置 用户角色关联状态 checked 标示已经关联 '' 标示未关联
|
||||
/// </summary>
|
||||
[DisplayName("执行时间")]
|
||||
public DateTime LogTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue