|
28 | 28 | import com.alibaba.fastjson.JSONObject; |
29 | 29 |
|
30 | 30 | import zuo.biao.apijson.JSON; |
31 | | -import zuo.biao.apijson.JSONRequest; |
| 31 | +import zuo.biao.apijson.JSONResponse; |
32 | 32 | import zuo.biao.apijson.RequestMethod; |
33 | 33 | import zuo.biao.apijson.StringUtil; |
34 | 34 | import zuo.biao.apijson.Table; |
@@ -555,38 +555,38 @@ private JSONObject getArray(String parentPath, QueryConfig parentConfig, String |
555 | 555 | System.out.println(TAG + "getArray try { page = arrayObject.getIntValue(page); ..." + |
556 | 556 | " >> } catch (Exception e) {\n" + e.getMessage()); |
557 | 557 | } |
558 | | - |
| 558 | + if (count <= 0 || count > 100) {//count最大为100 |
| 559 | + count = 100; |
| 560 | + } |
| 561 | + |
559 | 562 | //最好先获取第一个table的所有项(where条件),填充一个列表? |
560 | 563 | Set<String> set = request.keySet(); |
561 | 564 | if (count <= 0 || count > 10) {//10以下不优化长度 |
562 | 565 | if(parseRelation == false && set != null) { |
563 | | - JSONObject object; |
| 566 | + Object object; |
564 | 567 | int totalCount = 0; |
565 | 568 | for (String key : set) { |
566 | | - if (isTableKey(key)) { |
567 | | - object = getJSONObject(request, key); |
568 | | - if (object != null) {// && object.isEmpty() == false) { |
569 | | - totalCount = QueryHelper.getInstance().getCount(key); |
570 | | - break; |
571 | | - } |
| 569 | + object = isTableKey(key) ? request.get(key) : null; |
| 570 | + if (object != null && object instanceof JSONObject) {// && object.isEmpty() == false) { |
| 571 | + // totalCount = QueryHelper.getInstance().getCount(key); |
| 572 | + JSONObject response = new RequestParser(RequestMethod.HEAD) |
| 573 | + .parseResponse(new JSONRequest(key, object)); |
| 574 | + JSONObject target = response == null ? null : response.getJSONObject(key); |
| 575 | + totalCount = target == null ? 0 : target.getIntValue(JSONResponse.KEY_COUNT); |
| 576 | + break; |
572 | 577 | } |
573 | 578 | } |
574 | 579 | if (totalCount <= 0) {//request内部没有JSONObject或者不存在适合条件的table内容 |
575 | 580 | return null; |
576 | 581 | } |
577 | 582 | if (count > totalCount) { |
578 | 583 | count = totalCount; |
| 584 | + request.put(JSONRequest.KEY_COUNT, count); |
579 | 585 | } |
580 | 586 | } |
581 | 587 | } |
582 | | - if (count <= 0 || count > 100) {//count最大为100 |
583 | | - count = 100; |
584 | | - } |
585 | 588 |
|
586 | | - // if (parseRelation) { |
587 | | - // request.remove("page"); |
588 | | - // request.remove("count"); |
589 | | - // } |
| 589 | + |
590 | 590 | System.out.println(TAG + "getArray page = " + page + "; count = " + count); |
591 | 591 |
|
592 | 592 | QueryConfig config = new QueryConfig(requestMethod, count, page); |
@@ -625,6 +625,9 @@ private JSONObject getArray(String parentPath, QueryConfig parentConfig, String |
625 | 625 | } |
626 | 626 | } |
627 | 627 | } else { |
| 628 | + // request.remove(JSONRequest.KEY_PAGE); |
| 629 | + // request.remove(JSONRequest.KEY_COUNT); |
| 630 | + |
628 | 631 | for (String key : set) { |
629 | 632 | value = request.get(key); |
630 | 633 | if (value instanceof JSONObject) {//JSONObject,往下一级提取 |
|
0 commit comments