|
|
|
|
@@ -339,50 +339,50 @@ public class DataBaseManager : IDataBaseManager, ITransient
|
|
|
|
|
|
|
|
|
|
//try
|
|
|
|
|
//{
|
|
|
|
|
int total = 0;
|
|
|
|
|
int total = 0;
|
|
|
|
|
|
|
|
|
|
if (_sqlSugarClient.CurrentConnectionConfig.DbType == SqlSugar.DbType.Oracle) strSql = strSql.Replace(";", string.Empty);
|
|
|
|
|
if (_sqlSugarClient.CurrentConnectionConfig.DbType == SqlSugar.DbType.Oracle) strSql = strSql.Replace(";", string.Empty);
|
|
|
|
|
|
|
|
|
|
var sidx = pageInput.sidx.IsNotEmptyOrNull() && pageInput.sort.IsNotEmptyOrNull(); // 按前端参数排序
|
|
|
|
|
var defaultSidx = columnDesign.defaultSidx.IsNotEmptyOrNull() && columnDesign.sort.IsNotEmptyOrNull(); // 按模板默认排序
|
|
|
|
|
var sidx = pageInput.sidx.IsNotEmptyOrNull() && pageInput.sort.IsNotEmptyOrNull(); // 按前端参数排序
|
|
|
|
|
var defaultSidx = columnDesign.defaultSidx.IsNotEmptyOrNull() && columnDesign.sort.IsNotEmptyOrNull(); // 按模板默认排序
|
|
|
|
|
|
|
|
|
|
var dataRuleJson = new List<IConditionalModel>();
|
|
|
|
|
if (pageInput.dataRuleJson.IsNotEmptyOrNull()) dataRuleJson = _sqlSugarClient.Utilities.JsonToConditionalModels(pageInput.dataRuleJson);
|
|
|
|
|
var dataRuleJson = new List<IConditionalModel>();
|
|
|
|
|
if (pageInput.dataRuleJson.IsNotEmptyOrNull()) dataRuleJson = _sqlSugarClient.Utilities.JsonToConditionalModels(pageInput.dataRuleJson);
|
|
|
|
|
|
|
|
|
|
var querJson = new List<IConditionalModel>();
|
|
|
|
|
if (pageInput.queryJson.IsNotEmptyOrNull()) querJson = _sqlSugarClient.Utilities.JsonToConditionalModels(pageInput.queryJson);
|
|
|
|
|
var querJson = new List<IConditionalModel>();
|
|
|
|
|
if (pageInput.queryJson.IsNotEmptyOrNull()) querJson = _sqlSugarClient.Utilities.JsonToConditionalModels(pageInput.queryJson);
|
|
|
|
|
|
|
|
|
|
var superQueryJson = new List<IConditionalModel>();
|
|
|
|
|
if (pageInput.superQueryJson.IsNotEmptyOrNull()) superQueryJson = _sqlSugarClient.Utilities.JsonToConditionalModels(pageInput.superQueryJson);
|
|
|
|
|
// var sql = _sqlSugarClient.SqlQueryable<object>(strSql)
|
|
|
|
|
// .Where(dataRuleJson).Where(querJson).Where(superQueryJson).Where(dataPermissions).ToSqlString();
|
|
|
|
|
DataTable dt = _sqlSugarClient.SqlQueryable<object>(strSql)
|
|
|
|
|
.Where(dataRuleJson).Where(querJson).Where(superQueryJson).Where(dataPermissions)
|
|
|
|
|
.OrderByIF(sidx, pageInput.sidx + " " + pageInput.sort).OrderByIF(!sidx && defaultSidx, columnDesign.defaultSidx + " " + columnDesign.sort)
|
|
|
|
|
.ToDataTablePage(pageInput.currentPage, pageInput.pageSize, ref total);
|
|
|
|
|
var superQueryJson = new List<IConditionalModel>();
|
|
|
|
|
if (pageInput.superQueryJson.IsNotEmptyOrNull()) superQueryJson = _sqlSugarClient.Utilities.JsonToConditionalModels(pageInput.superQueryJson);
|
|
|
|
|
// var sql = _sqlSugarClient.SqlQueryable<object>(strSql)
|
|
|
|
|
// .Where(dataRuleJson).Where(querJson).Where(superQueryJson).Where(dataPermissions).ToSqlString();
|
|
|
|
|
DataTable dt = _sqlSugarClient.SqlQueryable<object>(strSql)
|
|
|
|
|
.Where(dataRuleJson).Where(querJson).Where(superQueryJson).Where(dataPermissions)
|
|
|
|
|
.OrderByIF(sidx, pageInput.sidx + " " + pageInput.sort).OrderByIF(!sidx && defaultSidx, columnDesign.defaultSidx + " " + columnDesign.sort)
|
|
|
|
|
.ToDataTablePage(pageInput.currentPage, pageInput.pageSize, ref total);
|
|
|
|
|
|
|
|
|
|
// 如果有字段别名 替换 ColumnName
|
|
|
|
|
if (outColumnName != null && outColumnName.Count > 0)
|
|
|
|
|
// 如果有字段别名 替换 ColumnName
|
|
|
|
|
if (outColumnName != null && outColumnName.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var resultKey = string.Empty;
|
|
|
|
|
for (var i = 0; i < dt.Columns.Count; i++)
|
|
|
|
|
dt.Columns[i].ColumnName = outColumnName.TryGetValue(dt.Columns[i].ColumnName.ToUpper(), out resultKey) == true ? outColumnName[dt.Columns[i].ColumnName.ToUpper()] : dt.Columns[i].ColumnName.ToUpper();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data = new PageResult<Dictionary<string, object>>()
|
|
|
|
|
{
|
|
|
|
|
pagination = new PageResult()
|
|
|
|
|
{
|
|
|
|
|
var resultKey = string.Empty;
|
|
|
|
|
for (var i = 0; i < dt.Columns.Count; i++)
|
|
|
|
|
dt.Columns[i].ColumnName = outColumnName.TryGetValue(dt.Columns[i].ColumnName.ToUpper(), out resultKey) == true ? outColumnName[dt.Columns[i].ColumnName.ToUpper()] : dt.Columns[i].ColumnName.ToUpper();
|
|
|
|
|
}
|
|
|
|
|
currentPage = pageInput.currentPage,
|
|
|
|
|
pageSize = pageInput.pageSize,
|
|
|
|
|
total = total
|
|
|
|
|
},
|
|
|
|
|
list = dt.ToObject<List<Dictionary<string, string>>>().ToObject<List<Dictionary<string, object>>>()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var data = new PageResult<Dictionary<string, object>>()
|
|
|
|
|
{
|
|
|
|
|
pagination = new PageResult()
|
|
|
|
|
{
|
|
|
|
|
currentPage = pageInput.currentPage,
|
|
|
|
|
pageSize = pageInput.pageSize,
|
|
|
|
|
total = total
|
|
|
|
|
},
|
|
|
|
|
list = dt.ToObject<List<Dictionary<string, string>>>().ToObject<List<Dictionary<string, object>>>()
|
|
|
|
|
};
|
|
|
|
|
_sqlSugarClient.ChangeDatabase(_connectionStrings.ConfigId);
|
|
|
|
|
|
|
|
|
|
_sqlSugarClient.ChangeDatabase(_connectionStrings.ConfigId);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
return data;
|
|
|
|
|
//}
|
|
|
|
|
//catch (Exception ex)
|
|
|
|
|
//{
|
|
|
|
|
@@ -456,15 +456,15 @@ public class DataBaseManager : IDataBaseManager, ITransient
|
|
|
|
|
_sqlSugarClient.ChangeDatabase(_connectionStrings.ConfigId);
|
|
|
|
|
return list.Adapt<List<DbTableFieldModel>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<string> GetPrimaries(DbLinkEntity? link, string tableName)
|
|
|
|
|
|
|
|
|
|
public List<string> GetPrimaries(DbLinkEntity? link, string tableName)
|
|
|
|
|
{
|
|
|
|
|
if (link != null && _sqlSugarClient.CurrentConnectionConfig.ConfigId != link.Id)
|
|
|
|
|
_sqlSugarClient = ChangeDataBase(link);
|
|
|
|
|
_sqlSugarClient = ChangeDataBase(link);
|
|
|
|
|
|
|
|
|
|
var data = _sqlSugarClient.DbMaintenance.GetPrimaries(tableName);
|
|
|
|
|
_sqlSugarClient.ChangeDatabase(_connectionStrings.ConfigId);
|
|
|
|
|
return data;
|
|
|
|
|
_sqlSugarClient.ChangeDatabase(_connectionStrings.ConfigId);
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
@@ -597,7 +597,7 @@ public class DataBaseManager : IDataBaseManager, ITransient
|
|
|
|
|
//var modelList = _sqlSugarClient.Ado.SqlQuery<DynamicDbTableModel>(sql).ToList();
|
|
|
|
|
var modelList = _sqlSugarClient.Ado.SqlQuery<DatabaseTableListOutput>(sql).ToList();
|
|
|
|
|
//return modelList.Select(x => new DatabaseTableListOutput { table = x.F_TABLE, tableName = x.F_TABLENAME, sum = x.F_SUM.ParseToInt() }).ToList();
|
|
|
|
|
_sqlSugarClient.ChangeDatabase(_connectionStrings.ConfigId);
|
|
|
|
|
_sqlSugarClient.ChangeDatabase(_connectionStrings.ConfigId);
|
|
|
|
|
return modelList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|