Skip to content

Commit a37bda1

Browse files
committed
自动注释:新增@combine;给各种@key新增示例;解决Table:alias:{}内的key不显示注释或显示不正常
1 parent 6ca4d76 commit a37bda1

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

apijson/CodeUtil.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -890,31 +890,36 @@ var CodeUtil = {
890890
return '';
891891
}
892892

893-
if (JSONObject.isTableKey(name)) {
893+
var aliaIndex = name.indexOf(':');
894+
var objName = aliaIndex < 0 ? name : name.substring(0, aliaIndex);
895+
896+
if (JSONObject.isTableKey(objName)) {
894897
if (key.startsWith('@')) {
895898
switch (key) {
896899
case '@column':
897-
return CodeUtil.getType4Request(value) != 'string' ? ' ! value必须是String类型!' : CodeUtil.getComment('返回字段', false, ' ');
900+
return CodeUtil.getType4Request(value) != 'string' ? ' ! value必须是String类型!' : CodeUtil.getComment('返回字段:例如 id,name,json_length(contactIdList):contactCount...', false, ' ');
898901
case '@order':
899-
return CodeUtil.getType4Request(value) != 'string' ? ' ! value必须是String类型!' : CodeUtil.getComment('排序方式+升序,-降序', false, ' ');
902+
return CodeUtil.getType4Request(value) != 'string' ? ' ! value必须是String类型!' : CodeUtil.getComment('排序方式+升序,-降序,例如 name+,date-,...', false, ' ');
900903
case '@group':
901-
return CodeUtil.getType4Request(value) != 'string' ? ' ! value必须是String类型!' : CodeUtil.getComment('分组方式', false, ' ');
904+
return CodeUtil.getType4Request(value) != 'string' ? ' ! value必须是String类型!' : CodeUtil.getComment('分组方式:例如 userId', false, ' ');
902905
case '@having':
903-
return CodeUtil.getType4Request(value) != 'string' ? ' ! value必须是String类型!' : CodeUtil.getComment('SQL函数', false, ' ');
906+
return CodeUtil.getType4Request(value) != 'string' ? ' ! value必须是String类型!' : CodeUtil.getComment('SQL函数:例如 max(id)>100,sum(balance)<=10000,...', false, ' ');
907+
case '@combine':
908+
return CodeUtil.getType4Request(value) != 'string' ? ' ! value必须是String类型!' : CodeUtil.getComment('条件组合:例如 name?,|tag?,&id{},!id,...', false, ' ');
904909
case '@schema':
905-
return CodeUtil.getType4Request(value) != 'string' ? ' ! value必须是String类型!' : CodeUtil.getComment('数据库', false, ' ');
910+
return CodeUtil.getType4Request(value) != 'string' ? ' ! value必须是String类型!' : CodeUtil.getComment('数据库:例如 sys', false, ' ');
906911
case '@correct':
907912
return value != null ? ' ! value必须是Object类型!' : CodeUtil.getComment('字段校正', false, ' ');
908913
case '@role':
909914
try {
910915
value = value.substring(1, value.length - 1).toUpperCase();
911916
} catch (e) {}
912917
var role = CodeUtil.REQUEST_ROLE[value];
913-
return StringUtil.isEmpty(role) ? ' ! value必须是[' + CodeUtil.REQUEST_ROLE_KEYS.join() + ']中的一种!' : CodeUtil.getComment('登录角色:' + role, false, ' ');
918+
return StringUtil.isEmpty(role) ? ' ! value必须是[' + CodeUtil.REQUEST_ROLE_KEYS.join() + ']中的一种!' : CodeUtil.getComment('来访角色:' + role, false, ' ');
914919
}
915920
return '';
916921
}
917-
var c = CodeUtil.getCommentFromDoc(tableList, name, key, method);
922+
var c = CodeUtil.getCommentFromDoc(tableList, objName, key, method);
918923
return StringUtil.isEmpty(c) ? ' ! 字段不存在!' : CodeUtil.getComment(c, false, ' ');
919924
}
920925

0 commit comments

Comments
 (0)