|
|
|
@ -51,6 +51,33 @@ namespace ZKLT.Hadoop
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 合并列
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="table">表</param>
|
|
|
|
|
/// <param name="cols">列</param>
|
|
|
|
|
/// <param name="command">命令</param>
|
|
|
|
|
private void MergeCols(HDP_Table table, string[]? cols, StringBuilder command)
|
|
|
|
|
{
|
|
|
|
|
if (cols == null || cols.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
command.AppendLine(" * ");
|
|
|
|
|
}
|
|
|
|
|
StringBuilder _colstr = new StringBuilder();
|
|
|
|
|
for (var i = 0; i < table.Columns!.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (cols!.Any(x => x == table.Columns[i].Key))
|
|
|
|
|
{
|
|
|
|
|
_colstr.Append($@"`{table.Columns[i].Key}`,");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (_colstr[_colstr.Length - 1] == ',')
|
|
|
|
|
{
|
|
|
|
|
_colstr.Remove(_colstr.Length - 1, 1);
|
|
|
|
|
}
|
|
|
|
|
command.AppendLine(_colstr.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 同步结构
|
|
|
|
|
/// </summary>
|
|
|
|
@ -504,7 +531,8 @@ namespace ZKLT.Hadoop
|
|
|
|
|
/// <param name="where">条件</param>
|
|
|
|
|
/// <param name="row">数据</param>
|
|
|
|
|
/// <returns>结果</returns>
|
|
|
|
|
public T? QuerySingle<T>(HDP_Source source, HDP_Table table, Dictionary<string, string> where, Dictionary<string, object> row)
|
|
|
|
|
public T? QuerySingle<T>(HDP_Source source, HDP_Table table, Dictionary<string, string> where, Dictionary<string, object> row,
|
|
|
|
|
string[]? col)
|
|
|
|
|
{
|
|
|
|
|
//数据校验
|
|
|
|
|
if (string.IsNullOrEmpty(table.Key))
|
|
|
|
@ -537,7 +565,16 @@ namespace ZKLT.Hadoop
|
|
|
|
|
//查询命令
|
|
|
|
|
StringBuilder _command = new StringBuilder();
|
|
|
|
|
Dictionary<string, object> _params = new Dictionary<string, object>();
|
|
|
|
|
_command.AppendLine(@$"SELECT * FROM `{table.Key}`");
|
|
|
|
|
if (col == null || col.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
_command.AppendLine(@$"SELECT * FROM `{table.Key}`");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_command.AppendLine("SELECT");
|
|
|
|
|
MergeCols(table, col, _command);
|
|
|
|
|
_command.AppendLine($@"FROM `{table.Key}`");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//执行条件
|
|
|
|
|
MergeWhere(table, where, row, _command, _params);
|
|
|
|
@ -564,7 +601,8 @@ namespace ZKLT.Hadoop
|
|
|
|
|
/// <param name="where">条件</param>
|
|
|
|
|
/// <param name="row">数据</param>
|
|
|
|
|
/// <returns>结果集</returns>
|
|
|
|
|
public T[] Query<T>(HDP_Source source, HDP_Table table, Dictionary<string, string>? where = null, Dictionary<string, object>? row = null, Dictionary<string, string>? order = null)
|
|
|
|
|
public T[] Query<T>(HDP_Source source, HDP_Table table, Dictionary<string, string>? where, Dictionary<string, object>? row,
|
|
|
|
|
Dictionary<string, string>? order, string[]? col)
|
|
|
|
|
{
|
|
|
|
|
//数据校验
|
|
|
|
|
if (string.IsNullOrEmpty(table.Key))
|
|
|
|
@ -589,7 +627,16 @@ namespace ZKLT.Hadoop
|
|
|
|
|
//查询命令
|
|
|
|
|
StringBuilder _command = new StringBuilder();
|
|
|
|
|
Dictionary<string, object> _params = new Dictionary<string, object>();
|
|
|
|
|
_command.AppendLine(@$"SELECT * FROM `{table.Key}`");
|
|
|
|
|
if (col == null || col.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
_command.AppendLine(@$"SELECT * FROM `{table.Key}`");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_command.AppendLine("SELECT");
|
|
|
|
|
MergeCols(table, col, _command);
|
|
|
|
|
_command.AppendLine($@"FROM `{table.Key}`");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//执行条件
|
|
|
|
|
MergeWhere(table, where, row, _command, _params);
|
|
|
|
@ -636,7 +683,8 @@ namespace ZKLT.Hadoop
|
|
|
|
|
/// <param name="where">条件</param>
|
|
|
|
|
/// <param name="row">数据</param>
|
|
|
|
|
/// <returns>结果集</returns>
|
|
|
|
|
public HDP_Page<T> QueryPage<T>(HDP_Source source, HDP_Table table, int pageIndex, int pageSize, Dictionary<string, string>? where = null, Dictionary<string, object>? row = null, Dictionary<string, string>? order = null)
|
|
|
|
|
public HDP_Page<T> QueryPage<T>(HDP_Source source, HDP_Table table, int pageIndex, int pageSize, Dictionary<string, string>? where,
|
|
|
|
|
Dictionary<string, object>? row, Dictionary<string, string>? order, string[]? col)
|
|
|
|
|
{
|
|
|
|
|
//数据校验
|
|
|
|
|
if (string.IsNullOrEmpty(table.Key))
|
|
|
|
@ -661,7 +709,16 @@ namespace ZKLT.Hadoop
|
|
|
|
|
//查询命令
|
|
|
|
|
StringBuilder _command = new StringBuilder();
|
|
|
|
|
Dictionary<string, object> _params = new Dictionary<string, object>();
|
|
|
|
|
_command.AppendLine(@$"SELECT * FROM `{table.Key}`");
|
|
|
|
|
if (col == null || col.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
_command.AppendLine(@$"SELECT * FROM `{table.Key}`");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_command.AppendLine("SELECT");
|
|
|
|
|
MergeCols(table, col, _command);
|
|
|
|
|
_command.AppendLine($@"FROM `{table.Key}`");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//执行条件
|
|
|
|
|
MergeWhere(table, where, row, _command, _params);
|
|
|
|
|