Skip to content

Commit 35be8b0

Browse files
committed
Java: MultiDataSource 更新内置 APIAuto
1 parent d826f6f commit 35be8b0

File tree

6 files changed

+1439
-291
lines changed

6 files changed

+1439
-291
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ https://github.com/TommyLemon/APIAuto/issues
260260
### 技术交流
261261
##### 关于作者
262262
[https://github.com/TommyLemon](https://github.com/TommyLemon)<br />
263-
<img width="1279" alt="image" src="https://user-images.githubusercontent.com/5738175/199979403-ace8b574-cd64-4582-8c19-b51571945214.png">
263+
<img width="1280" src="https://github.com/TommyLemon/UIGO/assets/5738175/ec77df98-ff9b-43aa-b2f1-2fce2549d276">
264264

265265
如果有什么问题或建议可以 [提 issue](https://github.com/TommyLemon/APIAuto/issues),交流技术,分享经验。<br >
266266
如果你解决了某些 bug,或者新增了一些功能,欢迎 [提 PR 贡献代码](https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md),感激不尽。
@@ -275,6 +275,8 @@ https://github.com/TommyLemon/APIAuto/issues
275275

276276
[SQLAuto](https://github.com/TommyLemon/SQLAuto) 智能零代码自动化测试 SQL 语句执行结果的数据库工具,任意增删改查、任意 SQL 模板变量、一键批量生成参数组合、快速构造大量测试数据
277277

278+
[UIGO](https://github.com/TommyLemon/UIGO) 📱 零代码快准稳 UI 智能录制回放平台 🚀 自动兼容任意宽高比分辨率屏幕,自动精准等待网络请求,录制回放快、准、稳!
279+
278280
[apijson-doc](https://github.com/vincentCheng/apijson-doc) APIJSON 官方文档,提供排版清晰、搜索方便的文档内容展示,包括设计规范、图文教程等
279281

280282
[APIJSONdocs](https://github.com/ruoranw/APIJSONdocs) APIJSON 英文文档,提供排版清晰的文档内容展示,包括详细介绍、设计规范、使用方式等
@@ -307,5 +309,11 @@ https://github.com/TommyLemon/APIAuto/commits/master
307309

308310

309311
### 我要赞赏
310-
创作不易,右上角点 ⭐Star 支持下本项目吧,谢谢 ^_^ <br />
312+
腾讯、中国邮政、字节跳动、阿里巴巴、美团、网易、百度、京东、滴滴、平安、SHEIN、快手、携程、Bilibili、微众银行、VIVO、 <br />
313+
58 集团、中兴 等 和国外 NVIDIA, Amazon, SAP, ThoughtWorks, Red Hat 等各大知名大厂员工点了 Star,感谢大家的支持~ <br />
314+
![image](https://github.com/TommyLemon/APIAuto/assets/5738175/723e1c9c-7cf7-431a-b29a-b878e99c7e39)
315+
316+
**创作不易、坚持更难,右上角点亮 ⭐Star 支持/收藏下本项目吧,谢谢 ^_^** <br />
311317
https://github.com/TommyLemon/APIAuto
318+
319+

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7007,7 +7007,7 @@ res_data = rep.json()
70077007
var verifyType = isSubquery != true && value != null;
70087008

70097009
if (onlyTableAndColumn) {
7010-
key = new String(columnName);
7010+
key = StringUtil.get(columnName);
70117011
}
70127012
else {
70137013
//功能符 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -7172,7 +7172,7 @@ res_data = rep.json()
71727172
}
71737173
else {
71747174
fun = '';
7175-
key = new String(columnName);
7175+
key = StringUtil.get(columnName);
71767176
}
71777177

71787178

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

Lines changed: 117 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -815,11 +815,11 @@ var JSONResponse = {
815815
var guess = target.guess;
816816
log('compareWithStandard guess = target.guess = ' + guess + ' >>');
817817

818-
var notnull = target.notnull;
819-
log('compareWithStandard notnull = target.notnull = ' + notnull + ' >>');
818+
var notNull = target.notNull;
819+
log('compareWithStandard notNull = target.notNull = ' + notNull + ' >>');
820820

821-
var notempty = target.notempty;
822-
log('compareWithStandard notempty = target.notempty = ' + notempty + ' >>');
821+
var notEmpty = target.notEmpty;
822+
log('compareWithStandard notEmpty = target.notEmpty = ' + notEmpty + ' >>');
823823

824824
var type = target.type;
825825
log('compareWithStandard type = target.type = ' + type + ' >>');
@@ -832,8 +832,8 @@ var JSONResponse = {
832832
var firstVal = values == null || values.length <= 0 ? null : values[0];
833833

834834
if (firstVal == null && (type == 'object' || type == 'array')) {
835-
if (notnull == true) { // values{} values&{}
836-
throw new Error('Standard 在 ' + folder + ' 语法错误,Object 或 Array 在 notnull: true 时 values 必须为有值的数组 !');
835+
if (notNull == true) { // values{} values&{}
836+
throw new Error('Standard 在 ' + folder + ' 语法错误,Object 或 Array 在 notNull: true 时 values 必须为有值的数组 !');
837837
}
838838

839839
log('compareWithStandard values == null; real ' + (real == null ? '=' : '!') + '= null >> return ' + (real == null ? 'COMPARE_EQUAL' : 'COMPARE_KEY_MORE'));
@@ -846,17 +846,17 @@ var JSONResponse = {
846846
}
847847

848848
if (real == null) { //少了key
849-
log('compareWithStandard real == null >> return ' + (notnull == true ? 'COMPARE_KEY_LESS' : 'COMPARE_EQUAL'));
849+
log('compareWithStandard real == null >> return ' + (notNull == true ? 'COMPARE_KEY_LESS' : 'COMPARE_EQUAL'));
850850
return {
851-
code: notnull == true ? JSONResponse.COMPARE_KEY_LESS : JSONResponse.COMPARE_EQUAL,
852-
msg: notnull == true ? '是缺少的' : '结果正确',
853-
path: notnull == true ? folder : '',
851+
code: notNull == true ? JSONResponse.COMPARE_KEY_LESS : JSONResponse.COMPARE_EQUAL,
852+
msg: notNull == true ? '是缺少的' : '结果正确',
853+
path: notNull == true ? folder : '',
854854
value: real
855855
};
856856
}
857857

858-
if (notempty == true && typeof real != 'boolean' && typeof real != 'number' && StringUtil.isEmpty(real, true)) { // 空
859-
log('compareWithStandard notempty == true && StringUtil.isEmpty(real, true) >> return COMPARE_VALUE_EMPTY');
858+
if (notEmpty == true && typeof real != 'boolean' && typeof real != 'number' && StringUtil.isEmpty(real, true)) { // 空
859+
log('compareWithStandard notEmpty == true && StringUtil.isEmpty(real, true) >> return COMPARE_VALUE_EMPTY');
860860
return {
861861
code: JSONResponse.COMPARE_VALUE_EMPTY,
862862
msg: '是空的',
@@ -1162,18 +1162,30 @@ var JSONResponse = {
11621162

11631163
getType: function(o) { //typeof [] = 'object'
11641164
if (o == null) {
1165-
return 'object';
1165+
return 'object'; // FIXME return null
11661166
}
1167+
11671168
if (o instanceof Array) {
11681169
return 'array';
11691170
}
11701171

1171-
var t = typeof o;
1172-
if (t == 'number' && Number.isInteger(o)) {
1172+
if (JSONResponse.isBoolean(o)) {
1173+
return 'boolean';
1174+
}
1175+
1176+
if (JSONResponse.isInteger(o)) {
11731177
return 'integer';
11741178
}
11751179

1176-
return t;
1180+
if (JSONResponse.isNumber(o)) {
1181+
return 'number';
1182+
}
1183+
1184+
if (JSONResponse.isString(o)) {
1185+
return 'string';
1186+
}
1187+
1188+
return typeof o;
11771189
},
11781190

11791191
isObject: function(o) {
@@ -1184,16 +1196,16 @@ var JSONResponse = {
11841196
return o instanceof Array;
11851197
},
11861198
isString: function(o) {
1187-
return typeof o == 'string';
1199+
return typeof o == 'string' || o instanceof String;
11881200
},
11891201
isNumber: function(o) {
1190-
return typeof o == 'number';
1202+
return typeof o == 'number' || o instanceof Number;
11911203
},
11921204
isInteger: function(o) {
1193-
return JSONResponse.getType(o) == 'integer';
1205+
return Number.isInteger(o);
11941206
},
11951207
isBoolean: function(o) {
1196-
return typeof o == 'boolean';
1208+
return typeof o == 'boolean' || o instanceof Boolean;
11971209
},
11981210

11991211

@@ -1282,16 +1294,16 @@ var JSONResponse = {
12821294
log('\n\n\n\n\nupdateStandard <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n' +
12831295
' \ntarget = ' + JSON.stringify(target, null, ' ') + '\n\n\nreal = ' + JSON.stringify(real, null, ' '));
12841296

1285-
var notnull = target.notnull;
1286-
log('updateStandard notnull = target.notnull = ' + notnull + ' >>');
1287-
if (notnull == null) {
1288-
notnull = target.notnull = real != null;
1297+
var notNull = target.notNull;
1298+
log('updateStandard notNull = target.notNull = ' + notNull + ' >>');
1299+
if (notNull == null) {
1300+
notNull = target.notNull = real != null;
12891301
}
12901302

1291-
var notempty = target.notempty;
1292-
log('updateStandard notempty = target.notempty = ' + notempty + ' >>');
1303+
var notEmpty = target.notEmpty;
1304+
log('updateStandard notEmpty = target.notEmpty = ' + notEmpty + ' >>');
12931305
if (real != null && typeof real != 'boolean' && typeof real != 'number') {
1294-
notempty = target.notempty = StringUtil.isNotEmpty(real, true);
1306+
notEmpty = target.notEmpty = StringUtil.isNotEmpty(real, true);
12951307
}
12961308

12971309
var type = target.type;
@@ -1470,10 +1482,10 @@ var JSONResponse = {
14701482
// 解决总是报错缺少字段 delete real[k2]; // 解决总是多出来 key: null real[k2] = null;
14711483

14721484
if (firstVal[k2] == null) {
1473-
firstVal[k2] = { notnull: false };
1485+
firstVal[k2] = { notNull: false };
14741486
}
14751487
else {
1476-
firstVal[k2].notnull = false;
1488+
firstVal[k2].notNull = false;
14771489
}
14781490
}
14791491
}
@@ -1559,6 +1571,71 @@ var JSONResponse = {
15591571
return target;
15601572
},
15611573

1574+
/**根据 APIJSON 引用赋值路径精准地获取值
1575+
*/
1576+
getValByPath: function(target, pathKeys, isTry) {
1577+
if (target == null) {
1578+
return null;
1579+
}
1580+
1581+
var tgt = target;
1582+
var depth = pathKeys == null ? 0 : pathKeys.length
1583+
if (depth <= 0) {
1584+
return target;
1585+
}
1586+
1587+
for (var i = 0; i < depth; i ++) {
1588+
if (tgt == null) {
1589+
return null;
1590+
}
1591+
1592+
var k = pathKeys[i];
1593+
if (k == null) {
1594+
return null;
1595+
}
1596+
k = decodeURI(k)
1597+
1598+
if (tgt instanceof Object) {
1599+
if (k == '') {
1600+
if (tgt instanceof Array) {
1601+
k = 0;
1602+
} else {
1603+
ks = Object.keys(tgt);
1604+
k = ks == null ? null : ks[0];
1605+
if (k == null) {
1606+
return null;
1607+
}
1608+
}
1609+
}
1610+
else {
1611+
k = decodeURI(k)
1612+
if (tgt instanceof Array) {
1613+
try {
1614+
var n = Number.parseInt(k);
1615+
if (Number.isSafeInteger(n)) {
1616+
k = n >= 0 ? n : n + tgt.length;
1617+
}
1618+
} catch (e) {
1619+
}
1620+
}
1621+
}
1622+
1623+
tgt = tgt[k];
1624+
1625+
continue;
1626+
}
1627+
1628+
if (isTry != true) {
1629+
throw new Error('getValByPath 语法错误,' + k + ': value 中 value 类型应该是 Object 或 Array !');
1630+
}
1631+
1632+
return null;
1633+
}
1634+
1635+
return tgt;
1636+
},
1637+
1638+
15621639
/**根据路径精准地更新测试标准中的键值对
15631640
*/
15641641
getStandardByPath: function(target, pathKeys) {
@@ -1590,12 +1667,15 @@ var JSONResponse = {
15901667
k = 0;
15911668
}
15921669
else {
1593-
try {
1594-
var n = Number.parseInt(k);
1595-
if (Number.isSafeInteger(n)) {
1596-
k = 0;
1597-
}
1598-
} catch (e) {
1670+
k = decodeURI(k)
1671+
if (tgt instanceof Array) {
1672+
try {
1673+
var n = Number.parseInt(k);
1674+
if (Number.isSafeInteger(n)) {
1675+
k = n > 0 ? n : n + tgt.length;
1676+
}
1677+
} catch (e) {
1678+
}
15991679
}
16001680
}
16011681

@@ -1664,7 +1744,7 @@ var JSONResponse = {
16641744
if (child == null) {
16651745
child = {};
16661746
child.type = typeof k == 'number' ? 'array' : 'number'; // TODO 没看懂为啥是 array
1667-
child.notnull = false;
1747+
child.notNull = false;
16681748
tgt.values[0] = child;
16691749
}
16701750

@@ -1686,7 +1766,7 @@ var JSONResponse = {
16861766
}
16871767
var startsWithQuestion = comment.startsWith('?')
16881768
tgt.type = JSONResponse.getType(real);
1689-
tgt.notnull = real != null && startsWithQuestion != true
1769+
tgt.notNull = real != null && startsWithQuestion != true
16901770
tgt.comment = startsWithQuestion ? comment.substring(1) : comment
16911771

16921772
return target;

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ table.diff thead th.texttitle {
555555
background-color: #FFF;
556556
}
557557

558-
559558
.historys li {
560559
display: block;
561560
padding: 10px;
@@ -582,6 +581,40 @@ table.diff thead th.texttitle {
582581
}
583582

584583

584+
.projects {
585+
margin: 0;
586+
padding: 0;
587+
width: 200px;
588+
589+
background-color: #FFF;
590+
}
591+
592+
.projects li {
593+
display: block;
594+
padding: 10px;
595+
border-bottom: #DDD 1px solid;
596+
text-overflow: ellipsis;
597+
white-space: nowrap;
598+
overflow: hidden;
599+
padding-right: 20px;
600+
position: relative
601+
}
602+
603+
.projects li a {
604+
display: inline-block;
605+
width: 100%;
606+
}
607+
608+
.projects svg {
609+
position: absolute;
610+
display: inline-block;
611+
cursor: pointer;
612+
right: 5px;
613+
width: 15px;
614+
height: 15px;
615+
}
616+
617+
585618
.pop-save {
586619
padding: 10px;
587620
width: 250px;

0 commit comments

Comments
 (0)