chengjie 6 months ago
parent
commit
43c292b181
1 changed files with 7 additions and 3 deletions
  1. 7 3
      src/api/web/webController.js

+ 7 - 3
src/api/web/webController.js

@@ -42,15 +42,19 @@ export async function GetKylx365TableColumnByTable(ctx) {
42
 export async function RunKylx365DBSql(ctx) {
42
 export async function RunKylx365DBSql(ctx) {
43
     let param = {
43
     let param = {
44
         SQL: ctx.request.body.sql || "",
44
         SQL: ctx.request.body.sql || "",
45
+        IsCompleteField:ctx.request.body.IsCompleteField || false,
45
     };
46
     };
47
+    console.log(param.SQL);
48
+    // 获取第一个分号前的SQL语句
49
+    const firstStatement = param.SQL.split(';')[0].trim();
46
     
50
     
47
     // 只允许执行SELECT查询
51
     // 只允许执行SELECT查询
48
-    if (!param.SQL.trim().toUpperCase().startsWith('SELECT')) {
52
+    if (!firstStatement.toUpperCase().startsWith('SELECT')) {
49
         ctx.body = {"errcode": 10001, errmsg: "只允许执行SELECT查询语句"};
53
         ctx.body = {"errcode": 10001, errmsg: "只允许执行SELECT查询语句"};
50
         return;
54
         return;
51
     }
55
     }
52
 
56
 
53
-    let result = await commonModel.RunSql(null, param.SQL);
57
+    let result = await commonModel.RunSql(null, firstStatement);
54
     console.log("记录数:" + result.length);
58
     console.log("记录数:" + result.length);
55
     
59
     
56
     // 处理查询结果
60
     // 处理查询结果
@@ -66,7 +70,7 @@ export async function RunKylx365DBSql(ctx) {
66
                     processedItem[key] = moment(value).format('YYYY-MM-DD HH:mm:ss');
70
                     processedItem[key] = moment(value).format('YYYY-MM-DD HH:mm:ss');
67
                 }
71
                 }
68
                 // 处理长文本字段
72
                 // 处理长文本字段
69
-                else if (typeof value === 'string' && value.length > 100) {
73
+                else if (!param.IsCompleteField && typeof value === 'string' && value.length > 100) {
70
                     processedItem[key] = value.substring(0, 100) + '...';
74
                     processedItem[key] = value.substring(0, 100) + '...';
71
                 } else {
75
                 } else {
72
                     processedItem[key] = value;
76
                     processedItem[key] = value;