Skip to content

Commit fedcfa9

Browse files
committed
Server:优化Controller注释;Client:优化Test中CodeUtil代码
1 parent 881bde6 commit fedcfa9

File tree

2 files changed

+12
-12
lines changed
  • APIJSON-Android/APIJSON-ADT/APIJSONTest/src/apijson/demo/ui
  • APIJSON-Java-Server/APIJSON-Eclipse/src/main/java/apijson/demo/server

2 files changed

+12
-12
lines changed

APIJSON-Android/APIJSON-ADT/APIJSONTest/src/apijson/demo/ui/CodeUtil.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ public static String parse(final String name, final JSONObject request) {
4343
if (set != null) {
4444

4545
Object value;
46-
String pairKey;
4746
for (String key : set) {
4847
value = request.get(key);
4948
if (value == null) {
5049
continue;
5150
}
5251

53-
pairKey = new String(key instanceof String ? "\"" + key + "\"" : key);
5452
if (value instanceof JSONObject) {//APIJSON Array转为常规JSONArray
5553
if (isArrayKey(key)) {//APIJSON Array转为常规JSONArray
5654
response += NEWLINE + NEWLINE + "//" + key + "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<";
@@ -65,22 +63,25 @@ public static String parse(final String name, final JSONObject request) {
6563

6664
String prefix = key.substring(0, key.length() - 2);
6765
response += NEWLINE + NEWLINE
68-
+ parentKey + ".add(" + getItemKey(key) + ".toArray("
66+
+ parentKey + ".putAll(" + getItemKey(key) + ".toArray("
6967
+ count + ", " + page + (prefix.isEmpty() ? "" : ", \"" + prefix + "\"") + "));";
7068

7169
response += NEWLINE + "//" + key + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + NEWLINE;
72-
} else {//常规JSONObject,往下一级提取
70+
}
71+
else {//常规JSONObject,往下一级提取
7372
response += NEWLINE + NEWLINE + "//" + key + "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<";
7473

7574
response += parse(key, (JSONObject) value);
7675

77-
response += NEWLINE + NEWLINE + parentKey + ".put(" + pairKey + ", " + getTableKey(key) + ");";
76+
response += NEWLINE + NEWLINE + parentKey + ".put(\"" + key + "\", " + getTableKey(key) + ");";
7877
response += NEWLINE + "//" + key + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + NEWLINE;
7978
}
80-
} else {//其它Object,直接填充
79+
}
80+
else {//其它Object,直接填充
8181
if (value instanceof String) {
8282
value = "\"" + value + "\"";
83-
} else if (value instanceof JSONArray) {
83+
}
84+
else if (value instanceof JSONArray) {
8485
String s = StringUtil.getString(value);
8586
if (s.startsWith("[")) {
8687
s = s.substring(1);
@@ -93,7 +94,7 @@ public static String parse(final String name, final JSONObject request) {
9394
value = "new Object[]{" + s + "}";//反射获取泛型太麻烦,反正开发中还要改的
9495
}
9596

96-
response += NEWLINE + parentKey + ".put(" + pairKey + ", " + value + ");";
97+
response += NEWLINE + parentKey + ".put(\"" + key + "\", " + value + ");";
9798
}
9899
}
99100
}

APIJSON-Java-Server/APIJSON-Eclipse/src/main/java/apijson/demo/server/Controller.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public String delete(@RequestBody String request, HttpSession session) {
253253

254254

255255
/**生成验证码,修改为post请求
256-
* @param phone
256+
* @param request
257257
* @return
258258
*/
259259
@RequestMapping(value = "post/verify", method = org.springframework.web.bind.annotation.RequestMethod.POST)
@@ -290,7 +290,7 @@ public JSONObject postVerify(@RequestBody String request) {
290290
}
291291

292292
/**获取验证码
293-
* @param phone
293+
* @param request
294294
* @return
295295
*/
296296
@RequestMapping(value = "post_get/verify", method = org.springframework.web.bind.annotation.RequestMethod.POST)
@@ -307,8 +307,7 @@ public JSONObject getVerify(@RequestBody String request) {
307307
}
308308

309309
/**校验验证码
310-
* @param phone
311-
* @param code
310+
* @param request
312311
* @return
313312
*/
314313
@RequestMapping(value = "post_head/verify", method = org.springframework.web.bind.annotation.RequestMethod.POST)

0 commit comments

Comments
 (0)