@@ -209,7 +209,7 @@ public SQLExecutor getSQLExecutor() {
209209 public Verifier <T > getVerifier () {
210210 return verifier ;
211211 }
212-
212+
213213 /**解析请求json并获取对应结果
214214 * @param request
215215 * @return
@@ -316,30 +316,35 @@ public JSONObject parseResponse(JSONObject request) {
316316
317317 requestObject = error == null ? extendSuccessResult (requestObject ) : extendErrorResult (requestObject , error );
318318
319+ JSONObject res = globleFormat && JSONResponse .isSuccess (requestObject ) ? new JSONResponse (requestObject ) : requestObject ;
320+
321+ long endTime = System .currentTimeMillis ();
322+ long duration = endTime - startTime ;
323+
319324 if (Log .DEBUG ) {
325+ requestObject .put ("time:start/duration/end" , startTime + "/" + duration + "/" + endTime );
320326 requestObject .put ("query:depth/max" , queryDepth + "/" + getMaxQueryDepth ());
321327 requestObject .put ("sql:generate/cache/execute/maxExecute" , sqlExecutor .getGeneratedSQLCount () + "/" + sqlExecutor .getCachedSQLCount () + "/" + sqlExecutor .getExecutedSQLCount () + "/" + getMaxSQLCount ());
322328 }
323-
329+
324330 sqlExecutor .close ();
325331 sqlExecutor = null ;
326-
327332 queryResultMap .clear ();
333+ queryResultMap = null ;
328334
329335 //会不会导致原来的session = null? session = null;
330336
337+ if (Log .DEBUG ) {
338+ Log .d (TAG , "\n \n \n \n <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n "
339+ + requestMethod + "/parseResponse request = \n " + requestString + "\n \n " );
331340
332- Log .d (TAG , "\n \n \n \n <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n "
333- + requestMethod + "/parseResponse request = \n " + requestString + "\n \n " );
334-
335- Log .d (TAG , "parse return response = \n " + JSON .toJSONString (requestObject )
336- + "\n >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> \n \n \n " );
337-
338- long endTime = System .currentTimeMillis ();
339- Log .d (TAG , "parseResponse endTime = " + endTime + "; duration = " + (endTime - startTime )
341+ Log .d (TAG , "parseResponse return response = \n " + JSON .toJSONString (requestObject )
342+ + "\n >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> \n \n \n " );
343+ }
344+ Log .d (TAG , "parseResponse endTime = " + endTime + "; duration = " + duration
340345 + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n \n \n " );
341346
342- return globleFormat && JSONResponse . isSuccess ( requestObject ) ? new JSONResponse ( requestObject ) : requestObject ;
347+ return res ;
343348 }
344349
345350
@@ -366,7 +371,9 @@ public void onVerifyRole(@NotNull SQLConfig config) throws Exception {
366371 config .setSchema (globleSchema );
367372 }
368373
369- Log .i (TAG , "executeSQL config = " + JSON .toJSONString (config ));
374+ if (Log .DEBUG ) {
375+ Log .i (TAG , "onVerifyRole config = " + JSON .toJSONString (config ));
376+ }
370377
371378 if (noVerifyRole == false ) {
372379 if (config .getRole () == null ) {
@@ -635,8 +642,11 @@ public JSONObject getStructure(@NotNull String table, String key, String value,
635642 @ Override
636643 public JSONObject onObjectParse (final JSONObject request
637644 , String parentPath , String name , final SQLConfig arrayConfig , boolean isSubquery ) throws Exception {
638- Log .i (TAG , "\n getObject: parentPath = " + parentPath
639- + ";\n name = " + name + "; request = " + JSON .toJSONString (request ));
645+
646+ if (Log .DEBUG ) {
647+ Log .i (TAG , "\n getObject: parentPath = " + parentPath
648+ + ";\n name = " + name + "; request = " + JSON .toJSONString (request ));
649+ }
640650 if (request == null ) {// Moment:{} || request.isEmpty()) {//key-value条件
641651 return null ;
642652 }
@@ -713,8 +723,11 @@ public JSONObject onObjectParse(final JSONObject request
713723 */
714724 @ Override
715725 public JSONArray onArrayParse (JSONObject request , String parentPath , String name , boolean isSubquery ) throws Exception {
716- Log .i (TAG , "\n \n \n onArrayParse parentPath = " + parentPath
717- + "; name = " + name + "; request = " + JSON .toJSONString (request ));
726+ if (Log .DEBUG ) {
727+ Log .i (TAG , "\n \n \n onArrayParse parentPath = " + parentPath
728+ + "; name = " + name + "; request = " + JSON .toJSONString (request ));
729+ }
730+
718731 //不能允许GETS,否则会被通过"[]":{"@role":"ADMIN"},"Table":{},"tag":"Table"绕过权限并能批量查询
719732 if (RequestMethod .isGetMethod (requestMethod , false ) == false ) {
720733 throw new UnsupportedOperationException ("key[]:{}只支持GET方法!不允许传 " + name + ":{} !" );
@@ -775,16 +788,16 @@ public JSONArray onArrayParse(JSONObject request, String parentPath, String name
775788 request .remove (JSONRequest .KEY_COUNT );
776789 request .remove (JSONRequest .KEY_PAGE );
777790 request .remove (JSONRequest .KEY_JOIN );
778- Log .d (TAG , "getArray query = " + query + "; count = " + count + "; page = " + page + "; join = " + join );
791+ Log .d (TAG , "onArrayParse query = " + query + "; count = " + count + "; page = " + page + "; join = " + join );
779792
780793 if (request .isEmpty ()) {//如果条件成立,说明所有的 parentPath/name:request 中request都无效!!!
781- Log .e (TAG , "getArray request.isEmpty() >> return null;" );
794+ Log .e (TAG , "onArrayParse request.isEmpty() >> return null;" );
782795 return null ;
783796 }
784797
785798
786799 int size = count2 == 0 ? max : count2 ;//count为每页数量,size为第page页实际数量,max(size) = count
787- Log .d (TAG , "getArray size = " + size + "; page = " + page );
800+ Log .d (TAG , "onArrayParse size = " + size + "; page = " + page );
788801
789802
790803 //key[]:{Table:{}}中key equals Table时 提取Table
@@ -847,7 +860,9 @@ public JSONArray onArrayParse(JSONObject request, String parentPath, String name
847860 request .put (JSONRequest .KEY_PAGE , page );
848861 request .put (JSONRequest .KEY_JOIN , join );
849862
850- Log .i (TAG , "getArray return response = \n " + JSON .toJSONString (response ) + "\n >>>>>>>>>>>>>>>\n \n \n " );
863+ if (Log .DEBUG ) {
864+ Log .i (TAG , "onArrayParse return response = \n " + JSON .toJSONString (response ) + "\n >>>>>>>>>>>>>>>\n \n \n " );
865+ }
851866 return response ;
852867 }
853868
@@ -1284,7 +1299,7 @@ public JSONObject executeSQL(SQLConfig config, boolean isSubquery) throws Except
12841299 Log .d (TAG , "executeSQL config == null >> return null;" );
12851300 return null ;
12861301 }
1287-
1302+
12881303 if (isSubquery ) {
12891304 JSONObject sqlObj = new JSONObject (true );
12901305 sqlObj .put (KEY_CONFIG , config );
0 commit comments