Skip to content

Commit eff8d95

Browse files
committed
Server: 解决已执行 SQL 数量统计错误;解决 DemoFunction 在 Function 表的 version 为 null 时测试不通过;解决 DemoFunction.getFunctionCall 参数 arguments 为 null 时拼接错误;
1 parent 30084d9 commit eff8d95

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

APIJSON-Java-Server/APIJSONBoot/src/main/java/apijson/demo/server/DemoFunction.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public static JSONObject init(boolean shutdownWhenServerError) throws ServerExce
149149
, true
150150
)
151151
.setTag(item.getString(JSONRequest.KEY_TAG))
152-
.setVersion(item.getInteger(JSONRequest.KEY_VERSION))
152+
.setVersion(item.getIntValue(JSONRequest.KEY_VERSION))
153153
.parseResponse(demo);
154154

155155
if (JSONResponse.isSuccess(r) == false) {
@@ -328,10 +328,10 @@ private JSONArray getChildCommentIdList(long tid) {
328328
* @return
329329
* @throws ServerException
330330
*/
331-
public JSONObject getFunctionDemo(@NotNull JSONObject request) throws ServerException {
331+
public JSONObject getFunctionDemo(@NotNull JSONObject request) {
332332
JSONObject demo = JSON.parseObject(request.getString("demo"));
333333
if (demo == null) {
334-
throw new ServerException("服务器内部错误,字段 demo 的值必须为合法且非 null 的 JSONObejct 字符串!");
334+
demo = new JSONObject();
335335
}
336336
if (demo.containsKey("result()") == false) {
337337
demo.put("result()", getFunctionCall(request.getString("name"), request.getString("arguments")));
@@ -353,15 +353,15 @@ public String getFunctionDetail(@NotNull JSONObject request) {
353353
* @return
354354
*/
355355
private static String getFunctionCall(String name, String arguments) {
356-
return name + "(" + arguments + ")";
356+
return name + "(" + StringUtil.getTrimedString(arguments) + ")";
357357
}
358358

359359
/**TODO 仅用来测试 "key-()":"getIdList()" 和 "key()":"getIdList()"
360360
* @param request
361361
* @return JSONArray 只能用JSONArray,用long[]会在SQLConfig解析崩溃
362362
* @throws Exception
363363
*/
364-
public JSONArray getIdList(@NotNull JSONObject request) throws Exception {
364+
public JSONArray getIdList(@NotNull JSONObject request) {
365365
return new JSONArray(new ArrayList<Object>(Arrays.asList(12, 15, 301, 82001, 82002, 38710)));
366366
}
367367

APIJSON-Java-Server/APIJSONORM/src/main/java/zuo/biao/apijson/server/AbstractSQLExecutor.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws
195195
switch (config.getMethod()) {
196196
case HEAD:
197197
case HEADS:
198-
executedSQLCount ++;
199-
200198
rs = executeQuery(config);
199+
200+
executedSQLCount ++;
201201

202202
result = rs.next() ? AbstractParser.newSuccessResult()
203203
: AbstractParser.newErrorResult(new SQLException("数据库错误, rs.next() 失败!"));
@@ -236,9 +236,11 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws
236236
return result;
237237
}
238238

239-
executedSQLCount ++;
240-
241239
rs = executeQuery(config);
240+
241+
if (config.isExplain() == false) { //只有 SELECT 才能 EXPLAIN
242+
executedSQLCount ++;
243+
}
242244
break;
243245

244246
default://OPTIONS, TRACE等

0 commit comments

Comments
 (0)