using Infrastructure; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using OpenAuth.App.DataSource; using OpenAuth.App.SysDatabaseLink; using OpenAuth.Repository.Domain; namespace OpenAuth.WebApi.Controllers { /// /// 日 期: 2024-03-02 /// 描 述: 数据源管理 /// [Route("api/[controller]/[action]")] [ApiController] public class DataSourceController : ControllerBase { private readonly DataSourceApp _app; public DataSourceController(DataSourceApp app) { _app = app; } /// /// 分页获取列表数据 /// /// 筛选条件 /// 当前页 /// 每页条数 /// [HttpGet] public async Task>>> LoadDataBaseInfo(string keyword, int page = 1, int limit = 15) { return await _app.LoadDataSourceList(keyword, page, limit); } /// /// 获取数据源列名 /// /// 数据源编码 /// [HttpGet] public async Task>> GetDataColName(string code) { return await _app.GetDataColName(code); } /// /// 获取单个数据源 /// /// 数据源编码 /// [HttpGet] [AllowAnonymous] public async Task GetEntityByCode(string code) { return await _app.GetEntityByCode(code); } /// /// 新增数据源 /// /// 主键 /// 实体 /// [HttpPost] public async Task> AddOrUpdateForm(string id, DataSource entity) { var result = new Response(); try { result = await _app.SaveEntity(id, entity); } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } /// /// 删除数据源 /// /// 主键 [HttpPost] public async Task> DeleteEntity(string keyValue) { var result = new Response(); try { result = await _app.DeleteEntity(keyValue); } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } } }