diff --git a/src/admin/Bootstrap.Admin/Controllers/AdminController.cs b/src/admin/Bootstrap.Admin/Controllers/AdminController.cs
index 0b920afb..cfb9bc5a 100644
--- a/src/admin/Bootstrap.Admin/Controllers/AdminController.cs
+++ b/src/admin/Bootstrap.Admin/Controllers/AdminController.cs
@@ -53,6 +53,12 @@ namespace Bootstrap.Admin.Controllers
///
public ActionResult Logs() => View(new NavigatorBarModel(this));
+ ///
+ ///
+ ///
+ ///
+ public ActionResult SQL() => View(new NavigatorBarModel(this));
+
///
///
///
diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/SQLController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/SQLController.cs
new file mode 100644
index 00000000..90842cdb
--- /dev/null
+++ b/src/admin/Bootstrap.Admin/Controllers/Api/SQLController.cs
@@ -0,0 +1,26 @@
+using Bootstrap.Admin.Query;
+using Bootstrap.DataAccess;
+using Longbow.Web.Mvc;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Bootstrap.Admin.Controllers.Api
+{
+ ///
+ /// SQL 语句执行日志 webapi
+ ///
+ [Route("api/[controller]")]
+ [ApiController]
+ public class SQLController : ControllerBase
+ {
+ ///
+ /// 获取执行日志数据
+ ///
+ ///
+ ///
+ [HttpGet]
+ public QueryData Get([FromQuery]QuerySQLOption value)
+ {
+ return value.RetrieveData();
+ }
+ }
+}
diff --git a/src/admin/Bootstrap.Admin/Query/QuerySQLOption.cs b/src/admin/Bootstrap.Admin/Query/QuerySQLOption.cs
new file mode 100644
index 00000000..01bbf00f
--- /dev/null
+++ b/src/admin/Bootstrap.Admin/Query/QuerySQLOption.cs
@@ -0,0 +1,40 @@
+using Bootstrap.DataAccess;
+using Longbow.Web.Mvc;
+using System;
+
+namespace Bootstrap.Admin.Query
+{
+ ///
+ /// SQL执行查询配置类
+ ///
+ public class QuerySQLOption : PaginationOption
+ {
+ ///
+ /// 获得/设置 用户登录名
+ ///
+ public string UserName { get; set; }
+
+ ///
+ /// 获得/设置 开始时间
+ ///
+ public DateTime? OperateTimeStart { get; set; }
+
+ ///
+ /// 获得/设置 结束时间
+ ///
+ public DateTime? OperateTimeEnd { get; set; }
+
+ ///
+ /// 查询数据方法
+ ///
+ ///
+ public QueryData RetrieveData()
+ {
+ var data = LogHelper.RetrieveDBLogs(this, OperateTimeStart, OperateTimeEnd, UserName);
+ var ret = new QueryData();
+ ret.total = data.TotalItems;
+ ret.rows = data.Items;
+ return ret;
+ }
+ }
+}
diff --git a/src/admin/Bootstrap.Admin/Tasks/TasksExtensions.cs b/src/admin/Bootstrap.Admin/Tasks/TasksExtensions.cs
index 5d81438b..e6151237 100644
--- a/src/admin/Bootstrap.Admin/Tasks/TasksExtensions.cs
+++ b/src/admin/Bootstrap.Admin/Tasks/TasksExtensions.cs
@@ -52,7 +52,7 @@ namespace Microsoft.Extensions.DependencyInjection
TaskServicesManager.GetOrAdd("禁用任务", token => Task.Delay(1000)).Status = SchedulerStatus.Disabled;
// 真实任务负责批次写入数据执行脚本到日志中
- TaskServicesManager.GetOrAdd("数据库脚本执行日志", TriggerBuilder.Build(Cron.Minutely()));
+ TaskServicesManager.GetOrAdd("SQL日志", TriggerBuilder.Build(Cron.Minutely()));
});
}
}
diff --git a/src/admin/Bootstrap.Admin/Views/Admin/SQL.cshtml b/src/admin/Bootstrap.Admin/Views/Admin/SQL.cshtml
new file mode 100644
index 00000000..bc919c77
--- /dev/null
+++ b/src/admin/Bootstrap.Admin/Views/Admin/SQL.cshtml
@@ -0,0 +1,80 @@
+@model NavigatorBarModel
+@{
+ ViewBag.Title = "SQL日志";
+}
+@section css {
+
+
+
+
+
+
+
+
+}
+@section javascript {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+
diff --git a/src/admin/Bootstrap.Admin/wwwroot/js/sql.js b/src/admin/Bootstrap.Admin/wwwroot/js/sql.js
new file mode 100644
index 00000000..e218976d
--- /dev/null
+++ b/src/admin/Bootstrap.Admin/wwwroot/js/sql.js
@@ -0,0 +1,20 @@
+$(function () {
+ var url = 'api/SQL';
+ var $data = $('#requestData');
+ var $dialog = $('#dialogRequestData');
+
+ $('.card-body table').smartTable({
+ url: url,
+ sortName: 'LogTime',
+ sortOrder: 'desc',
+ queryParams: function (params) { return $.extend(params, { UserName: $("#txt_username").val(), OperateTimeStart: $("#txt_operate_start").val(), OperateTimeEnd: $("#txt_operate_end").val() }); },
+ columns: [
+ { title: "所属用户", field: "UserName", sortable: true },
+ { title: "执行时间", field: "LogTime", sortable: true },
+ { title: "脚本内容", field: "SQL", sortable: false }
+ ],
+ exportOptions: {
+ fileName: "SQL日志数据"
+ }
+ });
+});
diff --git a/src/admin/Bootstrap.DataAccess/DBLog.cs b/src/admin/Bootstrap.DataAccess/DBLog.cs
index ee4bc523..a7b6a393 100644
--- a/src/admin/Bootstrap.DataAccess/DBLog.cs
+++ b/src/admin/Bootstrap.DataAccess/DBLog.cs
@@ -31,7 +31,7 @@ namespace Bootstrap.DataAccess
public DateTime LogTime { get; set; }
///
- /// 查询所有操作日志信息
+ /// 查询所有SQL日志信息
///
///
///
diff --git a/src/admin/Bootstrap.DataAccess/Helper/LogHelper.cs b/src/admin/Bootstrap.DataAccess/Helper/LogHelper.cs
index 41c00cc3..ade01c25 100644
--- a/src/admin/Bootstrap.DataAccess/Helper/LogHelper.cs
+++ b/src/admin/Bootstrap.DataAccess/Helper/LogHelper.cs
@@ -54,6 +54,16 @@ namespace Bootstrap.DataAccess
}
});
+ ///
+ /// 查询所有SQL日志信息
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static Page RetrieveDBLogs(PaginationOption op, DateTime? startTime, DateTime? endTime, string userName) => DbContextManager.Create().RetrievePages(op, startTime, endTime, userName);
+
///
/// 数据库脚本执行日志任务实体类
///