From f0001de997e86d36b0e435f84cc612174972399c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=98=E5=BB=BA=E4=B8=9C?= <617601767@qq.com> Date: Thu, 14 Mar 2024 14:10:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0between?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hadoop/ZKLT.Hadoop.Model/HDP_WhereType.cs | 2 ++ Hadoop/ZKLT.Hadoop/TableService.cs | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Hadoop/ZKLT.Hadoop.Model/HDP_WhereType.cs b/Hadoop/ZKLT.Hadoop.Model/HDP_WhereType.cs index 481eca6..b39275b 100644 --- a/Hadoop/ZKLT.Hadoop.Model/HDP_WhereType.cs +++ b/Hadoop/ZKLT.Hadoop.Model/HDP_WhereType.cs @@ -23,5 +23,7 @@ namespace ZKLT.Hadoop.Model public const string LESSTHEN = "<="; public const string IN = "IN"; + + public const string BETWEEN = "BETWEEN"; } } diff --git a/Hadoop/ZKLT.Hadoop/TableService.cs b/Hadoop/ZKLT.Hadoop/TableService.cs index fee0a39..daf6ee9 100644 --- a/Hadoop/ZKLT.Hadoop/TableService.cs +++ b/Hadoop/ZKLT.Hadoop/TableService.cs @@ -10,6 +10,7 @@ using ZKLT.Hadoop.Interface; using ZKLT.Hadoop.Model; using MySqlX.XDevAPI.Relational; using Mysqlx.Crud; +using Newtonsoft.Json; namespace ZKLT.Hadoop { @@ -39,12 +40,30 @@ namespace ZKLT.Hadoop { case HDP_WhereType.LIKE: _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} CONCAT('%',@{_column.Key!},'%')"); + param.Add(_column.Key!, row![_column.Key!]); + break; + case HDP_WhereType.BETWEEN: + if (row![_column.Key!] != null) { + var _betweendata = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(row![_column.Key!])); + if (_betweendata != null) { + if (_betweendata[0] != null) + { + _wherestr.Append($@" AND `{_column.Key!}` >= @{_column.Key!}0"); + param.Add(_column.Key! + "0", _betweendata[0]); + } + if (_betweendata[1] != null) + { + _wherestr.Append($@" AND `{_column.Key!}` <= @{_column.Key!}1"); + param.Add(_column.Key! + "1", _betweendata[1]); + } + } + } break; default: _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} @{_column.Key!}"); + param.Add(_column.Key!, row![_column.Key!]); break; } - param.Add(_column.Key!, row![_column.Key!]); } } command.AppendLine(_wherestr.ToString());