diff --git a/src/main/java/com/community/pocket/api/android/ForumController.java b/src/main/java/com/community/pocket/api/android/AndroidForumController.java similarity index 59% rename from src/main/java/com/community/pocket/api/android/ForumController.java rename to src/main/java/com/community/pocket/api/android/AndroidForumController.java index b545f38..8d4368e 100644 --- a/src/main/java/com/community/pocket/api/android/ForumController.java +++ b/src/main/java/com/community/pocket/api/android/AndroidForumController.java @@ -5,12 +5,15 @@ import com.community.pocket.entity.po.ForumContent; import com.community.pocket.entity.po.android.Active; import com.community.pocket.entity.po.android.Complain; import com.community.pocket.entity.po.android.Token; -import com.community.pocket.entity.vo.NoticeVo; +import com.community.pocket.entity.vo.ForumQuery; +import com.community.pocket.entity.vo.Page; import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.android.*; import com.community.pocket.repository.android.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; import java.util.List; @@ -19,10 +22,7 @@ import java.util.List; */ //客户端跨域测试 @RestController -public class ForumController { - - @Autowired - private NoticeDao noticeDao; +public class AndroidForumController { @Autowired private ForumDao forumDao; @@ -42,46 +42,6 @@ public class ForumController { @Autowired private ComplainDao complainDao; - //加载公告接口 - @CrossOrigin("http://localhost:4200") - @GetMapping({"/api/forum/notices", "/forum/notice"}) - public ForumNoticeResponse loadNotices() { - List noticeList = noticeDao.loadNotices(); - if (noticeList != null) { - ForumNoticeResponse response = new ForumNoticeResponse(Result.OK, ForumNoticeResponse.Msg.ok); - response.setNoticeList(noticeList); - return response; - } else { - return new ForumNoticeResponse(Result.FAIL, ForumNoticeResponse.Msg.fail); - } - } - - /** - * 添加公告 - */ - @CrossOrigin("http://localhost:4200") - @PostMapping("/api/forum/notice/add") - public ForumNoticeResponse addNotices(@RequestBody NoticeVo noticeForm) { - if (noticeDao.save(noticeForm) != null) { - return new ForumNoticeResponse(Result.OK, ForumNoticeResponse.Msg.ok); - } else { - return new ForumNoticeResponse(Result.FAIL, ForumNoticeResponse.Msg.fail); - } - } - - /** - * 删除公告 - */ - @CrossOrigin("http://localhost:4200") - @PostMapping("/api/forum/notice/delete") - public ForumNoticeResponse deleteNotices(@RequestBody NoticeVo noticeVo) { - if (noticeDao.deleteNotice(noticeVo)) { - return new ForumNoticeResponse(Result.OK, ForumNoticeResponse.Msg.delete_ok); - } else { - return new ForumNoticeResponse(Result.FAIL, ForumNoticeResponse.Msg.delete_fail); - } - } - //加载热榜接口 @GetMapping("/forum/hot") public ForumHotResponse loadHot(Integer num) { @@ -99,27 +59,14 @@ public class ForumController { return response; } - //加载最新帖子 - @GetMapping("/forum/new") - public ForumNewResponse loadForumNew() { - List forumList = forumDao.loadNewForum(); - if (forumList != null) { - ForumNewResponse response = new ForumNewResponse(Result.OK, ForumNewResponse.Msg.ok); - response.setForumList(forumList); - return response; - } else { - return new ForumNewResponse(Result.FAIL, ForumNewResponse.Msg.fail); - } - } - //发送活动贴 @PostMapping("/forum/sendActive") - public ForumPostResponse sendActive(ActiveForm activeForm) { - if (tokenDao.checkToken(activeForm)) { - Forum forum = forumDao.save(activeForm); + public ForumPostResponse sendActive(ActiveVo activeVo) { + if (tokenDao.checkToken(activeVo)) { + Forum forum = forumDao.save(activeVo); if (forum != null) { - ForumContent forumContent = forumContentDao.save(activeForm, forum); - Active active = activeDao.save(activeForm, forum); + ForumContent forumContent = forumContentDao.save(activeVo, forum); + Active active = activeDao.save(activeVo, forum); if (forumContent != null && active != null) { return new ForumPostResponse(Result.OK, ForumPostResponse.Msg.ok); } @@ -132,11 +79,11 @@ public class ForumController { //发送动态贴 @PostMapping("/forum/sendTopic") - public ForumPostResponse sendTopic(ForumForm forumForm) { - if (tokenDao.checkToken(forumForm)) { - Forum forum = forumDao.save(forumForm); + public ForumPostResponse sendTopic(ForumVo forumVo) { + if (tokenDao.checkToken(forumVo)) { + Forum forum = forumDao.save(forumVo); if (forum != null) { - ForumContent forumContent = forumContentDao.save(forumForm, forum); + ForumContent forumContent = forumContentDao.save(forumVo, forum); if (forumContent != null) { return new ForumPostResponse(Result.OK, ForumPostResponse.Msg.ok); } @@ -149,12 +96,12 @@ public class ForumController { //发送投诉贴 @PostMapping("/forum/sendComplain") - public ForumPostResponse sendComplain(ComplainForm complainForm) { - if (tokenDao.checkToken(complainForm)) { - Forum forum = forumDao.save(complainForm); + public ForumPostResponse sendComplain(ComplainVo complainVo) { + if (tokenDao.checkToken(complainVo)) { + Forum forum = forumDao.save(complainVo); if (forum != null) { - ForumContent forumContent = forumContentDao.save(complainForm, forum); - Complain complain = complainDao.save(complainForm, forum); + ForumContent forumContent = forumContentDao.save(complainVo, forum); + Complain complain = complainDao.save(complainVo, forum); if (forumContent != null && complain != null) { return new ForumPostResponse(Result.OK, ForumPostResponse.Msg.ok); } @@ -169,15 +116,12 @@ public class ForumController { * 加载我的帖子 */ @GetMapping("/forum/my") - public ForumMyResponse loadForumMy(Token token) { - if (tokenDao.checkToken(token)) { - List forumList = forumDao.loadMyForum(token.getUsername()); - ForumMyResponse response = new ForumMyResponse(Result.OK, ForumMyResponse.Msg.ok); - response.setForumList(forumList); - return response; - } else { - return new ForumMyResponse(Result.FAIL, ForumMyResponse.Msg.token); - } + public ForumMyResponse loadForumMy(ForumQuery forumQuery) { + Page forumList = forumDao.loadForum(forumQuery); + ForumMyResponse response = new ForumMyResponse(Result.OK, ForumMyResponse.Msg.ok); + response.setForumList(forumList); + return response; + } //获取个人信息 diff --git a/src/main/java/com/community/pocket/api/web/WebForumController.java b/src/main/java/com/community/pocket/api/web/WebForumController.java new file mode 100644 index 0000000..6dad22f --- /dev/null +++ b/src/main/java/com/community/pocket/api/web/WebForumController.java @@ -0,0 +1,89 @@ +package com.community.pocket.api.web; + +import com.community.pocket.entity.vo.*; +import com.community.pocket.entity.vo.android.ForumDto; +import com.community.pocket.entity.vo.web.ForumCheck; +import com.community.pocket.entity.vo.web.ForumCheckResponse; +import com.community.pocket.repository.android.ForumDao; +import com.community.pocket.repository.android.NoticeDao; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * web和android端共用论坛接口 + */ +@CrossOrigin("http://localhost:4200") +@RestController +public class WebForumController { + + + @Autowired + private NoticeDao noticeDao; + + @Autowired + private ForumDao forumDao; + + //加载最新帖子 + @GetMapping({"/api/forum/posts", "/forum/new"}) + public ForumNewResponse loadForumNew(ForumQuery forumQuery) { + Page forumList = forumDao.loadForum(forumQuery); + if (forumList != null) { + ForumNewResponse response = new ForumNewResponse(Result.OK, ForumNewResponse.Msg.ok); + response.setForumList(forumList); + return response; + } else { + return new ForumNewResponse(Result.FAIL, ForumNewResponse.Msg.fail); + } + } + + + /** + * 删除公告 + */ + @PostMapping("/api/forum/notice/delete") + public ForumNoticeResponse deleteNotices(@RequestBody NoticeVo noticeVo) { + if (noticeDao.deleteNotice(noticeVo)) { + return new ForumNoticeResponse(Result.OK, ForumNoticeResponse.Msg.delete_ok); + } else { + return new ForumNoticeResponse(Result.FAIL, ForumNoticeResponse.Msg.delete_fail); + } + } + + + /** + * 添加公告 + */ + @PostMapping("/api/forum/notice/add") + public ForumNoticeResponse addNotices(@RequestBody NoticeVo noticeForm) { + if (noticeDao.save(noticeForm) != null) { + return new ForumNoticeResponse(Result.OK, ForumNoticeResponse.Msg.add_ok); + } else { + return new ForumNoticeResponse(Result.FAIL, ForumNoticeResponse.Msg.add_fail); + } + } + + @PostMapping("/api/forum/posts/check") + public ForumCheckResponse check(@RequestBody ForumCheck forumCheck) { + if (forumDao.check(forumCheck)) { + return new ForumCheckResponse(Result.OK, ForumCheckResponse.Msg.check_ok); + } else { + return new ForumCheckResponse(Result.FAIL, ForumCheckResponse.Msg.check_fail); + } + } + + //加载公告接口 + @GetMapping({"/api/forum/notices", "/forum/notice"}) + public ForumNoticeResponse loadNotices() { + List noticeList = noticeDao.loadNotices(); + if (noticeList != null) { + ForumNoticeResponse response = new ForumNoticeResponse(Result.OK, ForumNoticeResponse.Msg.ok); + response.setNoticeList(noticeList); + return response; + } else { + return new ForumNoticeResponse(Result.FAIL, ForumNoticeResponse.Msg.fail); + } + } + +} diff --git a/src/main/java/com/community/pocket/entity/po/Forum.java b/src/main/java/com/community/pocket/entity/po/Forum.java index 95bee72..83bc0eb 100644 --- a/src/main/java/com/community/pocket/entity/po/Forum.java +++ b/src/main/java/com/community/pocket/entity/po/Forum.java @@ -2,14 +2,13 @@ package com.community.pocket.entity.po; import com.community.pocket.entity.po.android.MyInfo; import com.community.pocket.util.TableName; -import org.bson.types.ObjectId; import org.springframework.data.mongodb.core.mapping.Document; //论坛贴 @Document(TableName.forum) public class Forum { - private ObjectId id; + private String id; //发帖时间 private Long time; //帖子标题 @@ -20,12 +19,24 @@ public class Forum { private ForumType forumType; //缩略内容 private String content; + //审核状态 + private ForumStatus status; + + /** + * 审核状态 + */ + public enum ForumStatus { + uncheck, + ok, + fail + } private MyInfo myInfo; + /** * 帖子类型 */ - public enum ForumType{ + public enum ForumType { active, topic, complan @@ -90,11 +101,19 @@ public class Forum { this.content = content; } - public ObjectId getId() { + public String getId() { return id; } - public void setId(ObjectId id) { + public void setId(String id) { this.id = id; } + + public ForumStatus getStatus() { + return status; + } + + public void setStatus(ForumStatus status) { + this.status = status; + } } diff --git a/src/main/java/com/community/pocket/entity/po/ForumContent.java b/src/main/java/com/community/pocket/entity/po/ForumContent.java index fab9342..81e5e83 100644 --- a/src/main/java/com/community/pocket/entity/po/ForumContent.java +++ b/src/main/java/com/community/pocket/entity/po/ForumContent.java @@ -1,7 +1,6 @@ package com.community.pocket.entity.po; import com.community.pocket.util.TableName; -import org.bson.types.ObjectId; import org.springframework.data.mongodb.core.mapping.Document; /** @@ -10,7 +9,7 @@ import org.springframework.data.mongodb.core.mapping.Document; @Document(TableName.forumContent) public class ForumContent { //帖子详情id - private ObjectId id; + private String id; //帖子id private String forumId; //用户名 @@ -22,11 +21,11 @@ public class ForumContent { //帖子正文 private String content; - public ObjectId getId() { + public String getId() { return id; } - public void setId(ObjectId id) { + public void setId(String id) { this.id = id; } diff --git a/src/main/java/com/community/pocket/entity/po/Notice.java b/src/main/java/com/community/pocket/entity/po/Notice.java index 117c9e2..ed8744f 100644 --- a/src/main/java/com/community/pocket/entity/po/Notice.java +++ b/src/main/java/com/community/pocket/entity/po/Notice.java @@ -1,14 +1,13 @@ package com.community.pocket.entity.po; import com.community.pocket.util.TableName; -import org.bson.types.ObjectId; import org.springframework.data.mongodb.core.mapping.Document; //公告信息 @Document(TableName.notice) public class Notice { - private ObjectId id; + private String id; //公告标题 private String title; //公告内容 @@ -50,11 +49,11 @@ public class Notice { this.time = time; } - public ObjectId getId() { + public String getId() { return id; } - public void setId(ObjectId id) { + public void setId(String id) { this.id = id; } } diff --git a/src/main/java/com/community/pocket/entity/po/android/Active.java b/src/main/java/com/community/pocket/entity/po/android/Active.java index 472660b..fa0dfde 100644 --- a/src/main/java/com/community/pocket/entity/po/android/Active.java +++ b/src/main/java/com/community/pocket/entity/po/android/Active.java @@ -1,13 +1,12 @@ package com.community.pocket.entity.po.android; import com.community.pocket.util.TableName; -import org.bson.types.ObjectId; import org.springframework.data.mongodb.core.mapping.Document; @Document(TableName.active) public class Active { //帖子id - private ObjectId id; + private String id; //活动开始时间 private String activeStartTime; //活动结束时间 @@ -15,11 +14,11 @@ public class Active { //活动信用分 private String activeScore; - public ObjectId getId() { + public String getId() { return id; } - public void setId(ObjectId id) { + public void setId(String id) { this.id = id; } diff --git a/src/main/java/com/community/pocket/entity/po/android/Complain.java b/src/main/java/com/community/pocket/entity/po/android/Complain.java index 0388ecb..6fb3b2e 100644 --- a/src/main/java/com/community/pocket/entity/po/android/Complain.java +++ b/src/main/java/com/community/pocket/entity/po/android/Complain.java @@ -1,15 +1,18 @@ package com.community.pocket.entity.po.android; -import org.bson.types.ObjectId; +import com.community.pocket.util.TableName; +import org.springframework.data.mongodb.core.mapping.Document; /** * 投诉人 */ +@Document(TableName.complain) public class Complain { - private ObjectId id; - + private String id; //投诉人 private String complain; + //投诉人详情信息 + private MyInfo info; public String getComplain() { return complain; @@ -19,11 +22,23 @@ public class Complain { this.complain = complain; } - public ObjectId getId() { + public String getId() { return id; } - public void setId(ObjectId id) { + public void setId(String id) { this.id = id; } + + public MyInfo getInfo() { + return info; + } + + public void setInfo(MyInfo info) { + this.info = info; + } + + public static Complain getInstance() { + return new Complain(); + } } diff --git a/src/main/java/com/community/pocket/entity/po/android/Token.java b/src/main/java/com/community/pocket/entity/po/android/Token.java index 0c20007..d1d9310 100644 --- a/src/main/java/com/community/pocket/entity/po/android/Token.java +++ b/src/main/java/com/community/pocket/entity/po/android/Token.java @@ -12,9 +12,9 @@ public class Token { @Id private String token; - private long time; + protected Long time; - private String username; + protected String username; public String getToken() { return token; @@ -24,11 +24,11 @@ public class Token { this.token = token; } - public long getTime() { + public Long getTime() { return time; } - public void setTime(long time) { + public void setTime(Long time) { this.time = time; } diff --git a/src/main/java/com/community/pocket/entity/po/android/Visitor.java b/src/main/java/com/community/pocket/entity/po/android/Visitor.java index 3f8a6db..f6deb11 100644 --- a/src/main/java/com/community/pocket/entity/po/android/Visitor.java +++ b/src/main/java/com/community/pocket/entity/po/android/Visitor.java @@ -1,8 +1,6 @@ package com.community.pocket.entity.po.android; import com.community.pocket.util.TableName; -import com.fasterxml.jackson.annotation.JsonIgnore; -import org.bson.types.ObjectId; import org.springframework.data.mongodb.core.mapping.Document; /** @@ -11,8 +9,7 @@ import org.springframework.data.mongodb.core.mapping.Document; @Document(TableName.visitor) public class Visitor { //访客id - @JsonIgnore - private ObjectId id; + private String id; //访客人 private String username; //预约对象 @@ -58,11 +55,11 @@ public class Visitor { this.notes = notes; } - public ObjectId getId() { + public String getId() { return id; } - public void setId(ObjectId id) { + public void setId(String id) { this.id = id; } diff --git a/src/main/java/com/community/pocket/entity/vo/ForumNewResponse.java b/src/main/java/com/community/pocket/entity/vo/ForumNewResponse.java new file mode 100644 index 0000000..8776255 --- /dev/null +++ b/src/main/java/com/community/pocket/entity/vo/ForumNewResponse.java @@ -0,0 +1,29 @@ +package com.community.pocket.entity.vo; + +import com.community.pocket.entity.vo.android.CustomMessage; +import com.community.pocket.entity.vo.android.ForumDto; + +/** + * 最新帖子响应 + */ +public class ForumNewResponse extends Response { + + private Page forumList; + + public Page getForumList() { + return forumList; + } + + public void setForumList(Page forumList) { + this.forumList = forumList; + } + + public ForumNewResponse(Result result, Msg message, Object... args) { + super(result, message, args); + } + + public enum Msg implements CustomMessage { + ok, + fail + } +} diff --git a/src/main/java/com/community/pocket/entity/vo/android/ForumNoticeResponse.java b/src/main/java/com/community/pocket/entity/vo/ForumNoticeResponse.java similarity index 66% rename from src/main/java/com/community/pocket/entity/vo/android/ForumNoticeResponse.java rename to src/main/java/com/community/pocket/entity/vo/ForumNoticeResponse.java index 80721a2..5233397 100644 --- a/src/main/java/com/community/pocket/entity/vo/android/ForumNoticeResponse.java +++ b/src/main/java/com/community/pocket/entity/vo/ForumNoticeResponse.java @@ -1,8 +1,6 @@ -package com.community.pocket.entity.vo.android; +package com.community.pocket.entity.vo; -import com.community.pocket.entity.vo.NoticeVo; -import com.community.pocket.entity.vo.Response; -import com.community.pocket.entity.vo.Result; +import com.community.pocket.entity.vo.android.CustomMessage; import java.util.List; @@ -26,9 +24,17 @@ public class ForumNoticeResponse extends Response { } public enum Msg implements CustomMessage { + //获取成功 ok, + //获取失败 fail, + //删除成功 delete_ok, - delete_fail + //删除失败 + delete_fail, + //添加成功 + add_ok, + //添加失败 + add_fail } } diff --git a/src/main/java/com/community/pocket/entity/vo/ForumQuery.java b/src/main/java/com/community/pocket/entity/vo/ForumQuery.java new file mode 100644 index 0000000..4da5fe1 --- /dev/null +++ b/src/main/java/com/community/pocket/entity/vo/ForumQuery.java @@ -0,0 +1,38 @@ +package com.community.pocket.entity.vo; + +import com.community.pocket.entity.po.Forum; + +/** + * 帖子查询条件 + */ +public class ForumQuery { + private Forum.ForumStatus status; + + private Long currentPage; + + private String username; + + public Forum.ForumStatus getStatus() { + return status; + } + + public void setStatus(Forum.ForumStatus status) { + this.status = status; + } + + public Long getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Long currentPage) { + this.currentPage = currentPage; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } +} diff --git a/src/main/java/com/community/pocket/entity/vo/Page.java b/src/main/java/com/community/pocket/entity/vo/Page.java new file mode 100644 index 0000000..277db48 --- /dev/null +++ b/src/main/java/com/community/pocket/entity/vo/Page.java @@ -0,0 +1,56 @@ +package com.community.pocket.entity.vo; + +import java.util.List; + +//分页数据 +public class Page { + //总记录数 + private final Long count; + //总页数 + private final Long totalPage; + //当前页数 + private Long currentPage; + //数据集合 + private List list; + //分页大小 + private final Integer pageSize; + + public Page(Long count, Long currentPage, Integer pageSize) { + this.count = count; + this.currentPage = currentPage; + this.pageSize = pageSize; + this.totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; + } + + public Integer getPageSize() { + return pageSize; + } + + public Long getCount() { + return count; + } + + public Long getTotalPage() { + return totalPage; + } + + public Long getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Long currentPage) { + this.currentPage = currentPage; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public boolean isEmpty() { + return this.count == 0; + } +} diff --git a/src/main/java/com/community/pocket/entity/vo/android/ActiveForm.java b/src/main/java/com/community/pocket/entity/vo/android/ActiveVo.java similarity index 94% rename from src/main/java/com/community/pocket/entity/vo/android/ActiveForm.java rename to src/main/java/com/community/pocket/entity/vo/android/ActiveVo.java index 28ec374..b1474f2 100644 --- a/src/main/java/com/community/pocket/entity/vo/android/ActiveForm.java +++ b/src/main/java/com/community/pocket/entity/vo/android/ActiveVo.java @@ -3,7 +3,7 @@ package com.community.pocket.entity.vo.android; /** * 活动贴 */ -public class ActiveForm extends ForumForm { +public class ActiveVo extends ForumVo { //活动开始时间 private String activeStartTime; //活动结束时间 diff --git a/src/main/java/com/community/pocket/entity/vo/android/ComplainForm.java b/src/main/java/com/community/pocket/entity/vo/android/ComplainVo.java similarity index 83% rename from src/main/java/com/community/pocket/entity/vo/android/ComplainForm.java rename to src/main/java/com/community/pocket/entity/vo/android/ComplainVo.java index 60e3440..bc83d0c 100644 --- a/src/main/java/com/community/pocket/entity/vo/android/ComplainForm.java +++ b/src/main/java/com/community/pocket/entity/vo/android/ComplainVo.java @@ -1,6 +1,7 @@ package com.community.pocket.entity.vo.android; -public class ComplainForm extends ForumForm{ +public class ComplainVo extends ForumVo { + private String complain; public String getComplain() { diff --git a/src/main/java/com/community/pocket/entity/vo/android/ForumDto.java b/src/main/java/com/community/pocket/entity/vo/android/ForumDto.java new file mode 100644 index 0000000..254a518 --- /dev/null +++ b/src/main/java/com/community/pocket/entity/vo/android/ForumDto.java @@ -0,0 +1,122 @@ +package com.community.pocket.entity.vo.android; + +import com.community.pocket.entity.po.Forum; +import com.community.pocket.entity.po.android.Active; +import com.community.pocket.entity.po.android.Complain; +import com.community.pocket.entity.po.android.MyInfo; + +//帖子 +public class ForumDto { + //帖子 + private String id; + //帖子标题 + private String title; + //回复数 + private Integer reply; + //帖子类型 + private Forum.ForumType forumType; + //缩略内容 + private String content; + //发帖人 + private String username; + //发帖时间 + private Long time; + //审核状态 + private Forum.ForumStatus status; + + //发帖人详情信息 + private MyInfo info; + + //其他信息 + private Active activeDto; + + private Complain complainDto; + + public Active getActiveDto() { + return activeDto; + } + + public void setActiveDto(Active activeDto) { + this.activeDto = activeDto; + } + + public Complain getComplainDto() { + return complainDto; + } + + public void setComplainDto(Complain complainDto) { + this.complainDto = complainDto; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getReply() { + return reply; + } + + public void setReply(Integer reply) { + this.reply = reply; + } + + public Forum.ForumType getForumType() { + return forumType; + } + + public void setForumType(Forum.ForumType forumType) { + this.forumType = forumType; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public Long getTime() { + return time; + } + + public void setTime(Long time) { + this.time = time; + } + + public MyInfo getInfo() { + return info; + } + + public void setInfo(MyInfo info) { + this.info = info; + } + + public Forum.ForumStatus getStatus() { + return status; + } + + public void setStatus(Forum.ForumStatus status) { + this.status = status; + } +} diff --git a/src/main/java/com/community/pocket/entity/vo/android/ForumMyResponse.java b/src/main/java/com/community/pocket/entity/vo/android/ForumMyResponse.java index 7a9dafb..07c65fa 100644 --- a/src/main/java/com/community/pocket/entity/vo/android/ForumMyResponse.java +++ b/src/main/java/com/community/pocket/entity/vo/android/ForumMyResponse.java @@ -1,25 +1,24 @@ package com.community.pocket.entity.vo.android; +import com.community.pocket.entity.vo.Page; import com.community.pocket.entity.vo.Response; import com.community.pocket.entity.vo.Result; -import java.util.List; - /** * 我的帖子响应结果 */ public class ForumMyResponse extends Response { - private List forumList; + private Page forumList; public ForumMyResponse(Result result, Msg message, Object... args) { super(result, message, args); } - public List getForumList() { + public Page getForumList() { return forumList; } - public void setForumList(List forumList) { + public void setForumList(Page forumList) { this.forumList = forumList; } diff --git a/src/main/java/com/community/pocket/entity/vo/android/ForumNewResponse.java b/src/main/java/com/community/pocket/entity/vo/android/ForumNewResponse.java deleted file mode 100644 index bc9ecec..0000000 --- a/src/main/java/com/community/pocket/entity/vo/android/ForumNewResponse.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.community.pocket.entity.vo.android; - -import com.community.pocket.entity.vo.Response; -import com.community.pocket.entity.vo.Result; - -import java.util.List; - -/** - * 最新帖子响应 - */ -public class ForumNewResponse extends Response { - - private List forumList; - - public List getForumList() { - return forumList; - } - - public void setForumList(List forumList) { - this.forumList = forumList; - } - - public ForumNewResponse(Result result, Msg message, Object... args) { - super(result, message, args); - } - - public enum Msg implements CustomMessage{ - ok, - fail - } -} diff --git a/src/main/java/com/community/pocket/entity/vo/android/ForumOtherInfo.java b/src/main/java/com/community/pocket/entity/vo/android/ForumOtherInfo.java new file mode 100644 index 0000000..40de488 --- /dev/null +++ b/src/main/java/com/community/pocket/entity/vo/android/ForumOtherInfo.java @@ -0,0 +1,4 @@ +package com.community.pocket.entity.vo.android; + +public interface ForumOtherInfo { +} diff --git a/src/main/java/com/community/pocket/entity/vo/android/ForumVo.java b/src/main/java/com/community/pocket/entity/vo/android/ForumVo.java index 55f0a51..bba8d64 100644 --- a/src/main/java/com/community/pocket/entity/vo/android/ForumVo.java +++ b/src/main/java/com/community/pocket/entity/vo/android/ForumVo.java @@ -1,15 +1,14 @@ package com.community.pocket.entity.vo.android; import com.community.pocket.entity.po.Forum; +import com.community.pocket.entity.po.android.Token; /** * 帖子列表 */ -public class ForumVo { +public class ForumVo extends Token { //帖子 private String id; - //发帖时间 - private Long time; //帖子标题 private String title; //回复数 @@ -18,15 +17,15 @@ public class ForumVo { private Forum.ForumType forumType; //缩略内容 private String content; - //发帖人 - private String username; + //发帖时间 public Long getTime() { return time; } - public void setTime(Long time) { - this.time = time; + //发帖人 + public String getUsername() { + return username; } public String getTitle() { @@ -61,14 +60,6 @@ public class ForumVo { this.content = content; } - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - public String getId() { return id; } diff --git a/src/main/java/com/community/pocket/entity/vo/web/ForumCheck.java b/src/main/java/com/community/pocket/entity/vo/web/ForumCheck.java new file mode 100644 index 0000000..f7cda8d --- /dev/null +++ b/src/main/java/com/community/pocket/entity/vo/web/ForumCheck.java @@ -0,0 +1,27 @@ +package com.community.pocket.entity.vo.web; + +import com.community.pocket.entity.po.Forum; + +/** + * 帖子审核 + */ +public class ForumCheck { + private String id; + private Forum.ForumStatus status; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Forum.ForumStatus getStatus() { + return status; + } + + public void setStatus(Forum.ForumStatus status) { + this.status = status; + } +} diff --git a/src/main/java/com/community/pocket/entity/vo/web/ForumCheckResponse.java b/src/main/java/com/community/pocket/entity/vo/web/ForumCheckResponse.java new file mode 100644 index 0000000..eefdd72 --- /dev/null +++ b/src/main/java/com/community/pocket/entity/vo/web/ForumCheckResponse.java @@ -0,0 +1,20 @@ +package com.community.pocket.entity.vo.web; + +import com.community.pocket.entity.vo.Response; +import com.community.pocket.entity.vo.Result; +import com.community.pocket.entity.vo.android.CustomMessage; + +/** + * 帖子审核结果 + */ +public class ForumCheckResponse extends Response { + + public ForumCheckResponse(Result result, Msg message, Object... args) { + super(result, message, args); + } + + public enum Msg implements CustomMessage { + check_ok, + check_fail + } +} diff --git a/src/main/java/com/community/pocket/repository/BaseDao.java b/src/main/java/com/community/pocket/repository/BaseDao.java index 16d2b13..6a800f3 100644 --- a/src/main/java/com/community/pocket/repository/BaseDao.java +++ b/src/main/java/com/community/pocket/repository/BaseDao.java @@ -1,6 +1,7 @@ package com.community.pocket.repository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.data.mongodb.core.MongoTemplate; public abstract class BaseDao { @@ -9,6 +10,9 @@ public abstract class BaseDao { @Autowired protected MongoTemplate mongoTemplate; + @Value("${forum.page-size}") + protected Integer pageSize; + //增加 public abstract T save(T t); diff --git a/src/main/java/com/community/pocket/repository/android/ActiveDao.java b/src/main/java/com/community/pocket/repository/android/ActiveDao.java index 0987233..4ab7c8d 100644 --- a/src/main/java/com/community/pocket/repository/android/ActiveDao.java +++ b/src/main/java/com/community/pocket/repository/android/ActiveDao.java @@ -2,7 +2,7 @@ package com.community.pocket.repository.android; import com.community.pocket.entity.po.Forum; import com.community.pocket.entity.po.android.Active; -import com.community.pocket.entity.vo.android.ActiveForm; +import com.community.pocket.entity.vo.android.ActiveVo; import com.community.pocket.repository.BaseDao; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,12 +15,12 @@ public class ActiveDao extends BaseDao{ private static final Logger LOG = LoggerFactory.getLogger(ForumDao.class); //保存活动贴 - public Active save(ActiveForm activeForm, Forum forum) { - Active active=new Active(); + public Active save(ActiveVo activeVo, Forum forum) { + Active active = new Active(); active.setId(forum.getId()); - active.setActiveStartTime(activeForm.getActiveStartTime()); - active.setActiveEndTime(activeForm.getActiveEndTime()); - active.setActiveScore(activeForm.getActiveScore()); + active.setActiveStartTime(activeVo.getActiveStartTime()); + active.setActiveEndTime(activeVo.getActiveEndTime()); + active.setActiveScore(activeVo.getActiveScore()); return save(active); } diff --git a/src/main/java/com/community/pocket/repository/android/ComplainDao.java b/src/main/java/com/community/pocket/repository/android/ComplainDao.java index e7304a7..d8c388b 100644 --- a/src/main/java/com/community/pocket/repository/android/ComplainDao.java +++ b/src/main/java/com/community/pocket/repository/android/ComplainDao.java @@ -2,7 +2,7 @@ package com.community.pocket.repository.android; import com.community.pocket.entity.po.Forum; import com.community.pocket.entity.po.android.Complain; -import com.community.pocket.entity.vo.android.ComplainForm; +import com.community.pocket.entity.vo.android.ComplainVo; import com.community.pocket.repository.BaseDao; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,9 +16,9 @@ public class ComplainDao extends BaseDao { private static final Logger LOG = LoggerFactory.getLogger(ComplainDao.class); //保存投诉贴 - public Complain save(ComplainForm complainForm, Forum forum) { - Complain complain=new Complain(); - complain.setComplain(complainForm.getComplain()); + public Complain save(ComplainVo complainVo, Forum forum) { + Complain complain = Complain.getInstance(); + complain.setComplain(complainVo.getComplain()); complain.setId(forum.getId()); return save(complain); } diff --git a/src/main/java/com/community/pocket/repository/android/ForumContentDao.java b/src/main/java/com/community/pocket/repository/android/ForumContentDao.java index ea76c66..4bfeafd 100644 --- a/src/main/java/com/community/pocket/repository/android/ForumContentDao.java +++ b/src/main/java/com/community/pocket/repository/android/ForumContentDao.java @@ -3,8 +3,8 @@ 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.android.ForumContentVo; -import com.community.pocket.entity.vo.android.ForumForm; 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.TableName; @@ -59,10 +59,10 @@ public class ForumContentDao extends BaseDao { /** * 保存帖子详情 */ - public ForumContent save(ForumForm forumForm, Forum forum) { + public ForumContent save(ForumVo forumVo, Forum forum) { ForumContent forumContent = new ForumContent(); - forumContent.setContent(forumForm.getContent()); - forumContent.setForumId(forum.getId().toString()); + forumContent.setContent(forumVo.getContent()); + forumContent.setForumId(forum.getId()); forumContent.setTime(forum.getTime()); forumContent.setTower(1L); forumContent.setUsername(forum.getUsername()); diff --git a/src/main/java/com/community/pocket/repository/android/ForumDao.java b/src/main/java/com/community/pocket/repository/android/ForumDao.java index 013bae7..addcf00 100644 --- a/src/main/java/com/community/pocket/repository/android/ForumDao.java +++ b/src/main/java/com/community/pocket/repository/android/ForumDao.java @@ -1,13 +1,19 @@ package com.community.pocket.repository.android; import com.community.pocket.entity.po.Forum; +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.web.ForumCheck; import com.community.pocket.repository.BaseDao; import com.community.pocket.util.TableName; import org.bson.types.ObjectId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.aggregation.Aggregation; import org.springframework.data.mongodb.core.aggregation.AggregationOperation; @@ -16,6 +22,7 @@ import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Update; import org.springframework.stereotype.Repository; +import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; @@ -31,18 +38,33 @@ public class ForumDao extends BaseDao { @Value("${forum.content-length}") private int contentLength; + //活动贴 + //关联帖子外键属性 + private static final String idKey = "_id"; + //定义管道操作 + private static final String activeKey = "activeDto"; + //关联 + private static final LookupOperation activeforumLookup = LookupOperation.newLookup().from(TableName.active).localField(idKey).foreignField(idKey).as(activeKey); + + //投诉贴 + //关联属性 + private static final String complainKey = "complainDto"; + //定义管道操作 + private static final LookupOperation complainforumLookup = LookupOperation.newLookup().from(TableName.complain).localField(idKey).foreignField(idKey).as(complainKey); + //关联属性 + private static final String infoKey = "info"; + + //关联用户外键属性 + private static final String usernameKey = "username"; + //定义管道操作 + private static final LookupOperation infoLookup = LookupOperation.newLookup().from(TableName.info).localField(usernameKey).foreignField(idKey).as(infoKey); + //添加回复数 public boolean update(ForumReplyForm forumReplyForm) { return mongoTemplate.updateFirst(new Query(Criteria.where("id").is(new ObjectId(forumReplyForm.getForumId()))), new Update().inc("reply", 1), entityClass()).wasAcknowledged(); } - //关联用户表查询 - private static final LookupOperation lookupOperation = LookupOperation.newLookup(). - from(TableName.info). //关联从表名 - localField("username"). //主表关联字段 - foreignField("_id").//从表关联的字段 - as("myInfo"); //查询结果名 //查找热门贴 public List rankReply(Forum.ForumType type, int num) { @@ -50,7 +72,7 @@ public class ForumDao extends BaseDao { List forumList =mongoTemplate.find(new Query(Criteria.where("forumType").is(type)).with(Sort.by("reply").descending()).limit(num),entityClass()); for(Forum forum:forumList){ ForumHot forumHot=new ForumHot(); - forumHot.setForumId(forum.getId().toString()); + forumHot.setForumId(forum.getId()); forumHot.setReply(forum.getReply()); forumHot.setTitle(forum.getTitle()); forumHots.add(forumHot); @@ -59,10 +81,11 @@ public class ForumDao extends BaseDao { } //查找帖子 - private List loadForum(AggregationOperation... operation) { + private List loadForum(AggregationOperation... operation) { try { Aggregation aggregation = Aggregation.newAggregation(operation); - return mongoTemplate.aggregate(aggregation, TableName.forum, ForumVo.class).getMappedResults(); + LOG.info(aggregation.toString()); + return mongoTemplate.aggregate(aggregation, TableName.forum, ForumDto.class).getMappedResults(); } catch (Exception e) { e.printStackTrace(); LOG.error(e.toString()); @@ -70,29 +93,62 @@ public class ForumDao extends BaseDao { return null; } - //查找所有帖子 - public List loadNewForum() { - return loadForum(lookupOperation, Aggregation.unwind("myInfo"), Aggregation.sort(Sort.by("time").descending())); + //设置投诉贴投诉人详细信息 + private void loadComplain(ForumDto forumDto) { + Complain complain = forumDto.getComplainDto(); + complain.setInfo(mongoTemplate.findOne(new Query(Criteria.where(idKey).is(complain.getComplain())), MyInfo.class)); } - //查找最新帖子 - public List loadMyForum(String username) { - return loadForum(lookupOperation, Aggregation.unwind("myInfo"), Aggregation.match(Criteria.where("username").is(username)), Aggregation.sort(Sort.by("time").descending())); + //查询最新帖子 + public Page loadForum(ForumQuery forumQuery) { +// 根据审核状态按时间从大到小排序的帖子 + try { + Criteria criteria = new Criteria(); + if (!StringUtils.isEmpty(forumQuery.getStatus())) { + Criteria.where("status").is(forumQuery.getStatus()); + } + if (!StringUtils.isEmpty(forumQuery.getUsername())) { + criteria = criteria.and("username").is(forumQuery.getUsername()); + } + Query query = new Query(criteria).with(PageRequest.of(forumQuery.getCurrentPage().intValue() - 1, pageSize)); + long currentCount = mongoTemplate.count(query, entityClass()); + if (currentCount > 0) { + long count = mongoTemplate.count(new Query(criteria), entityClass()); + Page page = new Page<>(count, forumQuery.getCurrentPage(), pageSize); + List forumDtos = loadForum(complainforumLookup, activeforumLookup, infoLookup, Aggregation.match(criteria), Aggregation.skip((forumQuery.getCurrentPage() - 1) * pageSize), Aggregation.limit(pageSize), Aggregation.sort(Sort.by("time").descending())); + if (forumDtos != null) { + for (ForumDto forumDto : forumDtos) { + if (forumDto.getComplainDto() != null) { + loadComplain(forumDto); + } + } + } + page.setList(forumDtos); + return page; + } else { + return new Page<>(0L, forumQuery.getCurrentPage(), pageSize); + } + } catch (Exception e) { + e.printStackTrace(); + LOG.error(e.toString()); + } + return null; } //保存活动贴 - public Forum save(ActiveForm activeForm){ + public Forum save(ActiveVo activeVo) { try { - Forum forum=new Forum(); - forum.setUsername(activeForm.getUsername()); + Forum forum = new Forum(); + forum.setUsername(activeVo.getUsername()); forum.setForumType(Forum.ForumType.active); forum.setReply(0); - forum.setTitle(activeForm.getTitle()); + forum.setTitle(activeVo.getTitle()); forum.setTime(System.currentTimeMillis()); - if(activeForm.getContent().length()>contentLength){ - forum.setContent(activeForm.getContent().substring(0,contentLength)); - }else{ - forum.setContent(activeForm.getContent()); + forum.setStatus(Forum.ForumStatus.uncheck); + if (activeVo.getContent().length() > contentLength) { + forum.setContent(activeVo.getContent().substring(0, contentLength)); + } else { + forum.setContent(activeVo.getContent()); } return save(forum); } catch (Exception e) { @@ -103,15 +159,16 @@ public class ForumDao extends BaseDao { } //保存动态 - public Forum save(ForumForm forumForm){ + public Forum save(ForumVo forumVo) { try { - Forum forum=new Forum(); - forum.setContent(forumForm.getContent()); - forum.setTitle(forumForm.getTitle()); + Forum forum = new Forum(); + forum.setContent(forumVo.getContent()); + forum.setTitle(forumVo.getTitle()); forum.setForumType(Forum.ForumType.topic); forum.setTime(System.currentTimeMillis()); forum.setReply(0); - forum.setUsername(forumForm.getUsername()); + forum.setUsername(forumVo.getUsername()); + forum.setStatus(Forum.ForumStatus.uncheck); return save(forum); } catch (Exception e) { e.printStackTrace(); @@ -121,15 +178,16 @@ public class ForumDao extends BaseDao { } //保存投诉 - public Forum save(ComplainForm complainForm){ + public Forum save(ComplainVo complainVo) { try { - Forum forum=new Forum(); - forum.setContent(complainForm.getContent()); - forum.setTitle(complainForm.getTitle()); + Forum forum = new Forum(); + forum.setContent(complainVo.getContent()); + forum.setTitle(complainVo.getTitle()); forum.setForumType(Forum.ForumType.complan); forum.setTime(System.currentTimeMillis()); forum.setReply(0); - forum.setUsername(complainForm.getUsername()); + forum.setUsername(complainVo.getUsername()); + forum.setStatus(Forum.ForumStatus.uncheck); return save(forum); } catch (Exception e) { e.printStackTrace(); @@ -138,6 +196,11 @@ public class ForumDao extends BaseDao { return null; } + //审核帖子 + public boolean check(ForumCheck forumCheck) { + return mongoTemplate.updateFirst(new Query(Criteria.where(idKey).is(forumCheck.getId())), Update.update("status", forumCheck.getStatus()), entityClass()).wasAcknowledged(); + } + //保存 @Override public Forum save(Forum forum) { diff --git a/src/main/java/com/community/pocket/util/TableName.java b/src/main/java/com/community/pocket/util/TableName.java index c4c55fd..697573b 100644 --- a/src/main/java/com/community/pocket/util/TableName.java +++ b/src/main/java/com/community/pocket/util/TableName.java @@ -18,6 +18,8 @@ public class TableName { public static final String forumContent = "forumContent"; //活动帖子 public static final String active = "active"; + //投诉贴 + public static final String complain = "complain"; //公告 public static final String notice = "notice"; //访客信息 diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index f46d733..66cb3c8 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -43,6 +43,8 @@ token: forum: #帖子正文缩略长度 content-length: 10 + #响应客户端分页数据大小 + page-size: 10 #注册配置 register: diff --git a/src/test/java/com/community/pocket/DemoApplicationTests.java b/src/test/java/com/community/pocket/DemoApplicationTests.java index ad4a81e..5bcc902 100644 --- a/src/test/java/com/community/pocket/DemoApplicationTests.java +++ b/src/test/java/com/community/pocket/DemoApplicationTests.java @@ -11,18 +11,30 @@ import com.community.pocket.repository.android.VisitorPeopleDao; import com.community.pocket.util.MessageService; import com.google.gson.Gson; import org.apache.commons.lang3.RandomStringUtils; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultHandlers; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; import java.io.FileNotFoundException; import java.io.FileReader; import java.util.List; import java.util.Random; +//SpringBoot1.4版本之前用的是SpringJUnit4ClassRunner.class +//@RunWith(SpringRunner.class) +//SpringBoot1.4版本之前用的是@SpringApplicationConfiguration(classes = Application.class) @SpringBootTest +//测试环境使用,用来表示测试环境使用的ApplicationContext将是WebApplicationContext类型的 +@WebAppConfiguration class DemoApplicationTests { @Autowired @@ -40,6 +52,17 @@ class DemoApplicationTests { @Autowired private MessageService messageService; + @Autowired + private WebApplicationContext webApplicationContext; + + private MockMvc mockMvc; + + @BeforeEach + public void setup() { + this.mockMvc = MockMvcBuilders.webAppContextSetup( + webApplicationContext).build(); + } + private static final Logger LOG = LoggerFactory.getLogger(DemoApplicationTests.class); @Test @@ -83,4 +106,56 @@ class DemoApplicationTests { LOG.info(messageService.getMessage(GarbageCateGory.type1)); } + @Test + //测试添加活动贴 + void testActive() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.post("/forum/sendActive") + .param("activeStartTime", "2020/01/01") + .param("activeEndTime", "2020/01/02") + .param("activeScore", "15") + .param("title", "666") + .param("content", "fuckfuckfuckfuckfuck") + .param("username", "panqihua") + .param("token", "b6a518fffa3ffa607e756324474e9484") + ).andDo(MockMvcResultHandlers.print()).andReturn(); + } + + @Test + //测试添加投诉贴 + void testComplain() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.post("/forum/sendComplain") + .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") + .param("content", "fuckfuckfuckfuckfuck") + .param("token", "b6a518fffa3ffa607e756324474e9484") + .param("username", "panqihua") + ).andDo(MockMvcResultHandlers.print()).andReturn(); + } + + @Test + void queryForum() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/api/forum/posts") + + .param("currentPage", "1") + ).andDo(MockMvcResultHandlers.print()).andReturn(); + } + + @Test + void login() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.post("/login") + .param("username", "panqihua") + .param("password", "123456") + ).andDo(MockMvcResultHandlers.print()).andReturn(); + } }