70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
|
|
using Infrastructure;
|
|||
|
|
using Microsoft.AspNetCore.Authorization;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
using OpenAuth.App.DbTable;
|
|||
|
|
using OpenAuth.App.Request;
|
|||
|
|
|
|||
|
|
namespace OpenAuth.WebApi.Controllers
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 日 期:2024.05.13
|
|||
|
|
/// 描 述:数据库表
|
|||
|
|
/// </summary>
|
|||
|
|
[Route("api/[controller]/[action]")]
|
|||
|
|
[ApiController]
|
|||
|
|
public class DbTableController : ControllerBase
|
|||
|
|
{
|
|||
|
|
private readonly DbTableApp _app;
|
|||
|
|
public DbTableController(DbTableApp app)
|
|||
|
|
{
|
|||
|
|
_app = app;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 创建表信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dbCode">数据库编码</param>
|
|||
|
|
/// <param name="req">数据表信息</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
[AllowAnonymous]
|
|||
|
|
public Response<bool> AddTable(string dbCode, DbTableReq req)
|
|||
|
|
{
|
|||
|
|
var result = new Response<bool>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
return _app.AddTable(dbCode, req);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
result.Code = 500;
|
|||
|
|
result.Result = false;
|
|||
|
|
result.Message = ex.Message;
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 创建字段
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dbcode">数据库编码</param>
|
|||
|
|
/// <param name="dbColumnInput">表字段</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
[AllowAnonymous]
|
|||
|
|
public Response<bool> AddColumn(string dbCode, DbColumnInput req)
|
|||
|
|
{
|
|||
|
|
var result = new Response<bool>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
return _app.AddColumn(dbCode, req);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
result.Code = 500;
|
|||
|
|
result.Result = false;
|
|||
|
|
result.Message = ex.Message;
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|