Skip to content

Commit 42db861

Browse files
committed
处理别名如果为关键字的缺陷
1 parent f64c5bc commit 42db861

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

APIJSON.NET/APIJSON.NET/appsettings.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ConnectionStrings": {
33
"DbType": 0, //0:MySql,1:SqlServer,2:Sqlite
4-
"ConnectionString": "Server=192.168.2.25;Database=yunwei;Uid=root;Pwd=xmjk;Port=3306;Character Set=utf8;"
4+
"ConnectionString": "Server=192.168.2.25;Database=yunwei1.8;Uid=root;Pwd=xmjk;Port=3306;Character Set=utf8;"
55
//"ConnectionString": "Server=119.29.9.25;Port=3306;Database=test;Uid=root;Pwd=1q,2w.3e?;CharSet=UTF8;"
66
},
77
"Authentication": {
@@ -16,8 +16,8 @@
1616
{
1717
"name": "role1", //权限名称 唯一
1818
"select": { //查询权限
19-
"table": [ "moment", "User", "Comment" ], //可操作的表
20-
"column": [ "*", "*", "*" ], //可操作的字段
19+
"table": [ "*" ], //可操作的表
20+
"column": [ "*" ], //可操作的字段
2121
"where": []
2222
},
2323
"update": { //修改权限

APIJSON.NET/APIJSON.NET/wwwroot/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<option value="add">add</option>
3636
<option value="edit">edit</option>
3737
<option value="remove">remove</option>
38-
<!--<option value="org">org</option>-->
38+
<option value="org">org</option>
3939

4040
</select>
4141
<button @click="hpost()">发送请求</button>

APIJSON.NET/APIJSON.NET/wwwroot/js/main.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,11 @@
142142
},
143143
methods: {
144144
hpost: function () {
145-
146145
$.ajax({
147146
url: $('#rest-url').val(),
148147
type: "POST", dataType: "json",
149148
contentType: "application/json;charset=utf-8",
150-
data: $('#vInput').val(),
149+
data: $('#vInput').val(),//JSON.stringify($('#vInput').val()),
151150
success: function (data) {
152151

153152
App.jsonhtml = data;

APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<Version>0.0.8</Version>
6-
<Description>0.0.8 清理SelectTable 支持重载
5+
<Version>0.0.10</Version>
6+
<Description>0.0.10 处理别名如果为关键字的缺陷
7+
0.0.8 清理SelectTable 支持重载
78
0.0.7 修复not in的缺陷,增加~ 不等于的支持
89
0.0.6 增加ToSql接口,处理sql注入的情况
910
通用查询组件</Description>

APIJSON.NET/APIJSONCommon/Properties/AssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// 控制。更改这些特性值可修改
66
// 与程序集关联的信息。
77
[assembly: AssemblyTitle("ApiJson.Common")]
8-
[assembly: AssemblyDescription("修复not in的缺陷,增加~ 不等于的支持")]
8+
[assembly: AssemblyDescription("0.0.19 处理别名如果为关键字的缺陷")]
99
[assembly: AssemblyConfiguration("")]
1010
[assembly: AssemblyCompany("")]
1111
[assembly: AssemblyProduct("ApiJson.Common")]
@@ -31,5 +31,5 @@
3131
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
3232
//通过使用 "*",如下所示:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("0.0.7.0")]
35-
[assembly: AssemblyFileVersion("0.0.7.0")]
34+
[assembly: AssemblyVersion("0.0.10.0")]
35+
[assembly: AssemblyFileVersion("0.0.10.0")]

APIJSON.NET/APIJSONCommon/SelectTable.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,10 @@ private ISugarQueryable<ExpandoObject> sugarQueryable(string subtable, string se
456456
{
457457
string vakey = va.Key.Trim();
458458
string fieldValue = va.Value.ToString();
459-
459+
if (vakey.StartsWith("@"))
460+
{
461+
continue;
462+
}
460463
if (vakey.EndsWith("$"))//模糊查询
461464
{
462465
FuzzyQuery(subtable, conModels, va);
@@ -531,10 +534,10 @@ private void ProcessColumn(string subtable, string selectrole, JObject values, I
531534
{
532535
throw new Exception("别名不能超过20个字符");
533536
}
534-
str.Append(ziduan[0] + " as " + ReplaceSQLChar(ziduan[1]) + ",");
537+
str.Append(ziduan[0] + " as `" + ReplaceSQLChar(ziduan[1]) + "`,");
535538
}
536539
else
537-
str.Append(ziduan[0] + ",");
540+
str.Append("`" + ziduan[0] + "`" + ",");
538541

539542
}
540543
}

0 commit comments

Comments
 (0)