inleft
2022-03-02 e343e508ce5f2d355ad82c05a319981c66d1324b
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticlecomment/controller/BlogArticleCommentOutsideController.java
@@ -25,6 +25,7 @@
package vip.xiaonuo.modular.blogarticlecomment.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -99,15 +100,33 @@
        List<BlogArticleComment> commentList = blogArticleCommentService.lambdaQuery()
                .eq(queryDto.getArticleId() != null, BlogArticleComment::getArticleId, queryDto.getArticleId())
                .eq(BlogArticleComment::getCommentType, queryDto.getArticleId() == null ? MyConstant.CommentType.type_1 : MyConstant.CommentType.type_2)
                .eq(BlogArticleComment::getIsCheck, MyConstant.Yes)
                .eq(BlogArticleComment::getIsEnable, MyConstant.Yes)
                .eq(BlogArticleComment::getParentId,0)
                .eq(BlogArticleComment::getParentId, 0)
                .orderByDesc(BlogArticleComment::getCreateDate)
                .page(queryPage).getRecords();
        int limitCount = 5;
        String privateComment = "******";
        List<BlogCommentVo> res = commentList.stream().map(e -> {
                    BlogCommentVo vo = new BlogCommentVo();
                    BeanUtil.copyProperties(e, vo);
                    vo.setIsHasNext(MyConstant.No);
                    List<BlogCommentVo> replyList = blogArticleCommentService.getReplyListById(e.getId(), limitCount);
                    vo.setReplyList(replyList);
                    if (e.getAuthStatus().equals(MyConstant.AuthStatus.privateCode)) {
                        vo.setCommentContent(privateComment);
                    }
                    if (CollUtil.isNotEmpty(replyList)
                            && blogArticleCommentService.lambdaQuery()
                            .eq(BlogArticleComment::getParentId, e.getId())
                            .eq(BlogArticleComment::getIsCheck, MyConstant.Yes)
                            .eq(BlogArticleComment::getIsEnable, MyConstant.Yes)
                            .count() > limitCount) {
                        vo.setIsHasNext(MyConstant.Yes);
                    }
                    return vo;
                }
        ).collect(Collectors.toList());
@@ -115,4 +134,24 @@
        queryPage.setRecords(res);
        return new SuccessResponseData(queryPage);
    }
    @GetMapping("/blogComment/queryBlogCommentSubList")
    @BusinessLog(title = "外部blog系统_blog留言/评论子列表_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData queryBlogCommentSubList(BlogCommentQueryDto queryDto) {
        if (queryDto.getArticleId() != null && blogArticleCommentService.getById(queryDto.getCommentId()) == null) {
            throw new BlogException("查询不到相关评论");
        }
        String privateComment = "(悄悄话已隐藏)******";
        List<BlogCommentVo> replyList = blogArticleCommentService.getReplyListById(queryDto.getCommentId(), null);
        for (BlogCommentVo vo : replyList) {
            vo.setIsHasNext(MyConstant.No);
            if (vo.getAuthStatus().equals(MyConstant.AuthStatus.privateCode)) {
                vo.setCommentContent(privateComment);
            }
        }
        return new SuccessResponseData(replyList);
    }
}