소스 검색

物业管理端评论

tjf 4 달 전
부모
커밋
efed733e8e

+ 6 - 6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/communityNews/CommunityNewsController.java

@@ -30,7 +30,7 @@ public class CommunityNewsController extends BaseController {
     /**
      * 查询社区资讯列表
      */
-    @PreAuthorize("@ss.hasPermi('wuye:news:list')")
+    @PreAuthorize("@ss.hasPermi('wuYe:news:list')")
     @GetMapping("/list")
     public TableDataInfo list(CommunityNews communityNews) {
         startPage();
@@ -41,7 +41,7 @@ public class CommunityNewsController extends BaseController {
     /**
      * 导出社区资讯列表
      */
-    @PreAuthorize("@ss.hasPermi('wuye:news:export')")
+    @PreAuthorize("@ss.hasPermi('wuYe:news:export')")
     @Log(title = "社区资讯", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, CommunityNews communityNews) {
@@ -53,7 +53,7 @@ public class CommunityNewsController extends BaseController {
     /**
      * 获取社区资讯详细信息
      */
-    @PreAuthorize("@ss.hasPermi('wuye:news:query')")
+    @PreAuthorize("@ss.hasPermi('wuYe:news:query')")
     @GetMapping(value = "/{communityId}")
     public AjaxResult getInfo(@PathVariable("communityId") Long communityId) {
         return success(communityNewsService.selectCommunityNewsByCommunityId(communityId));
@@ -62,7 +62,7 @@ public class CommunityNewsController extends BaseController {
     /**
      * 新增社区资讯
      */
-    @PreAuthorize("@ss.hasPermi('wuye:news:add')")
+    @PreAuthorize("@ss.hasPermi('wuYe:news:add')")
     @Log(title = "社区资讯", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody CommunityNews communityNews) {
@@ -72,7 +72,7 @@ public class CommunityNewsController extends BaseController {
     /**
      * 修改社区资讯
      */
-    @PreAuthorize("@ss.hasPermi('wuye:news:edit')")
+    @PreAuthorize("@ss.hasPermi('wuYe:news:edit')")
     @Log(title = "社区资讯", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
     public AjaxResult edit(@RequestBody CommunityNews communityNews) {
@@ -82,7 +82,7 @@ public class CommunityNewsController extends BaseController {
     /**
      * 删除社区资讯
      */
-    @PreAuthorize("@ss.hasPermi('wuye:news:remove')")
+    @PreAuthorize("@ss.hasPermi('wuYe:news:remove')")
     @Log(title = "社区资讯", businessType = BusinessType.DELETE)
     @GetMapping("/delete/{communityIds}")
     public AjaxResult remove(@PathVariable Long[] communityIds) {

+ 2 - 2
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -193,11 +193,11 @@ public class Constants
     //------------------回复的key----------------------------
     //社区资讯回复点赞的人员集合的key value = 该回复的[userId]
     public static final String TWO_LIKE ="two_like:";
-    //对应用户点赞的回复key=my_like_two:{用户id} value = [评论id]
+    //对应用户点赞的回复key=two_my_like:{用户id} value = [评论id]
     public static final String TWO_MY_LIKE ="two_my_like:";
     //社区资讯评论点赞的数量 给数据库同步数据在 redis中增加一个有过期时间的key key=two_like_count_time:{评论id}#{数量} 过期时候value获取不到
     public static final String TWO_LIKE_COUNT_TIME ="two_like_count_time:";
-    //社区资讯评论点赞的数量永久key key=like_one_count:{评论id} value = 该评论的点赞数量
+    //社区资讯评论点赞的数量永久key key=two_like_count:{评论id} value = 该评论的点赞数量
     public static final String TWO_LIKE_COUNT="two_like_count:";
 
     //-------------------社区资讯收藏的key-----------------

+ 15 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/communityNews/vo/CommentChildrenVo.java

@@ -86,6 +86,19 @@ public class CommentChildrenVo implements Serializable {
      */
     private String isMyself;
 
+    /**
+     * 根评论id 1:根评论 2:子评论
+     */
+    private String isRoot;
+
+    public String getIsRoot() {
+        return isRoot;
+    }
+
+    public void setIsRoot(String isRoot) {
+        this.isRoot = isRoot;
+    }
+
     public String getIsMyself() {
         return isMyself;
     }
@@ -158,6 +171,7 @@ public class CommentChildrenVo implements Serializable {
         this.isLike = isLike;
     }
 
+
     @Override
     public String toString() {
         return "CommentChildrenVo{" +
@@ -170,6 +184,7 @@ public class CommentChildrenVo implements Serializable {
                 ", isLike='" + isLike + '\'' +
                 ", toRoot='" + toRoot + '\'' +
                 ", isMyself='" + isMyself + '\'' +
+                ", isRoot='" + isRoot + '\'' +
                 '}';
     }
 }

+ 13 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/communityNews/vo/CommentIndexVo.java

@@ -84,6 +84,18 @@ public class CommentIndexVo implements Serializable {
      * 是否是自己的评论
      */
     private String isMyself;
+    /**
+     * 根评论id 1:根评论 2:子评论
+     */
+    private String isRoot;
+
+    public String getIsRoot() {
+        return isRoot;
+    }
+
+    public void setIsRoot(String isRoot) {
+        this.isRoot = isRoot;
+    }
 
     public String getIsMyself() {
         return isMyself;
@@ -169,6 +181,7 @@ public class CommentIndexVo implements Serializable {
                 ", childrenList=" + childrenList +
                 ", childrenListCount=" + childrenListCount +
                 ", isMyself='" + isMyself + '\'' +
+                ", isRoot='" + isRoot + '\'' +
                 '}';
     }
 }

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/mapper/CommentContentMapper.java

@@ -63,10 +63,10 @@ public interface CommentContentMapper
 
     /**
      * 更新社区资讯评论内容表
-     * @param contentId 内容主键
+     * @param commentId 评论主键
      * @return
      */
-    public int updateCommentContentByContentId(Long contentId);
+    public int updateCommentContentByContentId(Long commentId);
 
     /**
      * 删除评论内容表数据

+ 24 - 11
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CommentIndexServiceImpl.java

@@ -17,11 +17,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
 import java.util.List;
 
-import static com.ruoyi.common.constant.Constants.COMMUNITY_COMMENT_COUNT;
-import static com.ruoyi.common.constant.Constants.TWO_MY_LIKE;
+import static com.ruoyi.common.constant.Constants.*;
 
 /**
  * 社区资讯评论Service业务层处理
@@ -145,7 +143,6 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
         int result = 0;
         int communityCommentCount = 0;
         //查找出所有parent_id = commentId的commentId
-        List<Long> commentIdList = new ArrayList<>();
         if (commentIndex != null && commentIndex.getUserId().equals(SecurityUtils.getUserId())) {
             //社区资讯id
             Long communityId = commentIndex.getCommunityId();
@@ -172,6 +169,20 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
                 }
                 redisCache.setCacheObject(communityCommentCountKey, communityCommentCount);
             }
+            //删除社区资讯评论点赞的数量永久key key=two_like_count:{评论id} value = 该评论的点赞数量
+            redisCache.deleteObject(TWO_LIKE_COUNT + commentId);
+            //社区资讯回复点赞的人员集合的key
+            redisCache.deleteObject(TWO_LIKE + commentId);
+            //对应用户点赞的回复key=two_my_like:{用户id} value = [评论id]
+            Long userId = SecurityUtils.getUserId();
+            List<Long> commentIdList = redisCache.getCacheList(TWO_MY_LIKE + userId);
+            if (commentIdList != null && commentIdList.size() > 0){
+                commentIdList.remove(commentId);
+            }
+            redisCache.deleteObject(TWO_MY_LIKE + userId);
+            if (commentIdList != null && commentIdList.size() > 0){
+                redisCache.setCacheList(TWO_MY_LIKE + userId,commentIdList);
+            }
 /*            //删除该资讯点赞的数量需要知道所有评论的id
             //首先获取该文章资讯的总点赞数量
             Integer likeCount = redisCache.getCacheObject(ONE_LIKE_COUNT + communityId);
@@ -226,10 +237,12 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
                     if (communityIdList.contains(commentChildrenVo.getId())) {
                         commentChildrenVo.setIsLike("Y");
                     }
-                    //是否是自己的评论
-                    if (commentChildrenVo.getCommentUser().getId().equals(userId)){
-                        commentChildrenVo.setIsMyself("Y");
-                    }
+                }
+            }
+            for (CommentChildrenVo commentChildrenVo : allComment) {
+                //是否是自己的评论
+                if (commentChildrenVo.getCommentUser().getId().equals(userId)) {
+                    commentChildrenVo.setIsMyself("Y");
                 }
             }
         }
@@ -257,9 +270,9 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
                         commentIndexVo.setIsLike("Y");
                     }
                     //是否是自己的评论
-                   if (commentIndexVo.getCommentUser().getId().equals(userId)){
-                       commentIndexVo.setIsMyself("Y");
-                   }
+                    if (commentIndexVo.getCommentUser().getId().equals(userId)) {
+                        commentIndexVo.setIsMyself("Y");
+                    }
                 }
             }
         }

+ 1 - 1
ruoyi-system/src/main/resources/mapper/system/CommentContentMapper.xml

@@ -94,7 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where content_id = #{contentId}
     </update>
     <update id="updateCommentContentByContentId" parameterType="CommentContent">
-        update comment_content set del_flag = 'Y' where content_id = #{contentId}
+        update comment_content set del_flag = 'Y' where comment_id = #{commentId}
     </update>
     <update id="deleteCommentContentByCommentId" parameterType="CommentContent">
         update comment_content set del_flag = 'Y' where comment_id in(select comment_id from comment_index where parent_id = #{commentId})

+ 4 - 0
ruoyi-system/src/main/resources/mapper/system/CommentIndexMapper.xml

@@ -49,6 +49,7 @@
     <!--回复列表返回给前端的格式-->
     <resultMap type="com.ruoyi.system.domain.communityNews.vo.CommentIndexVo" id="CommentIndexVoResult">
         <id property="id" column="ci_id"/>
+        <result property="isRoot" column="ci_is_root"/>
         <result property="content" column="ci_content"/>
         <result property="likeCount" column="ci_like_count"/>
         <result property="isLike" column="ci_is_like"/>
@@ -60,6 +61,7 @@
     </resultMap>
     <resultMap id="ChildrenListResult" type="com.ruoyi.system.domain.communityNews.vo.CommentChildrenVo">
         <result property="id" column="cl_id"/>
+        <result property="isRoot" column="cl_is_root"/>
         <result property="content" column="cl_content"/>
         <result property="likeCount" column="cl_like_count"/>
         <result property="isLike" column="cl_is_like"/>
@@ -143,6 +145,7 @@
     <select id="getRootComment" parameterType="CommentIndex" resultMap="CommentIndexVoResult">
         SELECT
             i.comment_id AS ci_id,
+            i.is_root AS ci_is_root,
             i.create_time AS ci_create_time,
             c.comment_content AS ci_content,
             i.user_id AS cu_one_id,
@@ -183,6 +186,7 @@
     <select id="getParentComment" parameterType="CommentIndex" resultMap="ChildrenListResult">
         SELECT
         i.comment_id AS cl_id,
+        i.is_root AS cl_is_root,
         i.user_id AS cu_two_id,
         i.nick_name AS cu_two_nick_name,
         i.avatar AS cu_two_avatar,