Skip to content

Commit cebdddf

Browse files
committed
更新 APIAuto
1 parent 06b5298 commit cebdddf

File tree

5 files changed

+707
-214
lines changed

5 files changed

+707
-214
lines changed

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

+29
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,35 @@ var CodeUtil = {
288288
},
289289

290290

291+
getOperation: function (method, json) {
292+
var method = StringUtil.toLowerCase(method)
293+
if (method.startsWith('insert') || method.startsWith('post') || method.startsWith('add')
294+
|| method.startsWith('pub') || method.startsWith('write')) {
295+
return 'INSERT'
296+
}
297+
if (method.startsWith('update') || method.startsWith('edit') || method.startsWith('put')
298+
|| method.startsWith('patch') || method.startsWith('mutate') || method.startsWith('mod')) { // modify
299+
return 'UPDATE'
300+
}
301+
if (method.startsWith('del') || method.startsWith('remove') || method.startsWith('rmv')
302+
|| method.startsWith('clear') || method.startsWith('clean') || method.startsWith('release')) {
303+
return 'DELETE'
304+
}
305+
if (method.startsWith('get') || method.startsWith('find') || method.startsWith('query') || method.startsWith('list')
306+
|| method.startsWith('search') || method.startsWith('select') || method.startsWith('read')
307+
|| method.startsWith('retrieve') || method.startsWith('fetch')) {
308+
return 'SELECT'
309+
}
310+
if (JSONResponse.getType(json) == 'object') {
311+
for (var key in json) {
312+
var k = key == null ? '' : key.replaceAll('_', '').toLowerCase()
313+
if (k.startsWith('page') || json.size != null || json.orderby != null) {
314+
return 'SELECT'
315+
}
316+
}
317+
}
318+
return null // 'SELECT'
319+
},
291320

