Skip to content

Commit 5108239

Browse files
committed
请求JSON注释:新增逻辑运算的注释
1 parent 7ec3174 commit 5108239

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

apijson/CodeUtil.js

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -866,69 +866,79 @@ var CodeUtil = {
866866
return table.TABLE_COMMENT;
867867
}
868868

869+
870+
//功能符 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
871+
869872
if (columnName.endsWith("()")) {//方法,查询完后处理,先用一个Map<key,function>保存?
870873
return '远程函数';
871874
}
872875

873-
var prefix;
874-
var at = '';
875-
var key;
876876

877+
var at = '';
877878
if (columnName.endsWith("@")) {//引用,引用对象查询完后处理。fillTarget中暂时不用处理,因为非GET请求都是由给定的id确定,不需要引用
878879
at = '引用赋值';
879880
columnName = columnName.substring(0, columnName.length - 1);
880881
}
881882

883+
var fun;
884+
var key;
882885
if (columnName.endsWith("$")) {//搜索,查询时处理
883-
prefix = '模糊搜索';
886+
fun = '模糊搜索';
884887
key = columnName.substring(0, columnName.length - 1);
885888
}
886889
else if (columnName.endsWith("?")) {//匹配正则表达式,查询时处理
887-
prefix = '正则匹配';
890+
fun = '正则匹配';
888891
key = columnName.substring(0, columnName.length - 1);
889892
}
890893
else if (columnName.endsWith("{}")) {//被包含,或者说key对应值处于value的范围内。查询时处理
891-
prefix = '匹配 选项/条件';
894+
fun = '匹配 选项/条件';
892895
key = columnName.substring(0, columnName.length - 2);
893896
}
894897
else if (columnName.endsWith("<>")) {//包含,或者说value处于key对应值的范围内。查询时处理
895-
prefix = '包含选项';
898+
fun = '包含选项';
896899
key = columnName.substring(0, columnName.length - 2);
897900
}
898901
else if (columnName.endsWith("+")) {//延长,PUT查询时处理
899902
//if (method == PUT) {//不为PUT就抛异常
900-
prefix = '增加 或 扩展 ';
903+
fun = '增加 或 扩展 ';
901904
key = columnName.substring(0, columnName.length - 1);
902905
//}
903906
}
904907
else if (columnName.endsWith("-")) {//缩减,PUT查询时处理
905908
//if (method == PUT) {//不为PUT就抛异常
906-
prefix = '减少 或 去除';
909+
fun = '减少 或 去除';
907910
key = columnName.substring(0, columnName.length - 1);
908911
//}
909912
}
910913
else {
911-
prefix = '';
914+
fun = '';
912915
key = new String(columnName);
913916
}
914917

915918

916-
var last = null;//不用Logic优化代码,否则 key 可能变为 key| 导致 key=value 变成 key|=value 而出错
919+
var logic = '';
917920
//if (RequestMethod.isQueryMethod(method)) {//逻辑运算符仅供GET,HEAD方法使用
918-
last = key.length <= 0 ? "" : key.substring(key.length - 1);
919-
if ("&" == last || "|" == last || "!" == last) {
920-
key = key.substring(0, key.length - 1);
921-
} else {
922-
last = null;//避免key + StringUtil.getString(last)错误延长
921+
if (key.endsWith("&")) {
922+
logic = '符合全部';
923923
}
924+
else if (key.endsWith("|")) {
925+
logic = '符合任意';
926+
}
927+
else if (key.endsWith("!")) {
928+
logic = '都不符合';
929+
}
930+
else {}
924931
//}
925932

926-
if (StringUtil.isName(key) == false) {
927-
return ' ! 字符' + key + '不合法!';
933+
if (logic.length > 0) {
934+
key = key.substring(0, key.length - 1);
928935
}
929936

937+
if (StringUtil.isName(key) == false) {
938+
return ' ! 字符 ' + key + ' 不合法!';
939+
}
930940

931-
941+
//功能符 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
932942

933943

934944
columnList = item['Column[]'];
@@ -945,7 +955,9 @@ var CodeUtil = {
945955
continue;
946956
}
947957

948-
var p = (at.length <= 0 ? '' : at + ' > ') + (prefix.length <= 0 ? '' : prefix + ' > ');
958+
var p = (at.length <= 0 ? '' : at + ' > ')
959+
+ (fun.length <= 0 ? '' : fun + ' > ')
960+
+ (logic.length <= 0 ? '' : logic + ' > ');
949961
return (p.length <= 0 ? '' : p + key + ': ') + column.COLUMN_COMMENT;
950962
}
951963

0 commit comments

Comments
 (0)