mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 02:29:24 +08:00
feat: 增加根据表和数据源获取表结构
This commit is contained in:
@@ -85,6 +85,11 @@ namespace OpenAuth.App
|
||||
/// <returns></returns>
|
||||
public IList<SysTableColumn> GetDbTableStructure(string tableName)
|
||||
{
|
||||
if(string.IsNullOrEmpty(tableName))
|
||||
{
|
||||
return new List<SysTableColumn>();
|
||||
}
|
||||
|
||||
//如果是空,说明没有通过ProcessExternalDb设置过,直接从本地读取
|
||||
if(string.IsNullOrEmpty(_dbTypeStr)){
|
||||
_dbTypeStr = _appConfiguration.Value.DbTypes[_httpContextAccessor.GetTenantId()];
|
||||
@@ -414,6 +419,22 @@ namespace OpenAuth.App
|
||||
return new List<SysTableColumn>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过表名和外部数据源ID获取表结构
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="externalDataSourceId">外部数据源ID</param>
|
||||
/// <returns></returns>
|
||||
public IList<SysTableColumn> GetDbTableStructure(string tableName, string externalDataSourceId){
|
||||
var connection = SugarClient.Queryable<ExternalDataSource>().First(u => u.Id == externalDataSourceId);
|
||||
if (connection != null)
|
||||
{
|
||||
var dbType = connection.Dbtype;
|
||||
SetConnection(connection.Connectionstring, dbType);
|
||||
}
|
||||
return GetDbTableStructure(tableName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理外部数据库
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user