key[]:{ query:2 或 query:"All" } 解决列表数据为空不返回列表分页信息

This commit is contained in:
TommyLemon 2024-06-16 23:02:39 +08:00
parent 09a60dc891
commit 0093589068

View File

@ -560,7 +560,7 @@ public abstract class AbstractObjectParser<T extends Object> implements ObjectPa
child = parser.onArrayParse(value, path, key, isSubquery);
isEmpty = child == null || ((JSONArray) child).isEmpty();
if (isEmpty == false && ("2".equals(query) || "ALL".equals(query))) {
if ("2".equals(query) || "ALL".equals(query)) { // 不判断 isEmpty因为分页数据可能只是某页没有
String totalKey = JSONResponse.formatArrayKey(key) + "Total";
String infoKey = JSONResponse.formatArrayKey(key) + "Info";
if ((request.containsKey(totalKey) || request.containsKey(infoKey)
@ -568,8 +568,10 @@ public abstract class AbstractObjectParser<T extends Object> implements ObjectPa
// 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");
String keyPath = AbstractParser.getValuePath(type == TYPE_ITEM ? path : parentPath, "/" + key);
String totalPath = keyPath + "/total";
String infoPath = keyPath + "/info";
response.put(totalKey, onReferenceParse(totalPath));
response.put(infoKey, onReferenceParse(infoPath));
}