292321
/**生成封装 Unity3D-C# 请求 JSON 的代码
293322
* 只需要把所有 对象标识{} 改为数组标识 []

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

+25-14
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ function log(msg) {
6666
var JSONResponse = {
6767
TAG: 'JSONResponse',
6868

69+
KEY_CODE: 'code',
70+
KEY_MSG: 'msg',
71+
CODE_SUCCESS: 200,
72+
6973
/**是否成功
7074
* @param code
7175
* @return
@@ -75,14 +79,11 @@ var JSONResponse = {
7579
return false
7680
}
7781

78-
if (typeof obj == 'number') {
79-
return obj == CODE_SUCCESS;
80-
}
81-
if (obj instanceof Object && obj instanceof Array == false) {
82-
return obj.code == CODE_SUCCESS;
82+
if (obj instanceof Array == false && obj instanceof Object) {
83+
return obj[JSONResponse.KEY_CODE] == JSONResponse.CODE_SUCCESS;
8384
}
8485

85-
return false
86+
return obj == JSONResponse.CODE_SUCCESS
8687
},
8788

8889
/**校验服务端是否存在table
@@ -362,8 +363,18 @@ var JSONResponse = {
362363
3-对象缺少字段/整数变小数,黄色;
363364
4-code/值类型 改变,红色;
364365
*/
365-
compareResponse: function(target, real, folder, isMachineLearning, codeName, exceptKeys, ignoreTrend) {
366-
codeName = StringUtil.isEmpty(codeName, true) ? 'code' : codeName;
366+
compareResponse: function(res, target, real, folder, isMachineLearning, codeName, exceptKeys, ignoreTrend) {
367+
var tStatus = (target || {}).status || 200;
368+
var rStatus = (res || {}).status;
369+
if (rStatus != null && rStatus != tStatus) {
370+
return {
371+
code: JSONResponse.COMPARE_CODE_CHANGE,
372+
msg: 'HTTP Status Code 改变!' + tStatus + ' -> ' + rStatus,
373+
path: ''
374+
}
375+
}
376+
377+
codeName = StringUtil.isEmpty(codeName, true) ? JSONResponse.KEY_CODE : codeName;
367378
var tCode = (target || {})[codeName];
368379
var rCode = (real || {})[codeName];
369380

@@ -380,15 +391,15 @@ var JSONResponse = {
380391
if (typeof rCode == 'number' && (rCode%10 != 0 || (rCode >= 400 && rCode < 600))) {
381392
return {
382393
code: JSONResponse.COMPARE_CODE_CHANGE, //未上传对比标准
383-
msg: '没有校验标准,且状态码在 [400, 599] 内或不是 0, 200 等以 0 结尾的数',
394+
msg: '没有校验标准,且状态码 ' + rCode + ' 在 [400, 599] 内或不是 0, 200 等以 0 结尾的数',
384395
path: folder == null ? '' : folder
385396
};
386397
}
387398

388399
if (real != null && real.throw != null) {
389400
return {
390401
code: JSONResponse.COMPARE_CODE_CHANGE, //未上传对比标准
391-
msg: '没有校验标准,且 throw 不是 null',
402+
msg: '没有校验标准,且 throw 不是 null,而是 ' + real.throw,
392403
path: folder == null ? '' : folder
393404
};
394405
}
@@ -426,18 +437,18 @@ var JSONResponse = {
426437
if (find != null) {
427438
return {
428439
code: JSONResponse.COMPARE_EQUAL_EXCEPTION,
429-
msg: '符合异常分支 ' + codeName + ':' + rCode + (StringUtil.isEmpty(rThrw) ? '' : ', throw:' + rThrw) + ', msg:' + StringUtil.trim(find.msg),
440+
msg: '符合异常分支 ' + rCode + (StringUtil.isEmpty(rThrw) ? '' : ' ' + rThrw + ':') + ' ' + StringUtil.trim(find.msg),
430441
path: folder == null ? '' : folder
431442
};
432443
}
433444

434445
return rCode != tCode ? {
435446
code: JSONResponse.COMPARE_CODE_CHANGE,
436-
msg: '状态码 ' + codeName + ' 改变!',
447+
msg: '状态码 ' + codeName + ' 改变!' + tCode + ' -> ' + rCode,
437448
path: folder == null ? '' : folder
438449
} : {
439450
code: JSONResponse.COMPARE_THROW_CHANGE,
440-
msg: '异常 throw 改变!',
451+
msg: '异常 throw 改变!' + tThrw + ' -> ' + rThrw,
441452
path: folder == null ? '' : folder
442453
};
443454
}
@@ -516,7 +527,7 @@ var JSONResponse = {
516527
if (type != "integer" || realType != "number") {
517528
return {
518529
code: JSONResponse.COMPARE_TYPE_CHANGE,
519-
msg: '值类型改变',
530+
msg: '值类型改变!' + type + " -> " + realType,
520531
path: folder,
521532
value: real
522533
};

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
<!--<use xlink:href="svg/icon.svg#share"></use>-->
155155
<!--</svg>-->
156156

157-
<a style="display: flex;flex-grow: 1;font-size: medium;color: black" class="hint--top save-tool" data-hint="点击切换" href="javascript:void(0)" @click="showTestCase(true, ! isLocalShow)">测试用例:{{ (isLocalShow ? '本地历史(' : '远程共享(') + (testCases == null ? 0 : testCases.length) + ')' }}</a>
157+
<a style="display: flex;flex-grow: 1;font-size: medium;color: black" class="hint--top save-tool" data-hint="点击切换" href="javascript:void(0)" @click="showTestCase(true, ! isLocalShow)">测试用例:{{ (isLocalShow ? '本地历史(' : '远程在线(') + (testCases == null ? 0 : testCases.length) + ')' }}</a>
158158

159159
<a v-show="! isLocalShow" class="hint--top save-tool" data-hint="点击切换" href="javascript:void(0)" @click="enableCross(! isCrossEnabled)">{{ crossProcess }}</a>
160160
<a v-show="! isLocalShow" class="hint--top save-tool" data-hint="点击切换" href="javascript:void(0)" @click="enableML(! isMLEnabled)">{{ testProcess }}</a>
@@ -186,11 +186,11 @@
186186
<ul v-show="isTestCaseShow" class="historys" style="width: 100%;height: 100%;overflow: hidden;overflow-y: scroll;padding-bottom: 50px">
187187
<li v-for="(item, index) in testCases" :id="'docItem' + index" >
188188
<div style="display: inline-table">
189-
<button v-show="isShowMethod()" style="width: 60px; margin-right: 0px;padding: 0px;" id="vDocMethod" @click="restoreRemoteAndTest(index, item)">{{ getMethodName(item.Document.method, item.Document.type) }}</button>
190-
<button v-show="isShowType()" style="width: 48px;margin-right: 6px;padding: 0px" id="vDocType" @click="restoreRemoteAndTest(index, item)">{{ getTypeName(item.Document.type, item.Document.method) }}</button>
189+
<button class="hint--right" :data-hint="item.Document.url" v-show="isShowMethod()" style="width: 60px; margin-right: 0px;padding: 0px;" id="vDocMethod" @click="restoreRemoteAndTest(index, item)">{{ getMethodName(item.Document.method, item.Document.type) }}</button>
190+
<button class="hint--right" :data-hint="item.Document.request" v-show="isShowType()" style="width: 48px;margin-right: 6px;padding: 0px" id="vDocType" @click="restoreRemoteAndTest(index, item)">{{ getTypeName(item.Document.type, item.Document.method) }}</button>
191191
<a class="hint--rounded hint--no-animate" ref="testCaseTexts" @mouseover="setRequestHint(index, item)" href="javascript:void(0)" @click="restoreRemote(index, item)" :style="{ color: index == currentDocIndex ? 'black' : 'gray' }"> {{(item.Document.version > 0 ? 'V' + item.Document.version : 'V*') + ' ' + item.Document.name + ' ' + item.Document.url}}</a>
192192
<div style="position: absolute; right: 36px; top: 8px; display: inline-flex">
193-
<div v-show="(item.totalCount || 0) > 0" style="background: lightgray; padding: 1px; margin-right: 2px; display: inline-block; position: relative" @click="restoreRemote(index, item)" >
193+
<div v-show="(item.totalCount || 0) > 0" style="background: lightgray; padding: 1px; margin-right: 2px; display: inline-block; position: relative" @click="restoreRemote(index, item, null, true)" >
194194
<!-- 只能写成一行来消除间隙,不能换行、空格 -->
195195
<a style="background: transparent; color: black; position: relative; min-width: 6px; width: auto; height: 100%; margin: 0; padding: 2px">{{ (item.totalCount || 0) + ':' }}</a><a style="background: white; color: black; position: relative; min-width: 6px; width: auto; height: 100%; margin: 0; padding: 2px">{{ item.whiteCount || 0 }}</a><a style="background: green; color: white; position: relative; min-width: 6px; width: auto; height: 100%; margin: 0; padding: 2px">{{ item.greenCount || 0 }}</a><a style="background: blue; color: white; position: relative; min-width: 6px; width: auto; height: 100%; margin: 0; padding: 2px">{{ item.blueCount || 0 }}</a><a style="background: orange; color: white; position: relative; min-width: 6px; width: auto; height: 100%; margin: 0; padding: 2px">{{ item.orangeCount || 0 }}</a><a style="background: red; color: white; position: relative; min-width: 6px; width: auto; height: 100%; margin: 0; padding: 2px">{{ item.redCount || 0 }}</a>
196196
</div>
@@ -346,7 +346,7 @@
346346
<img class="icon" src="img/refresh.png"/>
347347
</a>
348348
<a class="hint--top @cli-tool" data-hint="添加配置" style="font-size:xx-large; margin-bottom: 2px; color: black;"
349-
href="javascript:void(0)" @click="if(isRandomListShow || isRandomSubListShow) { randomTestTitle = null; isRandomListShow = false; isRandomSubListShow = false; } else { showExport(true, true, true) }"> + </a>
349+
href="javascript:void(0)" @click="onClickAddRandom()"> + </a>
350350
<a v-show="false" href="javascript:void(0)" style="font-size: small;" class="hint--top" data-hint="上传/分享" @click="showExport(true, true)">
351351
<svg class="icon">
352352
<use xlink:href="svg/icon.svg#share"></use>
@@ -599,7 +599,7 @@
599599
<button style="background-color: #DDD;margin: 0px;outline: none;border: #DDD 1px solid;" href="javascript:void(0)" @click="addAccountTab()"> + </button>
600600
<!-- 全部账号 -->
601601
<div v-show="isCrossEnabled && isAllSummaryShow()" style="display: inline-block; border: #DDD 1px solid" :style="{backgroundColor: currentAccountIndex == accounts.length ? 'transparent' : '#DDD'}">
602-
<button style="outline: none; border: none" :style="{backgroundColor: currentAccountIndex == accounts.length ? 'transparent' : '#DDD', color: currentAccountIndex == accounts.length ? 'black' : 'black'}" >全部账号</button>
602+
<button style="outline: none; border: none" :style="{backgroundColor: currentAccountIndex == accounts.length ? 'transparent' : '#DDD', color: currentAccountIndex == accounts.length ? 'black' : 'black'}" >全部总计</button>
603603
<br />
604604
<div style="background: lightgray; padding: 1px; display: inline-block; margin: 1px" >
605605
<!-- 只能写成一行来消除间隙,不能换行、空格 -->
@@ -678,13 +678,13 @@
678678

679679
<!--格式化错误视图-->
680680
<div class="view-error" v-show="view == 'error'">
681-
<pre v-cloak>{{error.msg}}</pre>
681+
<pre style="overflow: auto; overflow-y: auto" v-cloak>{{error.msg}}</pre>
682682
</div>
683683

684684
<!--diff视图-->
685-
<!-- <div id="diffoutput" v-show="baseview == 'diff' && view != 'error'">
685+
<div id="diffoutput" v-show="baseview == 'diff' && view != 'error'">
686686

687-
</div> -->
687+
</div>
688688

689689
</div>
690690
</div>

0 commit comments

Comments
 (0)