From 8af04193fc9148db621f9c7fbcbd528796f3bf1a Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 21 Jun 2022 13:18:29 +0800 Subject: [PATCH] Update json 2 sql --- .../SqlSugar/Abstract/SaveableProvider/Storageable.cs | 4 +++- .../SqlSugar/Json2Sql/JsonToModel/JsonSqlFuncToParameters.cs | 2 +- .../SqlSugar/Json2Sql/JsonToModel/JsonToGroupByModels.cs | 2 +- .../SqlSugar/Json2Sql/JsonToModel/JsonToJoinModels.cs | 4 ++-- .../SqlSugar/Json2Sql/JsonToModel/JsonToOrderByModels.cs | 2 +- .../SqlSugar/Json2Sql/JsonToModel/JsonToSelectModels.cs | 2 +- .../Json2Sql/Provider/Deleteable/JsonDeleteableProvider.cs | 2 +- .../SqlSugar/Json2Sql/Provider/Insertable/AppendName.cs | 2 +- .../SqlSugar/Json2Sql/Provider/Queryable/AppendFrom.cs | 1 + .../SqlSugar/Json2Sql/Provider/Queryable/AppendPage.cs | 2 +- .../SqlSugar/Json2Sql/Provider/Updateable/AppendTable.cs | 2 +- 11 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs index 47d8b7eff..2a33f1bd5 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs @@ -73,7 +73,9 @@ namespace SqlSugar var result = 0; var x = this.ToStorage(); result+=x.AsInsertable.ExecuteCommand(); - result += x.AsUpdateable.ExecuteCommand(); + var updateRow = x.AsUpdateable.ExecuteCommand(); + if (updateRow < 0) updateRow = 0; + result += updateRow; return result; } public async Task ExecuteCommandAsync() diff --git a/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonSqlFuncToParameters.cs b/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonSqlFuncToParameters.cs index 6186f689c..6ebeb7880 100644 --- a/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonSqlFuncToParameters.cs +++ b/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonSqlFuncToParameters.cs @@ -57,7 +57,7 @@ namespace SqlSugar public object GetStringParameters(JToken parameters) { - return parameters.ObjToString(); + return parameters.ObjToString().ToCheckField(); } #endregion diff --git a/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToGroupByModels.cs b/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToGroupByModels.cs index 4f0ccbbe8..b09817eb7 100644 --- a/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToGroupByModels.cs +++ b/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToGroupByModels.cs @@ -22,7 +22,7 @@ namespace SqlSugar } else { - conditionalModels.Add(new GroupByModel() { FieldName = item.ObjToString() }); + conditionalModels.Add(new GroupByModel() { FieldName = item.ObjToString().ToCheckField() }); } } return conditionalModels; diff --git a/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToJoinModels.cs b/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToJoinModels.cs index 7ebb17e1f..705c10a44 100644 --- a/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToJoinModels.cs +++ b/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToJoinModels.cs @@ -22,8 +22,8 @@ namespace SqlSugar var shortName = array[1]; var onWhere = array[2]; JoinModel result = new JoinModel(); - result.TableName = tableName.ObjToString(); - result.ShortName = shortName.ObjToString(); + result.TableName = tableName.ObjToString().ToCheckField(); + result.ShortName = shortName.ObjToString().ToCheckField(); result.OnWhereList = JsonToSqlFuncModels(onWhere); return result; } diff --git a/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToOrderByModels.cs b/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToOrderByModels.cs index d25f3f927..5eeed2ea3 100644 --- a/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToOrderByModels.cs +++ b/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToOrderByModels.cs @@ -22,7 +22,7 @@ namespace SqlSugar } else if (item.Type == JTokenType.String) { - conditionalModels.Add(new OrderByModel() { FieldName = item.ObjToString() }); + conditionalModels.Add(new OrderByModel() { FieldName = item.ObjToString().ToCheckField() }); } else if (item.Type == JTokenType.Array) { diff --git a/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToSelectModels.cs b/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToSelectModels.cs index b8a78db4e..fbd74147b 100644 --- a/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToSelectModels.cs +++ b/Src/Asp.NetCore2/SqlSugar/Json2Sql/JsonToModel/JsonToSelectModels.cs @@ -22,7 +22,7 @@ namespace SqlSugar } else if (IsString(item)) { - conditionalModels.Add(new SelectModel() { FiledName = item.ObjToString(), AsName = item.ObjToString().Replace(".", "_") }); + conditionalModels.Add(new SelectModel() { FiledName = item.ObjToString().ToCheckField(), AsName = item.ObjToString().Replace(".", "_") }); } else if (IsArraySingleItem(item)) { diff --git a/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Deleteable/JsonDeleteableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Deleteable/JsonDeleteableProvider.cs index ba074e47c..cc30018ea 100644 --- a/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Deleteable/JsonDeleteableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Deleteable/JsonDeleteableProvider.cs @@ -50,7 +50,7 @@ namespace SqlSugar private void AppendTable(JToken item) { var tableInfo = jsonCommonProvider.GetTableName(item); - var tableName = tableInfo.TableName; + var tableName = tableInfo.TableName.ToCheckField(); if (tableInfo.ShortName.HasValue()) { tableName = tableInfo.ShortName + "." + tableInfo.TableName; diff --git a/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Insertable/AppendName.cs b/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Insertable/AppendName.cs index 4e94e2bc9..a765fad78 100644 --- a/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Insertable/AppendName.cs +++ b/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Insertable/AppendName.cs @@ -10,7 +10,7 @@ namespace SqlSugar private void AppendName(JToken item) { var tableInfo = jsonCommonProvider.GetTableName(item); - this.TableName = tableInfo.TableName; + this.TableName = tableInfo.TableName.ToCheckField(); if (tableInfo.ShortName.HasValue()) { this.TableName = tableInfo.ShortName + "." + tableInfo.TableName; diff --git a/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Queryable/AppendFrom.cs b/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Queryable/AppendFrom.cs index b42984391..9a0e4fdf4 100644 --- a/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Queryable/AppendFrom.cs +++ b/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Queryable/AppendFrom.cs @@ -15,6 +15,7 @@ namespace SqlSugar private void AppendFrom(JToken item) { var tableNameInfo=jsonCommonProvider.GetTableName(item); + tableNameInfo.TableName.ToCheckField(); AddMasterTableInfos(tableNameInfo); if (tableNameInfo.ShortName.HasValue()) { diff --git a/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Queryable/AppendPage.cs b/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Queryable/AppendPage.cs index fa77d524c..fc9740fda 100644 --- a/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Queryable/AppendPage.cs +++ b/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Queryable/AppendPage.cs @@ -17,7 +17,7 @@ namespace SqlSugar private int AppendPageNumber(JToken item) { - var result= Convert.ToInt32(item.First().ToString().ObjToInt()); + var result = Convert.ToInt32(item.First().ToString().ObjToInt()); if (result == 0) { result = 1; diff --git a/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Updateable/AppendTable.cs b/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Updateable/AppendTable.cs index b4ee58609..d8f13be0d 100644 --- a/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Updateable/AppendTable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Json2Sql/Provider/Updateable/AppendTable.cs @@ -11,7 +11,7 @@ namespace SqlSugar private void AppendTable(JToken item) { var tableInfo = jsonCommonProvider.GetTableName(item); - this.TableName = tableInfo.TableName; + this.TableName = tableInfo.TableName.ToCheckField(); if (tableInfo.ShortName.HasValue()) { this.TableName = tableInfo.ShortName + "." + tableInfo.TableName;