From b8b2f979d2e94e62692a15cb73e688462a648c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=98=E5=BB=BA=E4=B8=9C?= <617601767@qq.com> Date: Tue, 19 Mar 2024 15:17:10 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8Dupdate=E4=B8=ADIN?= =?UTF-8?q?=E7=9A=84=E6=95=85=E9=9A=9C=202=E3=80=81=E4=BF=AE=E5=A4=8Dwhere?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E4=B8=ADLike=E6=97=A0=E6=B3=95=E6=A8=A1?= =?UTF-8?q?=E7=B3=8A=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hadoop/ZKLT.Hadoop.API/Program.cs | 28 ++++++++++++++-------------- Hadoop/ZKLT.Hadoop/TableService.cs | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Hadoop/ZKLT.Hadoop.API/Program.cs b/Hadoop/ZKLT.Hadoop.API/Program.cs index 38f3a30..3e2187e 100644 --- a/Hadoop/ZKLT.Hadoop.API/Program.cs +++ b/Hadoop/ZKLT.Hadoop.API/Program.cs @@ -40,34 +40,34 @@ namespace ZKLT.Hadoop.API app.UseCors("all"); #endregion - app.UseHadoop((c) => - { - c.Host = "127.0.0.1"; - c.Account = "root"; - c.PassWord = "root"; - c.Key = "hadoopdb"; - c.Port = 3306; - }); - - //app.UseHadoop((c) => //{ - // c.Host = "172.17.0.1"; + // c.Host = "127.0.0.1"; // c.Account = "root"; // c.PassWord = "root"; - // c.Key = "testdb"; - // c.Port = 4000; + // c.Key = "hadoopdb"; + // c.Port = 3306; //}); + //app.UseHadoop((c) => //{ - // c.Host = "118.195.165.218"; + // c.Host = "172.17.0.1"; // c.Account = "root"; // c.PassWord = "root"; // c.Key = "testdb"; // c.Port = 4000; //}); + app.UseHadoop((c) => + { + c.Host = "118.195.165.218"; + c.Account = "root"; + c.PassWord = "root"; + c.Key = "testdb"; + c.Port = 4000; + }); + // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { diff --git a/Hadoop/ZKLT.Hadoop/TableService.cs b/Hadoop/ZKLT.Hadoop/TableService.cs index f6d4f98..c63230d 100644 --- a/Hadoop/ZKLT.Hadoop/TableService.cs +++ b/Hadoop/ZKLT.Hadoop/TableService.cs @@ -72,6 +72,10 @@ namespace ZKLT.Hadoop { param.Add(_guid, _data[_item.Name]!); } + else if (_item.Value.ToString() == HDP_WhereType.LIKE) + { + param.Add(_guid,$@"%{((JValue)_data[_item.Name]!).Value!}%" ); + } else { param.Add(_guid, ((JValue)_data[_item.Name]!).Value!); } @@ -525,6 +529,15 @@ namespace ZKLT.Hadoop { throw new ArgumentNullException("条件无效"); } + List _where = new List(); + if (where.Type == JTokenType.Object) + { + _where.Add((JObject)where); + } + else if (where.Type == JTokenType.Array) + { + _where.AddRange(((JArray)where).ToObject()!); + } if (data == null || data.Count == 0) { throw new ArgumentNullException("数据无效"); @@ -564,7 +577,7 @@ namespace ZKLT.Hadoop for (var i = 0; i < table.Columns.Length; i++) { var _column = table.Columns[i]; - if (_row.ContainsKey(_column.Key!)) + if (_row.ContainsKey(_column.Key!) && !_where.Any(x => x.ContainsKey(_column.Key!))) { _colstr.Append($@"`{_column.Key!}`=@{_column.Key!},"); _params.Add(_column.Key!, ((JValue)_row[_column.Key!]!).Value!);