From 42b7d05dfdf60ee67c876084a3240ff48a3bf3a5 Mon Sep 17 00:00:00 2001
From: inleft <inleft@qq.com>
Date: Wed, 02 Mar 2022 12:08:11 +0800
Subject: [PATCH] 日志添加评论控制

---
 snowy-main/src/main/java/vip/xiaonuo/modular/blogarticlecomment/controller/BlogArticleCommentOutsideController.java |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/snowy-main/src/main/java/vip/xiaonuo/modular/blogarticlecomment/controller/BlogArticleCommentOutsideController.java b/snowy-main/src/main/java/vip/xiaonuo/modular/blogarticlecomment/controller/BlogArticleCommentOutsideController.java
index 86ea2a4..f47adb4 100644
--- a/snowy-main/src/main/java/vip/xiaonuo/modular/blogarticlecomment/controller/BlogArticleCommentOutsideController.java
+++ b/snowy-main/src/main/java/vip/xiaonuo/modular/blogarticlecomment/controller/BlogArticleCommentOutsideController.java
@@ -35,6 +35,7 @@
 import vip.xiaonuo.core.exception.BlogException;
 import vip.xiaonuo.core.pojo.response.ResponseData;
 import vip.xiaonuo.core.pojo.response.SuccessResponseData;
+import vip.xiaonuo.modular.blogarticle.entity.BlogArticle;
 import vip.xiaonuo.modular.blogarticle.service.BlogArticleService;
 import vip.xiaonuo.modular.blogarticlecomment.entity.BlogArticleComment;
 import vip.xiaonuo.modular.blogarticlecomment.entity.BlogCommentVo;
@@ -71,13 +72,18 @@
             if (addDto.getArticleId() == null) {
                 throw new BlogException("评论类型为日志评论,日志id不能为空");
             }
-            if (blogArticleService.getById(addDto.getId()) == null) {
+            BlogArticle checkArticle = blogArticleService.getById(addDto.getId());
+            if (checkArticle == null) {
                 throw new BlogException("查询不到相关日志");
+            }
+
+            if (checkArticle.getIsAllowedComment().equals(MyConstant.No)) {
+                throw new BlogException("该日志评论已经关闭..");
             }
         }
         BlogArticleComment insert = new BlogArticleComment();
         BeanUtil.copyProperties(addDto, insert);
-        insert.setIsCheck(MyConstant.No);
+        insert.setIsCheck(MyConstant.Yes);
         insert.setIsEnable(MyConstant.Yes);
         insert.setIsReceiveCallback(addDto.getIsReceiveMail());
 
@@ -106,8 +112,7 @@
                 .orderByDesc(BlogArticleComment::getCreateDate)
                 .page(queryPage).getRecords();
 
-        int limitCount = 5;
-        String privateComment = "******";
+        int limitCount = 3;
         List<BlogCommentVo> res = commentList.stream().map(e -> {
                     BlogCommentVo vo = new BlogCommentVo();
                     BeanUtil.copyProperties(e, vo);
@@ -116,7 +121,7 @@
                     vo.setReplyList(replyList);
 
                     if (e.getAuthStatus().equals(MyConstant.AuthStatus.privateCode)) {
-                        vo.setCommentContent(privateComment);
+                        vo.setCommentContent(MyConstant.privateComment);
                     }
 
                     if (CollUtil.isNotEmpty(replyList)
@@ -142,13 +147,12 @@
             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);
+                vo.setCommentContent(MyConstant.privateComment);
             }
         }
 

--
Gitblit v1.9.1