Skip to content

Commit 477ce8a

Browse files
committed
Server:format格式化Response仅在成功时才生效;优化代码
1 parent 27ab1ea commit 477ce8a

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ public Object put(String key, Object value) {
403403
return null;
404404
}
405405
if (StringUtil.isEmpty(key, true)) {
406-
Class<?> clazz = value.getClass();
407-
if (clazz == null || clazz.getAnnotation(MethodAccess.class) == null) {
408-
throw new IllegalArgumentException("puts StringUtil.isNotEmpty(key, true) == false" +
406+
Class<?> clazz = value.getClass(); //should not return null
407+
if (clazz.getAnnotation(MethodAccess.class) == null) {
408+
throw new IllegalArgumentException("puts StringUtil.isEmpty(key, true)" +
409409
" && clazz == null || clazz.getAnnotation(MethodAccess.class) == null" +
410410
" \n key为空时仅支持 类型被@MethodAccess注解 的value !!!" +
411411
" \n 如果一定要这么用,请对 " + clazz.getName() + " 注解!" +

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public static boolean isSuccess(JSONResponse response) {
167167
* @return
168168
*/
169169
public static boolean isSuccess(JSONObject response) {
170-
return isSuccess(response.getIntValue(KEY_CODE));
170+
return response != null && isSuccess(response.getIntValue(KEY_CODE));
171171
}
172172

173173
/**校验服务端是否存在table

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public JSONObject parseResponse(JSONObject request) {
315315
Log.d(TAG, "parseResponse endTime = " + endTime + "; duration = " + (endTime - startTime)
316316
+ ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n");
317317

318-
return globleFormat ? new JSONResponse(requestObject) : requestObject;
318+
return globleFormat && JSONResponse.isSuccess(requestObject) ? new JSONResponse(requestObject) : requestObject;
319319
}
320320

321321

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ public JSONObject execute(SQLConfig config) throws Exception {
126126

127127
config.setPrepared(prepared);
128128

129-
if (StringUtil.isNotEmpty(sql, true) == false) {
130-
Log.e(TAG, "select StringUtil.isNotEmpty(sql, true) == false >> return null;");
129+
if (StringUtil.isEmpty(sql, true)) {
130+
Log.e(TAG, "select StringUtil.isEmpty(sql, true) >> return null;");
131131
return null;
132132
}
133133
JSONObject result = null;

0 commit comments

Comments
 (0)