using System; using System.Collections.Generic; using System.Linq; using Infrastructure; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using OpenAuth.App; using OpenAuth.App.Response; using OpenAuth.Repository.QueryObj; namespace OpenAuth.WebApi.Controllers { /// /// 系统配置信息 /// [Route("api/[controller]/[action]")] [ApiController] [ApiExplorerSettings(GroupName = "系统配置_SysConf")] public class SysConfController : ControllerBase { private IOptions _appConfiguration; private DbExtension _dbExtension; public SysConfController(IOptions appConfiguration, DbExtension dbExtension) { _appConfiguration = appConfiguration; _dbExtension = dbExtension; } /// /// 是否Identity认证 /// /// [AllowAnonymous] [HttpGet] public Response IsIdentityAuth() { return new Response { Data = _appConfiguration.Value.IsIdentityAuth }; } /// /// 获取数据库表结构 /// /// 表名 /// 外部数据源ID /// [HttpGet] public Response> GetDbTableStructure(string tableName, string externalDataSourceId) { var result = new Response>(); try { result.Data = _dbExtension.GetDbTableStructure(tableName, externalDataSourceId).ToList(); } catch (Exception ex) { result.Code = 500; result.Message = ex.Message; } return result; } /// /// 获取数据库表结构(用于下拉框) /// /// 表名 /// 外部数据源ID /// [HttpGet] public PagedDynamicDataResp GetDbTableStructureForSelect(string tableName, string externalDataSourceId) { var result = new PagedDynamicDataResp(); try { result.Data = _dbExtension.GetDbTableStructure(tableName, externalDataSourceId).Select(u => new { Id = u.ColumnName, Name = u.ColumnName }); } catch (Exception ex) { result.Code = 500; result.Message = ex.Message; } return result; } } }