Skip to content

Commit fd80bb9

Browse files
committed
Server:新增默认的数组查询数量,初始值为10
1 parent b65bb4f commit fd80bb9

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

APIJSON-Java-Server/APIJSONDemo/src/main/java/apijson/demo/server/DemoSQLConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import zuo.biao.apijson.server.AbstractSQLConfig;
2626
import zuo.biao.apijson.server.Join;
2727
import zuo.biao.apijson.server.SQLConfig;
28-
import zuo.biao.apijson.server.Subquery;
2928

3029

3130
/**SQL配置

APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson/server/AbstractParser.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,10 +682,11 @@ public JSONArray onArrayParse(JSONObject request, String parentPath, String name
682682
return null;
683683
}
684684
String path = getAbsPath(parentPath, name);
685-
685+
686+
686687
//不能改变,因为后面可能继续用到,导致1以上都改变 []:{0:{Comment[]:{0:{Comment:{}},1:{...},...}},1:{...},...}
687688
final int query = request.getIntValue(JSONRequest.KEY_QUERY);
688-
final int count = request.getIntValue(JSONRequest.KEY_COUNT);
689+
final Integer count = request.getInteger(JSONRequest.KEY_COUNT);
689690
final int page = request.getIntValue(JSONRequest.KEY_PAGE);
690691
final String join = request.getString(JSONRequest.KEY_JOIN);
691692
request.remove(JSONRequest.KEY_QUERY);
@@ -701,8 +702,9 @@ public JSONArray onArrayParse(JSONObject request, String parentPath, String name
701702

702703

703704
//不用total限制数量了,只用中断机制,total只在query = 1,2的时候才获取
704-
int max = isSubquery ? count : getMaxQueryCount();
705-
int size = count <= 0 || count > max ? max : count;//count为每页数量,size为第page页实际数量,max(size) = count
705+
int count2 = isSubquery || count != null ? (count == null ? 0 : count) : getDefaultQueryCount();
706+
int max = isSubquery ? count2 : getMaxQueryCount();
707+
int size = count2 <= 0 || count2 > max ? max : count2;//count为每页数量,size为第page页实际数量,max(size) = count
706708
Log.d(TAG, "getArray size = " + size + "; page = " + page);
707709

708710

@@ -940,6 +942,10 @@ private JSONObject getJoinObject(String table, JSONObject obj, String key) {
940942
return requestObj;
941943
}
942944

945+
@Override
946+
public int getDefaultQueryCount() {
947+
return DEFAULT_QUERY_COUNT;
948+
}
943949
@Override
944950
public int getMaxQueryCount() {
945951
return MAX_QUERY_COUNT;

APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson/server/Parser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626
public interface Parser<T> {
2727

28+
int DEFAULT_QUERY_COUNT = 10;
2829
int MAX_QUERY_COUNT = 100;
2930
int MAX_UPDATE_COUNT = 10;
3031

@@ -96,6 +97,7 @@ public interface Parser<T> {
9697

9798
ObjectParser createObjectParser(JSONObject request, String parentPath, String name, SQLConfig arrayConfig, boolean isSubquery) throws Exception;
9899

100+
int getDefaultQueryCount();
99101
int getMaxQueryCount();
100102
int getMaxUpdateCount();
101103

0 commit comments

Comments
 (0)