完善论坛接口

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")
public ForumDataResponse loadData(QueryForum queryForum) {
ForumDto forumDto = forumDao.loadForum(queryForum);
public ForumDataResponse loadData(ForumQuery queryForum) {
ForumDto forumDto = forumDao.loadForumWithId(queryForum);
List<ForumContentVo> forumContents = forumContentDao.find(queryForum);
ForumDataResponse response = new ForumDataResponse(Result.OK, ForumDataResponse.Msg.ok);
response.setForumContentList(forumContents);
response.setForumDto(forumDto);
response.setForum(forumDto);
return response;
}

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

@ -6,12 +6,18 @@ import com.community.pocket.entity.po.Forum;
* 帖子查询条件
*/
public class ForumQuery {
//审核状态
private Forum.ForumStatus status;
private Long currentPage;
//用户名
private String username;
//帖子id
private String forumId;
//帖子类型
private Object[] forumType;
public Object[] getForumType() {
@ -45,4 +51,12 @@ public class ForumQuery {
public void setUsername(String 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 activeScore;
private Integer activeScore;
public String getRegistrationDeadline() {
@ -38,11 +38,11 @@ public class ActiveVo extends ForumVo {
this.activeEndTime = activeEndTime;
}
public String getActiveScore() {
public Integer getActiveScore() {
return activeScore;
}
public void setActiveScore(String activeScore) {
public void setActiveScore(Integer activeScore) {
this.activeScore = activeScore;
}

@ -8,7 +8,7 @@ import java.util.List;
public class ForumDataResponse extends Response<ForumDataResponse.Msg> {
private List<ForumContentVo> forumContentList;
private ForumDto forumDto;
private ForumDto forum;
public ForumDataResponse(Result result, Msg message, Object... args) {
super(result, message, args);
@ -22,12 +22,12 @@ public class ForumDataResponse extends Response<ForumDataResponse.Msg> {
this.forumContentList = forumContentList;
}
public ForumDto getForumDto() {
return forumDto;
public ForumDto getForum() {
return forum;
}
public void setForumDto(ForumDto forumDto) {
this.forumDto = forumDto;
public void setForum(ForumDto forum) {
this.forum = forum;
}
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.ForumContent;
import com.community.pocket.entity.vo.ForumQuery;
import com.community.pocket.entity.vo.android.ForumContentVo;
import com.community.pocket.entity.vo.android.ForumReplyForm;
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.util.LookupOperationUtil;
import com.community.pocket.util.TableName;
@ -30,7 +30,7 @@ public class ForumContentDao extends BaseDao<ForumContent> {
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())));
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.vo.ForumQuery;
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.repository.BaseDao;
import com.community.pocket.util.LookupOperationUtil;
@ -79,8 +82,8 @@ public class ForumDao extends BaseDao<Forum> {
}
//查询帖子
public ForumDto loadForum(QueryForum queryForum) {
Aggregation aggregation = Aggregation.newAggregation(Aggregation.match(Criteria.where(LookupOperationUtil.idKey).is(queryForum.getForumId())), LookupOperationUtil.complainforumLookup, LookupOperationUtil.activeforumLookup, LookupOperationUtil.infoLookup);
public ForumDto loadForumWithId(ForumQuery queryForum) {
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();
}

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

Loading…
Cancel
Save