完善论坛接口

master
panqihua 5 years ago
parent 03bf3cd4e6
commit b36a85ddcf
  1. 6
      src/main/java/com/community/pocket/api/android/ForumController.java
  2. 6
      src/main/java/com/community/pocket/entity/po/android/Active.java
  3. 14
      src/main/java/com/community/pocket/entity/vo/ForumQuery.java
  4. 6
      src/main/java/com/community/pocket/entity/vo/android/ActiveVo.java
  5. 10
      src/main/java/com/community/pocket/entity/vo/android/ForumDataResponse.java
  6. 17
      src/main/java/com/community/pocket/entity/vo/android/QueryForum.java
  7. 4
      src/main/java/com/community/pocket/repository/android/ForumContentDao.java
  8. 9
      src/main/java/com/community/pocket/repository/android/ForumDao.java
  9. 5
      src/test/java/com/community/pocket/DemoApplicationTests.java

@ -196,12 +196,12 @@ public class ForumController {
//获取帖子详情数据 //获取帖子详情数据
@GetMapping("/forum/content") @GetMapping("/forum/content")
public ForumDataResponse loadData(QueryForum queryForum) { public ForumDataResponse loadData(ForumQuery queryForum) {
ForumDto forumDto = forumDao.loadForum(queryForum); ForumDto forumDto = forumDao.loadForumWithId(queryForum);
List<ForumContentVo> forumContents = forumContentDao.find(queryForum); List<ForumContentVo> forumContents = forumContentDao.find(queryForum);
ForumDataResponse response = new ForumDataResponse(Result.OK, ForumDataResponse.Msg.ok); ForumDataResponse response = new ForumDataResponse(Result.OK, ForumDataResponse.Msg.ok);
response.setForumContentList(forumContents); response.setForumContentList(forumContents);
response.setForumDto(forumDto); response.setForum(forumDto);
return response; return response;
} }

@ -14,7 +14,7 @@ public class Active {
//活动结束时间 //活动结束时间
private String activeEndTime; private String activeEndTime;
//活动信用分 //活动信用分
private String activeScore; private Integer activeScore;
public String getId() { public String getId() {
return id; return id;
@ -48,11 +48,11 @@ public class Active {
this.activeEndTime = activeEndTime; this.activeEndTime = activeEndTime;
} }
public String getActiveScore() { public Integer getActiveScore() {
return activeScore; return activeScore;
} }
public void setActiveScore(String activeScore) { public void setActiveScore(Integer activeScore) {
this.activeScore = activeScore; this.activeScore = activeScore;
} }
} }

@ -6,12 +6,18 @@ import com.community.pocket.entity.po.Forum;
* 帖子查询条件 * 帖子查询条件
*/ */
public class ForumQuery { public class ForumQuery {
//审核状态
private Forum.ForumStatus status; private Forum.ForumStatus status;
private Long currentPage; private Long currentPage;
//用户名
private String username; private String username;
//帖子id
private String forumId;
//帖子类型
private Object[] forumType; private Object[] forumType;
public Object[] getForumType() { public Object[] getForumType() {
@ -45,4 +51,12 @@ public class ForumQuery {
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
public String getForumId() {
return forumId;
}
public void setForumId(String forumId) {
this.forumId = forumId;
}
} }

@ -11,7 +11,7 @@ public class ActiveVo extends ForumVo {
//活动结束时间 //活动结束时间
private String activeEndTime; private String activeEndTime;
//活动信用分 //活动信用分
private String activeScore; private Integer activeScore;
public String getRegistrationDeadline() { public String getRegistrationDeadline() {
@ -38,11 +38,11 @@ public class ActiveVo extends ForumVo {
this.activeEndTime = activeEndTime; this.activeEndTime = activeEndTime;
} }
public String getActiveScore() { public Integer getActiveScore() {
return activeScore; return activeScore;
} }
public void setActiveScore(String activeScore) { public void setActiveScore(Integer activeScore) {
this.activeScore = activeScore; this.activeScore = activeScore;
} }

@ -8,7 +8,7 @@ import java.util.List;
public class ForumDataResponse extends Response<ForumDataResponse.Msg> { public class ForumDataResponse extends Response<ForumDataResponse.Msg> {
private List<ForumContentVo> forumContentList; private List<ForumContentVo> forumContentList;
private ForumDto forumDto; private ForumDto forum;
public ForumDataResponse(Result result, Msg message, Object... args) { public ForumDataResponse(Result result, Msg message, Object... args) {
super(result, message, args); super(result, message, args);
@ -22,12 +22,12 @@ public class ForumDataResponse extends Response<ForumDataResponse.Msg> {
this.forumContentList = forumContentList; this.forumContentList = forumContentList;
} }
public ForumDto getForumDto() { public ForumDto getForum() {
return forumDto; return forum;
} }
public void setForumDto(ForumDto forumDto) { public void setForum(ForumDto forum) {
this.forumDto = forumDto; this.forum = forum;
} }
public enum Msg implements CustomMessage { public enum Msg implements CustomMessage {

@ -1,17 +0,0 @@
package com.community.pocket.entity.vo.android;
/**
* 查找帖子
*/
public class QueryForum {
//帖子id
private String forumId;
public String getForumId() {
return forumId;
}
public void setForumId(String forumId) {
this.forumId = forumId;
}
}

@ -2,10 +2,10 @@ package com.community.pocket.repository.android;
import com.community.pocket.entity.po.Forum; import com.community.pocket.entity.po.Forum;
import com.community.pocket.entity.po.ForumContent; import com.community.pocket.entity.po.ForumContent;
import com.community.pocket.entity.vo.ForumQuery;
import com.community.pocket.entity.vo.android.ForumContentVo; import com.community.pocket.entity.vo.android.ForumContentVo;
import com.community.pocket.entity.vo.android.ForumReplyForm; import com.community.pocket.entity.vo.android.ForumReplyForm;
import com.community.pocket.entity.vo.android.ForumVo; import com.community.pocket.entity.vo.android.ForumVo;
import com.community.pocket.entity.vo.android.QueryForum;
import com.community.pocket.repository.BaseDao; import com.community.pocket.repository.BaseDao;
import com.community.pocket.util.LookupOperationUtil; import com.community.pocket.util.LookupOperationUtil;
import com.community.pocket.util.TableName; import com.community.pocket.util.TableName;
@ -30,7 +30,7 @@ public class ForumContentDao extends BaseDao<ForumContent> {
private ForumDao forumDao; private ForumDao forumDao;
//查找帖子详情 //查找帖子详情
public List<ForumContentVo> find(QueryForum queryForum) { public List<ForumContentVo> find(ForumQuery queryForum) {
Aggregation aggregation = Aggregation.newAggregation(LookupOperationUtil.infoLookup, Aggregation.match(Criteria.where("forumId").is(queryForum.getForumId()))); Aggregation aggregation = Aggregation.newAggregation(LookupOperationUtil.infoLookup, Aggregation.match(Criteria.where("forumId").is(queryForum.getForumId())));
return mongoTemplate.aggregate(aggregation, TableName.forumContent, ForumContentVo.class).getMappedResults(); return mongoTemplate.aggregate(aggregation, TableName.forumContent, ForumContentVo.class).getMappedResults();
} }

@ -5,7 +5,10 @@ import com.community.pocket.entity.po.android.Complain;
import com.community.pocket.entity.po.android.MyInfo; import com.community.pocket.entity.po.android.MyInfo;
import com.community.pocket.entity.vo.ForumQuery; import com.community.pocket.entity.vo.ForumQuery;
import com.community.pocket.entity.vo.Page; import com.community.pocket.entity.vo.Page;
import com.community.pocket.entity.vo.android.*; import com.community.pocket.entity.vo.android.ForumDto;
import com.community.pocket.entity.vo.android.ForumHot;
import com.community.pocket.entity.vo.android.ForumReplyForm;
import com.community.pocket.entity.vo.android.ForumVo;
import com.community.pocket.entity.vo.web.ForumCheck; import com.community.pocket.entity.vo.web.ForumCheck;
import com.community.pocket.repository.BaseDao; import com.community.pocket.repository.BaseDao;
import com.community.pocket.util.LookupOperationUtil; import com.community.pocket.util.LookupOperationUtil;
@ -79,8 +82,8 @@ public class ForumDao extends BaseDao<Forum> {
} }
//查询帖子 //查询帖子
public ForumDto loadForum(QueryForum queryForum) { public ForumDto loadForumWithId(ForumQuery queryForum) {
Aggregation aggregation = Aggregation.newAggregation(Aggregation.match(Criteria.where(LookupOperationUtil.idKey).is(queryForum.getForumId())), LookupOperationUtil.complainforumLookup, LookupOperationUtil.activeforumLookup, LookupOperationUtil.infoLookup); Aggregation aggregation = Aggregation.newAggregation(Aggregation.match(Criteria.where(LookupOperationUtil.idKey).is(queryForum.getForumId())), LookupOperationUtil.complainforumLookup, LookupOperationUtil.activeforumLookup, LookupOperationUtil.scoreforumLookup, LookupOperationUtil.infoLookup);
return mongoTemplate.aggregate(aggregation, TableName.forum, ForumDto.class).getUniqueMappedResult(); return mongoTemplate.aggregate(aggregation, TableName.forum, ForumDto.class).getUniqueMappedResult();
} }

@ -163,10 +163,9 @@ class DemoApplicationTests {
@Test @Test
void queryForum() throws Exception { void queryForum() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/api/forum/posts") mockMvc.perform(MockMvcRequestBuilders.get("/api/forum/posts")
.param("status", Forum.ForumStatus.uncheck.name()) .param("status", Forum.ForumStatus.ok.name())
.param("username", "panqihua") .param("username", "panqihua")
.param("currentPage", "1") .param("currentPage", "1")
.param("forumType", Forum.ForumType.active.name(), Forum.ForumType.complan.name())
).andDo(MockMvcResultHandlers.print()).andReturn(); ).andDo(MockMvcResultHandlers.print()).andReturn();
} }
@ -210,7 +209,7 @@ class DemoApplicationTests {
@Test @Test
void queryForumContent() throws Exception { void queryForumContent() throws Exception {
MockHttpServletRequestBuilder builders = MockMvcRequestBuilders.get("/forum/content") MockHttpServletRequestBuilder builders = MockMvcRequestBuilders.get("/forum/content")
.param("forumId", "5e950cae51e7a9796b05c596"); .param("forumId", "5e9bb813f62d4f19ca975ec0");
mockMvc.perform(addToken(builders)) mockMvc.perform(addToken(builders))
.andDo(MockMvcResultHandlers.print()).andReturn(); .andDo(MockMvcResultHandlers.print()).andReturn();
} }

Loading…
Cancel
Save