Skip to content

Commit 09a60dc

Browse files
committed
key[]:{ query:2 或 query:"All" } 默认返回列表分页信息 调整 total 的 key 名,避免同级多列表导致重名
1 parent 8715e12 commit 09a60dc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,15 +561,16 @@ public JSON onChildParse(int index, String key, JSONObject value) throws Excepti
561561
isEmpty = child == null || ((JSONArray) child).isEmpty();
562562

563563
if (isEmpty == false && ("2".equals(query) || "ALL".equals(query))) {
564+
String totalKey = JSONResponse.formatArrayKey(key) + "Total";
564565
String infoKey = JSONResponse.formatArrayKey(key) + "Info";
565-
if (request.containsKey("total") == false && request.containsKey(infoKey) == false
566-
&& request.containsKey("total@") == false && request.containsKey(infoKey + "@") == false) {
566+
if ((request.containsKey(totalKey) || request.containsKey(infoKey)
567+
|| request.containsKey(totalKey + "@") || request.containsKey(infoKey + "@")) == false) {
567568
// onParse("total@", "/" + key + "/total");
568569
// onParse(infoKey + "@", "/" + key + "/info");
569570
// 替换为以下性能更好、对流程干扰最小的方式:
570571
String totalPath = AbstractParser.getValuePath(type == TYPE_ITEM ? path : parentPath, "/" + key + "/total");
571572
String infoPath = AbstractParser.getValuePath(type == TYPE_ITEM ? path : parentPath, "/" + key + "/info");
572-
response.put("total", onReferenceParse(totalPath));
573+
response.put(totalKey, onReferenceParse(totalPath));
573574
response.put(infoKey, onReferenceParse(infoPath));
574575
}
575576
}

0 commit comments

Comments
 (0)