wiki评论和空间
This commit is contained in:
@@ -7,6 +7,8 @@ import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageComment;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageCommentService;
|
||||
import com.zyplayer.doc.wiki.controller.vo.WikiPageCommentVo;
|
||||
import org.dozer.Mapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -16,6 +18,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 文档控制器
|
||||
@@ -30,14 +34,23 @@ public class WikiPageCommentController {
|
||||
|
||||
@Resource
|
||||
WikiPageCommentService wikiPageCommentService;
|
||||
@Resource
|
||||
Mapper mapper;
|
||||
|
||||
@PostMapping("/list")
|
||||
public ResponseJson<List<WikiPageComment>> list(WikiPageComment wikiPageComment) {
|
||||
public ResponseJson<List<WikiPageCommentVo>> list(WikiPageComment wikiPageComment) {
|
||||
UpdateWrapper<WikiPageComment> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("page_id", wikiPageComment.getPageId());
|
||||
wrapper.eq(wikiPageComment.getParentId() != null, "parent_id", wikiPageComment.getParentId());
|
||||
List<WikiPageComment> authList = wikiPageCommentService.list(wrapper);
|
||||
return DocResponseJson.ok(authList);
|
||||
Map<Long, List<WikiPageComment>> listMap = authList.stream().filter(val -> val.getParentId() != null)
|
||||
.collect(Collectors.groupingBy(WikiPageComment::getParentId));
|
||||
List<WikiPageCommentVo> commentList = authList.stream().filter(val -> val.getParentId() == null)
|
||||
.map(val -> mapper.map(val, WikiPageCommentVo.class)).collect(Collectors.toList());
|
||||
for (WikiPageCommentVo commentVo : commentList) {
|
||||
commentVo.setCommentList(listMap.get(commentVo.getId()));
|
||||
}
|
||||
return DocResponseJson.ok(commentList);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
|
||||
@@ -57,6 +57,7 @@ public class WikiSpaceController {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
wikiSpace.setCreateTime(new Date());
|
||||
wikiSpace.setCreateUserId(currentUser.getUserId());
|
||||
wikiSpace.setCreateUserName(currentUser.getUsername());
|
||||
wikiSpaceService.save(wikiSpace);
|
||||
}
|
||||
return DocResponseJson.ok();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.zyplayer.doc.wiki.controller.vo;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageComment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-02-24
|
||||
*/
|
||||
public class WikiPageCommentVo extends WikiPageComment {
|
||||
private List<WikiPageComment> commentList;
|
||||
|
||||
public List<WikiPageComment> getCommentList() {
|
||||
return commentList;
|
||||
}
|
||||
|
||||
public void setCommentList(List<WikiPageComment> commentList) {
|
||||
this.commentList = commentList;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user