Skip to content

Commit 0dfed3a

Browse files
committed
Function 和 Request 表在非 Log.DEBUG 时仅加载和使用 debug=0 的配置
1 parent 0400037 commit 0dfed3a

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/main/java/apijson/framework/APIJSONConstant.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* @author Lemon
3939
*/
4040
public class APIJSONConstant {
41+
public static String KEY_DEBUG = "debug";
4142

4243
public static final String DEFAULTS = "defaults";
4344
public static final String USER_ = "User";

src/main/java/apijson/framework/APIJSONFunctionParser.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ public static <T extends Object> JSONObject init(boolean shutdownWhenServerError
146146
boolean isAll = table == null || table.isEmpty();
147147

148148
JSONObject function = isAll ? new JSONRequest() : table;
149+
if (Log.DEBUG == false) {
150+
function.put(APIJSONConstant.KEY_DEBUG, 0);
151+
}
152+
149153
JSONRequest functionItem = new JSONRequest();
150154
functionItem.put(FUNCTION_, function);
151155

src/main/java/apijson/framework/APIJSONVerifier.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public static <T> JSONObject initAccess(boolean shutdownWhenServerError, APIJSON
153153

154154
JSONObject access = isAll ? new JSONRequest() : table;
155155
if (Log.DEBUG == false) {
156-
access.put("debug", 0);
156+
access.put(APIJSONConstant.KEY_DEBUG, 0);
157157
}
158158
JSONRequest accessItem = new JSONRequest();
159159
accessItem.put(ACCESS_, access);
@@ -288,9 +288,13 @@ public static <T> JSONObject initRequest(boolean shutdownWhenServerError, APIJSO
288288

289289

290290
boolean isAll = table == null || table.isEmpty();
291+
JSONObject requestTable = isAll ? new JSONRequest().setOrder("version-,id+") : table;
292+
if (Log.DEBUG == false) {
293+
requestTable.put(APIJSONConstant.KEY_DEBUG, 0);
294+
}
291295

292296
JSONRequest requestItem = new JSONRequest();
293-
requestItem.put(REQUEST_, isAll ? new JSONRequest().setOrder("version-,id+") : table); // 方便查找
297+
requestItem.put(REQUEST_, requestTable); // 方便查找
294298

295299
JSONRequest request = new JSONRequest();
296300
request.putAll(requestItem.toArray(0, 0, REQUEST_));

0 commit comments

Comments
 (0)