| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6e9affe commit a46e24e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -807,8 +807,7 @@ public void onTableArrayParse(String key, L valueArray) throws Exception { | |||
| 807 | 807 | } | |
| 808 | 808 | ||
| 809 | 809 | Object id = item.get(idKey); | |
| 810 | - M req = JSON.createJSONObject(); | ||
| 811 | - req.put(childKey, item); | ||
| 810 | + M req = JSON.createJSONObject(childKey, item); | ||
| 812 | 811 | ||
| 813 | 812 | M result = null; | |
| 814 | 813 | try { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,7 @@ | |||
| 29 | 29 | ||
| 30 | 30 | import static apijson.JSON.*; | |
| 31 | 31 | import static apijson.JSONMap.*; | |
| 32 | - import static apijson.JSONRequest.KEY_TAG; | ||
| 32 | + import static apijson.JSONRequest.*; | ||
| 33 | 33 | import static apijson.RequestMethod.CRUD; | |
| 34 | 34 | import static apijson.RequestMethod.GET; | |
| 35 | 35 | ||
@@ -475,7 +475,7 @@ public M parseResponse(String request) { | |||
| 475 | 475 | + requestMethod + "/parseResponse request = \n" + request + "\n\n"); | |
| 476 | 476 | ||
| 477 | 477 | try { | |
| 478 | - requestObject = (M) JSON.parseObject(request); | ||
| 478 | + requestObject = JSON.parseObject(request); | ||
| 479 | 479 | if (requestObject == null) { | |
| 480 | 480 | throw new UnsupportedEncodingException("JSON格式不合法!"); | |
| 481 | 481 | } | |
@@ -502,8 +502,15 @@ public M parseResponse(M request) { | |||
| 502 | 502 | ||
| 503 | 503 | requestObject = request; | |
| 504 | 504 | try { | |
| 505 | - setVersion(getIntValue(requestObject, apijson.JSONRequest.KEY_VERSION)); | ||
| 506 | - requestObject.remove(apijson.JSONRequest.KEY_VERSION); | ||
| 505 | + setGlobalFormat(getBoolean(requestObject, KEY_FORMAT)); | ||
| 506 | + requestObject.remove(KEY_FORMAT); | ||
| 507 | + } catch (Exception e) { | ||
| 508 | + return extendErrorResult(requestObject, e, requestMethod, getRequestURL(), isRoot); | ||
| 509 | + } | ||
| 510 | + | ||
| 511 | + try { | ||
| 512 | + setVersion(getIntValue(requestObject, KEY_VERSION)); | ||
| 513 | + requestObject.remove(KEY_VERSION); | ||
| 507 | 514 | ||
| 508 | 515 | if (getMethod() != RequestMethod.CRUD) { | |
| 509 | 516 | setTag(getString(requestObject, KEY_TAG)); | |
@@ -547,7 +554,6 @@ public M parseResponse(M request) { | |||
| 547 | 554 | ||
| 548 | 555 | setGlobalExplain(getBoolean(requestObject, KEY_EXPLAIN)); | |
| 549 | 556 | setGlobalCache(getString(requestObject, KEY_CACHE)); | |
| 550 | - setGlobalFormat(getBoolean(requestObject, apijson.JSONRequest.KEY_FORMAT)); | ||
| 551 | 557 | ||
| 552 | 558 | requestObject.remove(KEY_DATABASE); | |
| 553 | 559 | requestObject.remove(KEY_DATASOURCE); | |
@@ -557,7 +563,6 @@ public M parseResponse(M request) { | |||
| 557 | 563 | ||
| 558 | 564 | requestObject.remove(KEY_EXPLAIN); | |
| 559 | 565 | requestObject.remove(KEY_CACHE); | |
| 560 | - requestObject.remove(apijson.JSONRequest.KEY_FORMAT); | ||
| 561 | 566 | } catch (Exception e) { | |
| 562 | 567 | return extendErrorResult(requestObject, e, requestMethod, getRequestURL(), isRoot); | |
| 563 | 568 | } | |
@@ -995,7 +1000,7 @@ public M newErrorResult(Exception e, boolean isRoot) { | |||
| 995 | 1000 | // } | |
| 996 | 1001 | ||
| 997 | 1002 | String msg = CommonException.getMsg(e); | |
| 998 | - Integer code = CommonException.getCode(e); | ||
| 1003 | + int code = CommonException.getCode(e); | ||
| 999 | 1004 | ||
| 1000 | 1005 | return newResult(code, msg, null, isRoot); | |
| 1001 | 1006 | } | |
@@ -1081,10 +1086,10 @@ public M getStructure(@NotNull String table, String method, String tag, int vers | |||
| 1081 | 1086 | where.put(KEY_TAG, tag); | |
| 1082 | 1087 | ||
| 1083 | 1088 | if (version > 0) { | |
| 1084 | - where.put(apijson.JSONRequest.KEY_VERSION + ">=", version); | ||
| 1089 | + where.put(KEY_VERSION + ">=", version); | ||
| 1085 | 1090 | } | |
| 1086 | 1091 | config.setWhere(where); | |
| 1087 | - config.setOrder(apijson.JSONRequest.KEY_VERSION + (version > 0 ? "+" : "-")); | ||
| 1092 | + config.setOrder(KEY_VERSION + (version > 0 ? "+" : "-")); | ||
| 1088 | 1093 | config.setCount(1); | |
| 1089 | 1094 | ||
| 1090 | 1095 | // too many connections error: 不try-catch,可以让客户端看到是服务器内部异常 | |
@@ -2335,7 +2340,7 @@ protected M batchVerify(RequestMethod method, String tag, int version, String na | |||
| 2335 | 2340 | case KEY_DATASOURCE: | |
| 2336 | 2341 | case KEY_SCHEMA: | |
| 2337 | 2342 | case KEY_DATABASE: | |
| 2338 | - case apijson.JSONRequest.KEY_VERSION: | ||
| 2343 | + case KEY_VERSION: | ||
| 2339 | 2344 | case KEY_ROLE: | |
| 2340 | 2345 | objAttrMap.put(objAttrKey, entry.getValue()); | |
| 2341 | 2346 | break; | |
@@ -2385,15 +2390,15 @@ protected M batchVerify(RequestMethod method, String tag, int version, String na | |||
| 2385 | 2390 | setRequestAttribute(key, true, KEY_DATASOURCE, request); | |
| 2386 | 2391 | setRequestAttribute(key, true, KEY_SCHEMA, request); | |
| 2387 | 2392 | setRequestAttribute(key, true, KEY_DATABASE, request); | |
| 2388 | - setRequestAttribute(key, true, apijson.JSONRequest.KEY_VERSION, request); | ||
| 2393 | + setRequestAttribute(key, true, KEY_VERSION, request); | ||
| 2389 | 2394 | setRequestAttribute(key, true, KEY_ROLE, request); | |
| 2390 | 2395 | } | |
| 2391 | 2396 | } else { | |
| 2392 | 2397 | setRequestAttribute(key, false, KEY_METHOD, request); | |
| 2393 | 2398 | setRequestAttribute(key, false, KEY_DATASOURCE, request); | |
| 2394 | 2399 | setRequestAttribute(key, false, KEY_SCHEMA, request); | |
| 2395 | 2400 | setRequestAttribute(key, false, KEY_DATABASE, request); | |
| 2396 | - setRequestAttribute(key, false, apijson.JSONRequest.KEY_VERSION, request); | ||
| 2401 | + setRequestAttribute(key, false, KEY_VERSION, request); | ||
| 2397 | 2402 | setRequestAttribute(key, false, KEY_ROLE, request); | |
| 2398 | 2403 | } | |
| 2399 | 2404 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments