Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1503220

Browse files
committed
优化本地保存和共享的默认名;优化query和join的自动生成请求代码
1 parent b3151d0 commit 1503220

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

apijson/CodeUtil.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ var CodeUtil = {
179179

180180
const count = isSmart ? (value.count || 0) : 0;
181181
const page = isSmart ? (value.page || 0) : 0;
182-
const query = isSmart ? (value.query || 0) : 0;
182+
const query = isSmart ? value.query : null;
183183
const join = isSmart ? value.join : null;
184184

185185
log(CodeUtil.TAG, 'parseJava for count = ' + count + '; page = ' + page);
@@ -199,12 +199,18 @@ var CodeUtil = {
199199

200200
if (isSmart) {
201201
var prefix = key.substring(0, key.length - 2);
202-
s += '\n\n'
203-
+ name + '.setQuery(' + CodeUtil.QUERY_TYPE_CONSTS[query] + ');\n'
204-
+ name + '.setJoin("' + join + '");\n'
205-
+ parentKey + '.putAll(' + name + '.toArray('
202+
203+
if (query != null) {
204+
s += '\n\n'
205+
+ name + '.setQuery(' + (CodeUtil.QUERY_TYPE_CONSTS[query] || CodeUtil.QUERY_TYPE_CONSTS[0]) + ');\n';
206+
}
207+
if (StringUtil.isEmpty(join, true) == false) {
208+
s += name + '.setJoin("' + join + '");\n';
209+
}
210+
s += parentKey + '.putAll(' + name + '.toArray('
206211
+ count + ', ' + page + (prefix.length <= 0 ? '' : ', "' + prefix + '"') + '));';
207-
} else {
212+
}
213+
else {
208214
s += '\n\n' + parentKey + '.put("' + key + '", ' + name + ');';
209215
}
210216

js/main.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,16 @@
291291
url = index <= 0 ? url : url.substring(index)
292292
return url.startsWith('/') ? url.substring(1) : url
293293
},
294+
//获取请求的tag
295+
getTag: function () {
296+
var req = null
297+
try {
298+
req = JSON.parse(new String(vInput.value))
299+
} catch (e) {
300+
log('main.getTag', 'try { req = JSON.parse(new String(vInput.value)) \n } catch (e) {\n' + e.message)
301+
}
302+
return req == null ? null : req.tag
303+
},
294304

295305
// 显示保存弹窗
296306
showSave: function (show) {
@@ -300,7 +310,8 @@
300310
return
301311
}
302312

303-
App.history.name = '请求 ' + App.getMethod() + ' ' + App.formatTime() //不自定义名称的都是临时的,不需要时间太详细
313+
var tag = App.getTag()
314+
App.history.name = App.getMethod() + ' ' + (StringUtil.isEmpty(tag, true) ? 'Test' : tag) + ' ' + App.formatTime() //不自定义名称的都是临时的,不需要时间太详细
304315
}
305316
App.isSaveShow = show
306317
},
@@ -317,7 +328,8 @@
317328
alert('请先测试请求,确保是正确可用的!')
318329
return
319330
}
320-
App.exTxt.name = App.getMethod() + '请求'
331+
var tag = App.getTag()
332+
App.exTxt.name = App.getMethod() + ' ' + (StringUtil.isEmpty(tag, true) ? 'Test' : tag)
321333
}
322334
else { //下载到本地
323335
if (App.isRemoteShow) { //文档

0 commit comments

Comments
 (0)