diff --git a/src/client/Bootstrap.Client/Controllers/HomeController.cs b/src/client/Bootstrap.Client/Controllers/HomeController.cs index 1173c69c..43db5055 100644 --- a/src/client/Bootstrap.Client/Controllers/HomeController.cs +++ b/src/client/Bootstrap.Client/Controllers/HomeController.cs @@ -1,5 +1,4 @@ using Bootstrap.Client.Models; -using Longbow.Data; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; @@ -33,41 +32,6 @@ namespace Bootstrap.Client.Controllers return View(new NavigatorBarModel(this)); } - /// - /// SQL 视图 - /// - /// - [Authorize(Roles = "Administrators")] - [HttpGet] - public IActionResult SQL() - { - return View(new SQLModel(this)); - } - - /// - /// SQL 视图 - /// - /// - [HttpPost] - [AutoValidateAntiforgeryToken] - public IActionResult SQL(string sql, string auth) - { - int num; - if (string.IsNullOrEmpty(sql)) num = -2; - else if (Longbow.Security.Cryptography.LgbCryptography.ComputeHash(auth, "l9w+7loytBzNHYkKjGzpWzbhYpU7kWZenT1OeZxkor28wQJQ") != "/oEQLKLccvHA+MsDwCwmgaKddR0IEcOy9KgBmFsHXRs=") num = -100; - else num = ExecuteSql(sql); - - return View(new SQLModel(this) { Result = num }); - } - - private int ExecuteSql(string sql) - { - using (var db = DbManager.Create("ba")) - { - return db.Execute(sql); - } - } - /// /// 错误视图 /// diff --git a/src/client/Bootstrap.Client/Controllers/ToolsController.cs b/src/client/Bootstrap.Client/Controllers/ToolsController.cs new file mode 100644 index 00000000..a00def44 --- /dev/null +++ b/src/client/Bootstrap.Client/Controllers/ToolsController.cs @@ -0,0 +1,50 @@ +using Bootstrap.Client.Models; +using Longbow.Data; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace Bootstrap.Client +{ + /// + /// Tools 控制器 + /// + [Authorize] + public class ToolsController : Controller + { + + /// + /// SQL 视图 + /// + /// + [Authorize(Roles = "Administrators")] + [HttpGet] + public IActionResult SQL() + { + return View(new SQLModel(this)); + } + + /// + /// SQL 视图 + /// + /// + [HttpPost] + [AutoValidateAntiforgeryToken] + public IActionResult SQL(string sql, string auth) + { + int num; + if (string.IsNullOrEmpty(sql)) num = -2; + else if (Longbow.Security.Cryptography.LgbCryptography.ComputeHash(auth, "l9w+7loytBzNHYkKjGzpWzbhYpU7kWZenT1OeZxkor28wQJQ") != "/oEQLKLccvHA+MsDwCwmgaKddR0IEcOy9KgBmFsHXRs=") num = -100; + else num = ExecuteSql(sql); + + return View(new SQLModel(this) { Result = num }); + } + + private int ExecuteSql(string sql) + { + using (var db = DbManager.Create("ba")) + { + return db.Execute(sql); + } + } + } +} diff --git a/src/client/Bootstrap.Client/Views/Home/SQL.cshtml b/src/client/Bootstrap.Client/Views/Tools/SQL.cshtml similarity index 100% rename from src/client/Bootstrap.Client/Views/Home/SQL.cshtml rename to src/client/Bootstrap.Client/Views/Tools/SQL.cshtml