客户端加载更多帖子提示优化

master
panqihua 5 years ago
parent 74d22d2e5a
commit f5a6ae9164
  1. 15
      src/main/java/com/community/pocket/api/android/ForumController.java
  2. 11
      src/main/java/com/community/pocket/api/web/ForumController.java
  3. 2
      src/main/java/com/community/pocket/entity/vo/ForumNewResponse.java
  4. 2
      src/main/java/com/community/pocket/entity/vo/android/ForumMyResponse.java
  5. 17
      src/test/java/com/community/pocket/DemoApplicationTests.java

@ -154,9 +154,22 @@ public class ForumController {
@GetMapping("/forum/my")
public ForumMyResponse loadForumMy(ForumQuery forumQuery) {
Page<ForumDto> forumList = forumDao.loadForum(forumQuery);
ForumMyResponse response = new ForumMyResponse(Result.OK, ForumMyResponse.Msg.ok);
if (forumList != null) {
ForumMyResponse response;
if (forumList.isEmpty()) {
response = new ForumMyResponse(Result.OK, ForumMyResponse.Msg.ok_empty);
} else {
if (forumList.getCurrentPage() > 1) {
response = new ForumMyResponse(Result.OK, ForumMyResponse.Msg.ok_more);
} else {
response = new ForumMyResponse(Result.OK, ForumMyResponse.Msg.ok);
}
}
response.setForumList(forumList);
return response;
} else {
return new ForumMyResponse(Result.FAIL, ForumMyResponse.Msg.fail);
}
}

@ -33,7 +33,16 @@ public class ForumController {
public ForumNewResponse loadForumNew(ForumQuery forumQuery) {
Page<ForumDto> forumList = forumDao.loadForum(forumQuery);
if (forumList != null) {
ForumNewResponse response = new ForumNewResponse(Result.OK, ForumNewResponse.Msg.ok);
ForumNewResponse response;
if (forumList.isEmpty()) {
response = new ForumNewResponse(Result.OK, ForumNewResponse.Msg.ok_empty);
} else {
if (forumList.getCurrentPage() > 1) {
response = new ForumNewResponse(Result.OK, ForumNewResponse.Msg.ok_more);
} else {
response = new ForumNewResponse(Result.OK, ForumNewResponse.Msg.ok);
}
}
response.setForumList(forumList);
return response;
} else {

@ -24,6 +24,8 @@ public class ForumNewResponse extends Response<ForumNewResponse.Msg> {
public enum Msg implements CustomMessage {
ok,
ok_empty,
ok_more,
fail
}
}

@ -24,6 +24,8 @@ public class ForumMyResponse extends Response<ForumMyResponse.Msg> {
public enum Msg implements CustomMessage {
ok,
ok_empty,
ok_more,
fail,
token
}

@ -133,8 +133,6 @@ class DemoApplicationTests {
.param("activeScore", "15")
.param("title", "666")
.param("content", "fuckfuckfuckfuckfuck")
.param("username", "panqihua")
.param("token", "b6a518fffa3ffa607e756324474e9484")
).andDo(MockMvcResultHandlers.print()).andReturn();
}
@ -145,28 +143,27 @@ class DemoApplicationTests {
.param("complain", "panqihua")
.param("title", "666")
.param("content", "fuckfuckfuckfuckfuck")
.param("token", "b6a518fffa3ffa607e756324474e9484")
.param("username", "panqihua")
).andDo(MockMvcResultHandlers.print()).andReturn();
}
//测试发送动态
@Test
void testTopic() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.post("/forum/sendTopic")
.param("title", "666")
for (int i = 0; i < 20; i++) {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.post("/forum/sendTopic")
.param("title", "title" + i)
.param("content", "fuckfuckfuckfuckfuck")
.param("token", "b6a518fffa3ffa607e756324474e9484")
.param("username", "panqihua")
.param("forumType", "topic");
mockMvc.perform(addToken(builder)
).andDo(MockMvcResultHandlers.print()).andReturn();
}
}
//测试查询帖子
@Test
void queryForum() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/api/forum/posts")
.param("status", Forum.ForumStatus.ok.name())
.param("username", "panqihua")
.param("currentPage", "1")
).andDo(MockMvcResultHandlers.print()).andReturn();
}
@ -201,7 +198,6 @@ class DemoApplicationTests {
void queryVisitor() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/visitor/reservation")
.param("username", "panqihua")
.param("token", "e3c8ed5a74841556c57de6e17b166f68")
.param("startDate", "2020/04/18")
.param("endDate", "2020/04/19"))
.andDo(MockMvcResultHandlers.print()).andReturn();
@ -255,4 +251,5 @@ class DemoApplicationTests {
visitorDao.save(visitorForm);
}
}
}

Loading…
Cancel
Save