key[]:{ query:2 或 query:"All" } 默认返回列表分页信息 调整 total 的 key 名,避免同级多列表导致重名

This commit is contained in:
TommyLemon 2024-06-16 19:31:27 +08:00
parent 8715e1298d
commit 09a60dc891

View File

@ -561,15 +561,16 @@ public abstract class AbstractObjectParser<T extends Object> implements ObjectPa
isEmpty = child == null || ((JSONArray) child).isEmpty();
if (isEmpty == false && ("2".equals(query) || "ALL".equals(query))) {
String totalKey = JSONResponse.formatArrayKey(key) + "Total";
String infoKey = JSONResponse.formatArrayKey(key) + "Info";
if (request.containsKey("total") == false && request.containsKey(infoKey) == false
&& request.containsKey("total@") == false && request.containsKey(infoKey + "@") == false) {
if ((request.containsKey(totalKey) || request.containsKey(infoKey)
|| request.containsKey(totalKey + "@") || request.containsKey(infoKey + "@")) == false) {
// onParse("total@", "/" + key + "/total");
// onParse(infoKey + "@", "/" + key + "/info");
// 替换为以下性能更好对流程干扰最小的方式
String totalPath = AbstractParser.getValuePath(type == TYPE_ITEM ? path : parentPath, "/" + key + "/total");
String infoPath = AbstractParser.getValuePath(type == TYPE_ITEM ? path : parentPath, "/" + key + "/info");
response.put("total", onReferenceParse(totalPath));
response.put(totalKey, onReferenceParse(totalPath));
response.put(infoKey, onReferenceParse(infoPath));
}
}