Skip to content

Commit ed7a9e8

Browse files
committed
Server: Java Demo新增删除动态下所有评论的远程函数
1 parent 1c3940b commit ed7a9e8

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

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

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,39 @@ public Object verifyURLList(@NotNull JSONObject request, @NotNull String urlList
194194
}
195195
return null;
196196
}
197+
198+
199+
/**
200+
* @param rq
201+
* @param momentId
202+
* @return
203+
* @throws Exception
204+
*/
205+
public int deleteCommentOfMoment(@NotNull JSONObject rq, @NotNull String momentId) throws Exception {
206+
long mid = rq.getLongValue(momentId);
207+
if (mid <= 0 || rq.getIntValue(JSONResponse.KEY_COUNT) <= 0) {
208+
return 0;
209+
}
197210

198-
/**判断array是否为空
199-
* @param request
200-
* @param array
211+
JSONRequest request = new JSONRequest();
212+
213+
//Comment<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
214+
JSONRequest comment = new JSONRequest();
215+
comment.put("momentId", mid);
216+
217+
request.put("Comment", comment);
218+
//Comment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
219+
220+
JSONObject rp = new DemoParser(RequestMethod.DELETE).setNoVerify(true).parseResponse(request);
221+
222+
JSONObject c = rp.getJSONObject("Comment");
223+
return c == null ? 0 : c.getIntValue(JSONResponse.KEY_COUNT);
224+
}
225+
226+
227+
/**删除评论的子评论
228+
* @param rq
229+
* @param toId
201230
* @return
202231
*/
203232
public int deleteChildComment(@NotNull JSONObject rq, @NotNull String toId) throws Exception {
@@ -213,8 +242,8 @@ public int deleteChildComment(@NotNull JSONObject rq, @NotNull String toId) thro
213242
//Comment<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
214243
JSONRequest comment = new JSONRequest();
215244
comment.put("id{}", getChildCommentIdList(tid));
216-
request.put("Comment", comment);
217245

246+
request.put("Comment", comment);
218247
//Comment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
219248

220249
JSONObject rp = new DemoParser(RequestMethod.DELETE).setNoVerify(true).parseResponse(request);

0 commit comments

Comments
 (0)