@@ -62,7 +62,6 @@ var CodeUtil = {
62
62
else {
63
63
if ( line . endsWith ( '}' ) ) {
64
64
if ( line . endsWith ( '{}' ) ) { //对象,判断是不是Table,再加对应的注释
65
- names [ depth ] = key ;
66
65
comment = CodeUtil . getComment4Request ( tableList , null , key , null , method ) ;
67
66
}
68
67
else {
@@ -225,20 +224,22 @@ var CodeUtil = {
225
224
const isTable = isSmart && JSONObject . isTableKey ( JSONResponse . getTableName ( key ) ) ;
226
225
227
226
const column = isTable ? value [ '@column' ] : null ;
228
- const order = isTable ? value [ '@order' ] : null ;
229
227
const group = isTable ? value [ '@group' ] : null ;
230
228
const having = isTable ? value [ '@having' ] : null ;
229
+ const order = isTable ? value [ '@order' ] : null ;
231
230
const combine = isTable ? value [ '@combine' ] : null ;
232
231
const schema = isTable ? value [ '@schema' ] : null ;
232
+ const database = isTable ? value [ '@database' ] : null ;
233
233
const role = isTable ? value [ '@role' ] : null ;
234
234
235
235
if ( isTable ) {
236
236
delete value [ '@column' ] ;
237
- delete value [ '@order' ] ;
238
237
delete value [ '@group' ] ;
239
238
delete value [ '@having' ] ;
239
+ delete value [ '@order' ] ;
240
240
delete value [ '@combine' ] ;
241
241
delete value [ '@schema' ] ;
242
+ delete value [ '@database' ] ;
242
243
delete value [ '@role' ] ;
243
244
}
244
245
@@ -247,11 +248,12 @@ var CodeUtil = {
247
248
const name = CodeUtil . getTableKey ( JSONResponse . getSimpleName ( key ) ) ;
248
249
if ( isTable ) {
249
250
s = column == null ? s : s + '\n' + name + '.setColumn(' + CodeUtil . getJavaValue ( name , key , column ) + ');' ;
250
- s = order == null ? s : s + '\n' + name + '.setOrder(' + CodeUtil . getJavaValue ( name , key , order ) + ');' ;
251
251
s = group == null ? s : s + '\n' + name + '.setGroup(' + CodeUtil . getJavaValue ( name , key , group ) + ');' ;
252
252
s = having == null ? s : s + '\n' + name + '.setHaving(' + CodeUtil . getJavaValue ( name , key , having ) + ');' ;
253
+ s = order == null ? s : s + '\n' + name + '.setOrder(' + CodeUtil . getJavaValue ( name , key , order ) + ');' ;
253
254
s = combine == null ? s : s + '\n' + name + '.setCombine(' + CodeUtil . getJavaValue ( name , key , combine ) + ');' ;
254
255
s = schema == null ? s : s + '\n' + name + '.setSchema(' + CodeUtil . getJavaValue ( name , key , schema ) + ');' ;
256
+ s = database == null ? s : s + '\n' + name + '.setDatabase(' + CodeUtil . getJavaValue ( name , key , database ) + ');' ;
255
257
s = role == null ? s : s + '\n' + name + '.setRole(' + CodeUtil . getJavaValue ( name , key , role ) + ');' ;
256
258
}
257
259
@@ -270,6 +272,18 @@ var CodeUtil = {
270
272
if ( key == 'version' ) {
271
273
return '\n' + parentKey + '.setVersion(' + CodeUtil . getJavaValue ( name , key , value ) + ');' ;
272
274
}
275
+ if ( key == 'format' ) {
276
+ return '\n' + parentKey + '.setFormat(' + CodeUtil . getJavaValue ( name , key , value ) + ');' ;
277
+ }
278
+ if ( key == '@schema' ) {
279
+ return '\n' + parentKey + '.setSchema(' + CodeUtil . getJavaValue ( name , key , value ) + ');' ;
280
+ }
281
+ if ( key == '@database' ) {
282
+ return '\n' + parentKey + '.setDatabase(' + CodeUtil . getJavaValue ( name , key , value ) + ');' ;
283
+ }
284
+ if ( key == '@role' ) {
285
+ return '\n' + parentKey + '.setRole(' + CodeUtil . getJavaValue ( name , key , value ) + ');' ;
286
+ }
273
287
}
274
288
return '\n' + parentKey + '.put("' + key + '", ' + CodeUtil . getJavaValue ( name , key , value ) + ');' ;
275
289
}
@@ -827,6 +841,7 @@ var CodeUtil = {
827
841
OWNER : '拥有者' ,
828
842
ADMIN : '管理员'
829
843
} ,
844
+ REQUEST_DATABASE_KEYS : [ 'MYSQL' , 'POSTGRESQL' , 'ORACLE' ] ,
830
845
831
846
/**获取请求JSON的注释
832
847
* @param tableList
@@ -875,17 +890,17 @@ var CodeUtil = {
875
890
if ( JSONObject . isArrayKey ( name ) ) {
876
891
switch ( key ) {
877
892
case 'count' :
878
- return CodeUtil . getType4Request ( value ) != 'number' ? ' ! value必须是Number类型!' : CodeUtil . getComment ( '最多数量' , false , ' ' ) ;
893
+ return CodeUtil . getType4Request ( value ) != 'number' ? ' ! value必须是Number类型!' : CodeUtil . getComment ( '最多数量: 例如 5 10 20 ... ' , false , ' ' ) ;
879
894
case 'page' :
880
895
if ( CodeUtil . getType4Request ( value ) != 'number' ) {
881
896
return ' ! value必须是Number类型!' ;
882
897
}
883
- return value < 0 ? ' ! 必须 >= 0 !' : CodeUtil . getComment ( '分页页码' , false , ' ' ) ;
898
+ return value < 0 ? ' ! 必须 >= 0 !' : CodeUtil . getComment ( '分页页码: 例如 0 1 2 ... ' , false , ' ' ) ;
884
899
case 'query' :
885
900
var query = CodeUtil . QUERY_TYPES [ value ] ;
886
901
return StringUtil . isEmpty ( query ) ? ' ! value必须是[' + CodeUtil . QUERY_TYPE_KEYS . join ( ) + ']中的一种!' : CodeUtil . getComment ( '查询内容:0-数据 1-总数 2-全部' , false , ' ' ) ;
887
902
case 'join' :
888
- return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '多表连接:LEFT JOIN < ,RIGHT JOIN > ,INNER JOIN & | ! ' , false , ' ' ) ;
903
+ return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '多表连接:例如 &/User/id@,</Comment/momentId@,... ' , false , ' ' ) ;
889
904
}
890
905
return '' ;
891
906
}
@@ -894,29 +909,32 @@ var CodeUtil = {
894
909
var objName = aliaIndex < 0 ? name : name . substring ( 0 , aliaIndex ) ;
895
910
896
911
if ( JSONObject . isTableKey ( objName ) ) {
912
+ switch ( key ) {
913
+ case '@column' :
914
+ return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '返回字段:例如 id,name;json_length(contactIdList):contactCount;...' , false , ' ' ) ;
915
+ case '@group' :
916
+ return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '分组方式:例如 userId,momentId,...' , false , ' ' ) ;
917
+ case '@having' :
918
+ return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( 'SQL函数:例如 max(id)>100;sum(balance)<=10000;...' , false , ' ' ) ;
919
+ case '@order' :
920
+ return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '排序方式:+升序,-降序,例如 name+,date-,...' , false , ' ' ) ;
921
+ case '@combine' :
922
+ return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '条件组合:例如 name?,|tag?,&id{},!id,...' , false , ' ' ) ;
923
+ case '@schema' :
924
+ return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '集合空间:例如 sys apijson ...' , false , ' ' ) ;
925
+ case '@database' :
926
+ try {
927
+ value = value . substring ( 1 , value . length - 1 ) . toUpperCase ( ) ;
928
+ } catch ( e ) { }
929
+ return CodeUtil . REQUEST_DATABASE_KEYS . indexOf ( value ) < 0 ? ' ! value必须是[' + CodeUtil . REQUEST_DATABASE_KEYS . join ( ) + ']中的一种!' : CodeUtil . getComment ( '数据库:例如 MYSQL POSTGRESQL ORACLE ...' , false , ' ' ) ;
930
+ case '@role' :
931
+ try {
932
+ value = value . substring ( 1 , value . length - 1 ) . toUpperCase ( ) ;
933
+ } catch ( e ) { }
934
+ var role = CodeUtil . REQUEST_ROLE [ value ] ;
935
+ return StringUtil . isEmpty ( role ) ? ' ! value必须是[' + CodeUtil . REQUEST_ROLE_KEYS . join ( ) + ']中的一种!' : CodeUtil . getComment ( '来访角色:' + role , false , ' ' ) ;
936
+ }
897
937
if ( key . startsWith ( '@' ) ) {
898
- switch ( key ) {
899
- case '@column' :
900
- return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '返回字段:例如 id,name,json_length(contactIdList):contactCount...' , false , ' ' ) ;
901
- case '@order' :
902
- return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '排序方式:+升序,-降序,例如 name+,date-,...' , false , ' ' ) ;
903
- case '@group' :
904
- return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '分组方式:例如 userId' , false , ' ' ) ;
905
- case '@having' :
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 , ' ' ) ;
909
- case '@schema' :
910
- return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '数据库:例如 sys' , false , ' ' ) ;
911
- case '@correct' :
912
- return value != null ? ' ! value必须是Object类型!' : CodeUtil . getComment ( '字段校正' , false , ' ' ) ;
913
- case '@role' :
914
- try {
915
- value = value . substring ( 1 , value . length - 1 ) . toUpperCase ( ) ;
916
- } catch ( e ) { }
917
- var role = CodeUtil . REQUEST_ROLE [ value ] ;
918
- return StringUtil . isEmpty ( role ) ? ' ! value必须是[' + CodeUtil . REQUEST_ROLE_KEYS . join ( ) + ']中的一种!' : CodeUtil . getComment ( '来访角色:' + role , false , ' ' ) ;
919
- }
920
938
return '' ;
921
939
}
922
940
var c = CodeUtil . getCommentFromDoc ( tableList , objName , key , method ) ;
@@ -930,12 +948,21 @@ var CodeUtil = {
930
948
if ( method == 'GET' || method == 'HEAD' ) {
931
949
return '' ;
932
950
}
933
- return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '请求密钥' , false , ' ' ) ;
951
+ return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '请求密钥:例如 User Comment[] Privacy-CIRCLE ... ' , false , ' ' ) ;
934
952
case 'version' :
935
953
if ( method == 'GET' || method == 'HEAD' ) {
936
954
return '' ;
937
955
}
938
- return CodeUtil . getType4Request ( value ) != 'number' ? ' ! value必须是Number类型!' : CodeUtil . getComment ( '版本号' , false , ' ' ) ;
956
+ return CodeUtil . getType4Request ( value ) != 'number' ? ' ! value必须是Number类型!' : CodeUtil . getComment ( '版本号: 例如 1 2 3 ...' , false , ' ' ) ;
957
+ case 'format' :
958
+ return CodeUtil . getType4Request ( value ) != 'boolean' ? ' ! value必须是Boolean类型!' : CodeUtil . getComment ( '格式化: true-是 false-否' , false , ' ' ) ;
959
+ case '@schema' :
960
+ return CodeUtil . getType4Request ( value ) != 'string' ? ' ! value必须是String类型!' : CodeUtil . getComment ( '集合空间:例如 sys apijson ...' , false , ' ' ) ;
961
+ case '@database' :
962
+ try {
963
+ value = value . substring ( 1 , value . length - 1 ) . toUpperCase ( ) ;
964
+ } catch ( e ) { }
965
+ return CodeUtil . REQUEST_DATABASE_KEYS . indexOf ( value ) < 0 ? ' ! value必须是[' + CodeUtil . REQUEST_DATABASE_KEYS . join ( ) + ']中的一种!' : CodeUtil . getComment ( '数据库:例如 MYSQL POSTGRESQL ORACLE ...' , false , ' ' ) ;
939
966
case '@role' :
940
967
try {
941
968
value = value . substring ( 1 , value . length - 1 ) . toUpperCase ( ) ;
0 commit comments