|
27 | 27 | import static apijson.JSONObject.KEY_COMBINE; |
28 | 28 | import static apijson.JSONObject.KEY_DROP; |
29 | 29 | import static apijson.JSONObject.KEY_TRY; |
| 30 | +import static apijson.JSONRequest.KEY_QUERY; |
30 | 31 | import static apijson.RequestMethod.POST; |
31 | 32 | import static apijson.RequestMethod.PUT; |
32 | 33 | import static apijson.orm.SQLConfig.TYPE_ITEM; |
@@ -555,8 +556,22 @@ public JSON onChildParse(int index, String key, JSONObject value) throws Excepti |
555 | 556 | } |
556 | 557 | } |
557 | 558 |
|
| 559 | + String query = value.getString(KEY_QUERY); |
558 | 560 | child = parser.onArrayParse(value, path, key, isSubquery); |
559 | 561 | isEmpty = child == null || ((JSONArray) child).isEmpty(); |
| 562 | + |
| 563 | + if (isEmpty == false && ("2".equals(query) || "ALL".equals(query))) { |
| 564 | + String infoKey = JSONResponse.formatArrayKey(key) + "Info"; |
| 565 | + if (request.containsKey("total@") == false && request.containsKey(infoKey + "@") == false) { |
| 566 | + // onParse("total@", "/" + key + "/total"); |
| 567 | + // onParse(infoKey + "@", "/" + key + "/info"); |
| 568 | + // 替换为以下性能更好、对流程干扰最小的方式: |
| 569 | + String totalPath = AbstractParser.getValuePath(type == TYPE_ITEM ? path : parentPath, "/" + key + "/total"); |
| 570 | + String infoPath = AbstractParser.getValuePath(type == TYPE_ITEM ? path : parentPath, "/" + key + "/info"); |
| 571 | + response.put("total", onReferenceParse(totalPath)); |
| 572 | + response.put(infoKey, onReferenceParse(infoPath)); |
| 573 | + } |
| 574 | + } |
560 | 575 | } |
561 | 576 | else { //APIJSON Object |
562 | 577 | boolean isTableKey = JSONRequest.isTableKey(Pair.parseEntry(key, true).getKey()); |
|
0 commit comments