Skip to content

Commit deb16c1

Browse files
committed
Java:MultiDataSource 同步 APIAuto 代码
1 parent 03259d7 commit deb16c1

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/apijson/CodeUtil.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,25 @@ var CodeUtil = {
115115
}
116116
};
117117

118-
var cc = isRestful == true ? '//' : ' //'; // 对 APIJSON API 要求严格些,因为本来就有字段注释
119-
var ccLen = cc.length;
118+
// var cc = isRestful == true ? '//' : ' //'; // 对 APIJSON API 要求严格些,因为本来就有字段注释
119+
// var ccLen = cc.length;
120120

121121
for (var i = 0; i < lines.length; i ++) {
122122
var line = lines[i].trim() || '';
123123

124124
//每一种都要提取:左边的key
125-
var index = line.indexOf(': '); //可能是 ' 或 ",所以不好用 ': , ": 判断
125+
var index = line.indexOf(':'); //可能是 ' 或 ",所以不好用 ': , ": 判断
126126
var key = index < 0 ? (depth <= 1 && startName != null ? startName : '') : line.substring(1, index - 1);
127-
var cIndex = line.lastIndexOf(cc);
127+
var cIndex = line.lastIndexOf(' //');
128+
var ccLen = cIndex < 0 ? 2 : 3;
129+
if (cIndex < 0) {
130+
cIndex = line.lastIndexOf('//');
131+
}
128132

129133
var comment = '';
130134
if (cIndex >= 0) {
131-
if (isExtract && standardObj != null && (depth != 1 || (key != 'code' && key != 'throw'))) {
135+
if (isExtract && standardObj != null && (depth != 1
136+
|| (isReq != true && [JSONResponse.KEY_CODE, JSONResponse.KEY_MSG, JSONResponse.KEY_THROW].indexOf(key) < 0))) {
132137
comment = line.substring(cIndex + ccLen).trim();
133138
// standardObj = CodeUtil.updateStandardPart(standardObj, names, key, value, comment)
134139
}

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/apijson/JSONResponse.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ var JSONResponse = {
6868

6969
KEY_CODE: 'code',
7070
KEY_MSG: 'msg',
71+
KEY_THROW: 'throw',
7172
CODE_SUCCESS: 200,
7273

7374
/**是否成功

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/js/main.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5477,7 +5477,7 @@ https://github.com/Tencent/APIJSON/issues
54775477
}
54785478
}
54795479

5480-
if (req != null) { // 支持 URL 里有 Path Variable,例如 http://apijson.cn:8080/{method}/{table}
5480+
if (req != null && JSONResponse.getType(req) == 'object') { // 支持 URL 里有 Path Variable,例如 http://apijson.cn:8080/{method}/{table}
54815481
var ind = url.indexOf('?')
54825482
var uri = ind < 0 ? url : url.substring(0, ind)
54835483

@@ -5644,6 +5644,7 @@ https://github.com/Tencent/APIJSON/issues
56445644
// eval(s)
56455645

56465646
var isTest = false;
5647+
var isInject = false;
56475648
var data = res == null ? null : res.data
56485649
var result = eval(code)
56495650
console.log = logger
@@ -7958,10 +7959,10 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
79587959
else {
79597960
if (show == true) {
79607961
vInput.value = JSON.stringify(constJson, null, ' ');
7961-
App.send(false, cb, caseScript, null, null, true);
7962+
App.send(false, cb, caseScript);
79627963
}
79637964
else {
7964-
App.request(false, method, type, url, constJson, header, cb, caseScript, null, null, true);
7965+
App.request(false, method, type, url, constJson, header, cb, caseScript);
79657966
}
79667967
}
79677968

@@ -8543,12 +8544,20 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
85438544

85448545
}
85458546

8547+
var isInject = true;
85468548
var isPre = false; // 避免执行副作用代码 true;
85478549
var isTest = false;
8550+
var method = null;
8551+
var type = null;
8552+
var url = null;
8553+
var req = null;
8554+
var header = null;
8555+
// var callback = null;
8556+
85488557
var res = {};
85498558
var data = res.data;
85508559
var err = null;
8551-
invoke(eval(StringUtil.trim(preScript) + '\n(' + toEval + ')'), which, p_k, pathKeys, key, lastKeyInPath);
8560+
invoke(eval(StringUtil.trim(preScript) + '\n;\n(' + toEval + ')'), which, p_k, pathKeys, key, lastKeyInPath);
85528561

85538562
// alert('> current = ' + JSON.stringify(current, null, ' '))
85548563
}

0 commit comments

Comments
 (0)