Skip to content

Commit 7f2b051

Browse files
committed
自动生成文档:新增访问角色
1 parent ea00f88 commit 7f2b051

File tree

2 files changed

+64
-15
lines changed

2 files changed

+64
-15
lines changed

apijson/JSONResponse.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,13 @@ var JSONResponse = {
477477
return StringUtil.isEmpty(folder, true) ? name : folder + '/' + name;
478478
},
479479

480+
getShowString(arr) {
481+
if (arr == null || arr.length <= 0) {
482+
return '';
483+
}
484+
return arr.join();
485+
},
486+
480487
log(msg) {
481488
// console.log(msg);
482489
}

js/main.js

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,9 +1382,12 @@
13821382
}
13831383
}
13841384
},
1385-
'Request[]': {
1386-
'Request': {
1387-
'@order': 'version-,method-'
1385+
'Access[]': {
1386+
'Access': {
1387+
'@column': 'name,alias,get,head,gets,heads,post,put,delete',
1388+
'@order': 'date-,name+',
1389+
'name()': 'getWithDefault(alias,name)',
1390+
'r0()': 'removeKey(alias)'
13881391
}
13891392
},
13901393
'Function[]': {
@@ -1396,6 +1399,11 @@
13961399
'r0()': 'removeKey(name)',
13971400
'r1()': 'removeKey(arguments)'
13981401
}
1402+
},
1403+
'Request[]': {
1404+
'Request': {
1405+
'@order': 'version-,method-'
1406+
}
13991407
}
14001408
}, function (url, res, err) {
14011409
if (err != null || res == null || res.data == null) {
@@ -1468,32 +1476,38 @@
14681476
//[] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
14691477

14701478

1471-
//Request[] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1472-
list = docObj == null ? null : docObj['Request[]'];
1479+
1480+
//Access[] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1481+
list = docObj == null ? null : docObj['Access[]'];
14731482
if (list != null) {
1474-
log('getDoc Request[] = \n' + format(JSON.stringify(list)));
1483+
log('getDoc Access[] = \n' + format(JSON.stringify(list)));
14751484

1476-
doc += '\n\n\n\n\n\n\n\n\n### 非开放请求'
1477-
+ ' \n 版本 | 方法 | 数据和结构'
1478-
+ ' \n -------- | ------------ | ------------ | ------------ ';
1485+
doc += '\n\n\n\n\n\n\n\n\n### 访问权限'
1486+
+ ' \n 表名 | 允许 get 的角色 | 允许 head 的角色 | 允许 gets 的角色 | 允许 heads 的角色 | 允许 post 的角色 | 允许 put 的角色 | 允许 delete 的角色'
1487+
+ ' \n -------- | -------------- | -------------- | -------------- | -------------- | -------------- | -------------- | -------------- ';
14791488

14801489
for (var i = 0; i < list.length; i++) {
14811490
item = list[i];
14821491
if (item == null) {
14831492
continue;
14841493
}
1485-
log('getDoc Request[] for i=' + i + ': item = \n' + format(JSON.stringify(item)));
1494+
log('getDoc Access[] for i=' + i + ': item = \n' + format(JSON.stringify(item)));
14861495

14871496

1488-
doc += '\n' + item.version + ' | ' + item.method
1489-
+ ' | ' + JSON.stringify(App.getStructure(item.structure, item.tag));
1497+
doc += '\n' + item.name
1498+
+ ' | ' + JSONResponse.getShowString(JSON.parse(item.get))
1499+
+ ' | ' + JSONResponse.getShowString(JSON.parse(item.head))
1500+
+ ' | ' + JSONResponse.getShowString(JSON.parse(item.gets))
1501+
+ ' | ' + JSONResponse.getShowString(JSON.parse(item.heads))
1502+
+ ' | ' + JSONResponse.getShowString(JSON.parse(item.post))
1503+
+ ' | ' + JSONResponse.getShowString(JSON.parse(item.put))
1504+
+ ' | ' + JSONResponse.getShowString(JSON.parse(item.delete));
14901505
}
14911506

1492-
doc += '\n注: \n1.GET,HEAD方法不受限,可传任何 数据、结构。\n2.可在最外层传版本version来指定使用的版本,不传或 version <= 0 则使用最新版。\n\n\n\n\n\n\n';
1507+
doc += '\n' //避免没数据时表格显示没有网格
14931508
}
14941509

1495-
1496-
//Request[] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1510+
//Access[] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
14971511

14981512

14991513
//Function[] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -1521,6 +1535,34 @@
15211535

15221536
//Function[] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
15231537

1538+
1539+
//Request[] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1540+
list = docObj == null ? null : docObj['Request[]'];
1541+
if (list != null) {
1542+
log('getDoc Request[] = \n' + format(JSON.stringify(list)));
1543+
1544+
doc += '\n\n\n\n\n\n\n\n\n### 非开放请求'
1545+
+ ' \n 版本 | 方法 | 数据和结构'
1546+
+ ' \n -------- | ------------ | ------------ | ------------ ';
1547+
1548+
for (var i = 0; i < list.length; i++) {
1549+
item = list[i];
1550+
if (item == null) {
1551+
continue;
1552+
}
1553+
log('getDoc Request[] for i=' + i + ': item = \n' + format(JSON.stringify(item)));
1554+
1555+
1556+
doc += '\n' + item.version + ' | ' + item.method
1557+
+ ' | ' + JSON.stringify(App.getStructure(item.structure, item.tag));
1558+
}
1559+
1560+
doc += '\n注: \n1.GET,HEAD方法不受限,可传任何 数据、结构。\n2.可在最外层传版本version来指定使用的版本,不传或 version <= 0 则使用最新版。\n\n\n\n\n\n\n';
1561+
}
1562+
1563+
1564+
//Request[] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1565+
15241566
App.onChange(false);
15251567

15261568

0 commit comments

Comments
 (0)