refactor: 重构 SQL 功能到 Tools 控制器下
This commit is contained in:
parent
dd85f12e79
commit
2c49fbff42
|
@ -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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL 视图
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize(Roles = "Administrators")]
|
||||
[HttpGet]
|
||||
public IActionResult SQL()
|
||||
{
|
||||
return View(new SQLModel(this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL 视图
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 错误视图
|
||||
/// </summary>
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
using Bootstrap.Client.Models;
|
||||
using Longbow.Data;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Bootstrap.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// Tools 控制器
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
public class ToolsController : Controller
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// SQL 视图
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize(Roles = "Administrators")]
|
||||
[HttpGet]
|
||||
public IActionResult SQL()
|
||||
{
|
||||
return View(new SQLModel(this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL 视图
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue