浏览代码

update 点赞

tjf 2 月之前
父节点
当前提交
53b993b870
共有 34 个文件被更改,包括 2178 次插入34 次删除
  1. 12 0
      ruoyi-common/ruoyi-common-redis/src/main/java/org/dromara/common/redis/utils/RedisUtils.java
  2. 1 1
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysUserVo.java
  3. 54 3
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/controller/communityNews/CommentIndexController.java
  4. 15 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/controller/communityNews/CommentLikesController.java
  5. 19 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/controller/communityNews/CommunityNewsController.java
  6. 10 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/controller/staffManage/StaffManageController.java
  7. 1 1
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/CommentContent.java
  8. 1 1
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/CommentIndex.java
  9. 2 1
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/CommentLikes.java
  10. 7 7
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/CommunityNews.java
  11. 1 1
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/bo/CommentContentBo.java
  12. 1 1
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/bo/CommunityNewsBo.java
  13. 190 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommentChildrenVo.java
  14. 84 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommentIndexShVo.java
  15. 187 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommentIndexVoOld.java
  16. 151 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommentInteractionVo.java
  17. 61 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommentUser.java
  18. 20 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommunityNewsVo.java
  19. 58 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/TargetUser.java
  20. 81 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/factory/AsyncFactory.java
  21. 56 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/manager/AsyncManager.java
  22. 4 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/mapper/CommentContentMapper.java
  23. 40 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/mapper/CommentIndexMapper.java
  24. 3 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/mapper/CommentLikesMapper.java
  25. 21 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/ICommentIndexService.java
  26. 7 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/ICommentLikesService.java
  27. 24 0
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/ICommunityNewsService.java
  28. 49 3
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/impl/CommentContentServiceImpl.java
  29. 256 9
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/impl/CommentIndexServiceImpl.java
  30. 337 1
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/impl/CommentLikesServiceImpl.java
  31. 176 4
      ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/impl/CommunityNewsServiceImpl.java
  32. 3 0
      ruoyi-modules/ruoyi-wuye/src/main/resources/mapper/wuYe/CommentContentMapper.xml
  33. 219 0
      ruoyi-modules/ruoyi-wuye/src/main/resources/mapper/wuYe/CommentIndexMapper.xml
  34. 27 1
      ruoyi-modules/ruoyi-wuye/src/main/resources/mapper/wuYe/CommentLikesMapper.xml

+ 12 - 0
ruoyi-common/ruoyi-common-redis/src/main/java/org/dromara/common/redis/utils/RedisUtils.java

@@ -448,6 +448,18 @@ public class RedisUtils {
         return rMap.get(hKey);
     }
 
+    /**
+     * 判断Hash中是否存在对应的
+     *
+     * @param key Redis键
+     * @param hKey Hash键
+     */
+    public static boolean hasCacheMapKey(final String key, final String hKey)
+    {
+        RMap<String, Object> rMap = CLIENT.getMap(key);
+        return rMap.isExists();
+    }
+
     /**
      * 删除Hash中的数据
      *

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysUserVo.java

@@ -76,7 +76,7 @@ public class SysUserVo implements Serializable {
     /**
      * 头像地址
      */
-    @Translation(type = TransConstant.OSS_ID_TO_URL)
+    //@Translation(type = TransConstant.OSS_ID_TO_URL)
     private Long avatar;
 
     /**

+ 54 - 3
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/controller/communityNews/CommentIndexController.java

@@ -1,8 +1,8 @@
 package org.dromara.controller.communityNews;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.dev33.satoken.annotation.SaIgnore;
 import jakarta.servlet.http.HttpServletResponse;
-import jakarta.validation.constraints.NotEmpty;
 import jakarta.validation.constraints.NotNull;
 import lombok.RequiredArgsConstructor;
 import org.dromara.common.core.domain.R;
@@ -14,8 +14,13 @@ import org.dromara.common.log.annotation.Log;
 import org.dromara.common.log.enums.BusinessType;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.satoken.utils.LoginHelper;
+import org.dromara.common.tenant.helper.TenantHelper;
 import org.dromara.common.web.core.BaseController;
+import org.dromara.domain.communityNews.CommentIndex;
 import org.dromara.domain.communityNews.bo.CommentIndexBo;
+import org.dromara.domain.communityNews.vo.CommentChildrenVo;
+import org.dromara.domain.communityNews.vo.CommentIndexShVo;
 import org.dromara.domain.communityNews.vo.CommentIndexVo;
 import org.dromara.service.ICommentIndexService;
 import org.springframework.validation.annotation.Validated;
@@ -46,6 +51,42 @@ public class CommentIndexController extends BaseController {
         return commentIndexService.queryPageList(bo, pageQuery);
     }
 
+    /**
+     * 查询社区资讯评论-----审核列表
+     */
+    @SaCheckPermission("wuYe:commentIndex:commentSh")
+    @GetMapping("/commentSh")
+    public TableDataInfo<CommentIndexShVo> commentSh(CommentIndexShVo commentIndexShVo, PageQuery pageQuery) {
+        commentIndexShVo.setTenantId(LoginHelper.getTenantId());
+        return TenantHelper.ignore(() -> {
+            return commentIndexService.commentSh(commentIndexShVo, pageQuery);
+        });
+    }
+
+    /**
+     * 根据查询所有一级评论组带子集总数组装成前端所需要的数据结构 带分页
+     */
+    @SaIgnore
+    @PostMapping(value = "/getRootComment", name = "查询一级评论")
+    public TableDataInfo<CommentIndexVo> getRootComment(@RequestBody CommentIndex commentIndex, PageQuery pageQuery) {
+        commentIndex.setTenantId(LoginHelper.getTenantId());
+        return TenantHelper.ignore(() -> {
+            return commentIndexService.getRootComment(commentIndex, pageQuery);
+        });
+    }
+
+    /**
+     * 根据parent_id查询所有评论组装成前端所需要的子集数据结构 带分页
+     */
+    @SaIgnore
+    @PostMapping(value = "/getParentComment", name = "查询子级评论")
+    public TableDataInfo<CommentChildrenVo> getParentComment(@RequestBody CommentIndex commentIndex, PageQuery pageQuery) {
+        commentIndex.setTenantId(LoginHelper.getTenantId());
+        return TenantHelper.ignore(() -> {
+            return commentIndexService.getParentComment(commentIndex, pageQuery);
+        });
+    }
+
     /**
      * 导出社区资讯评论列表
      */
@@ -91,16 +132,26 @@ public class CommentIndexController extends BaseController {
         return toAjax(commentIndexService.updateByBo(bo));
     }
 
-    /**
+/*    *//**
      * 删除社区资讯评论
      *
      * @param commentIds 主键串
-     */
+     *//*
     @SaCheckPermission("wuYe:commentIndex:remove")
     @Log(title = "社区资讯评论", businessType = BusinessType.DELETE)
     @GetMapping("/delete/{commentIds}")
     public R<Void> remove(@NotEmpty(message = "主键不能为空")
                           @PathVariable Long[] commentIds) {
         return toAjax(commentIndexService.deleteWithValidByIds(List.of(commentIds), true));
+    }*/
+
+    /**
+     * 逻辑删除社区资讯评论
+     */
+    @SaCheckPermission("wuYe:commentIndex:remove")
+    @Log(title = "社区资讯评论", businessType = BusinessType.DELETE)
+    @GetMapping("/delete/{commentId}")
+    public R<Void> remove(@PathVariable Long commentId) {
+        return toAjax(commentIndexService.deleteCommentIndexByCommentId(commentId));
     }
 }

+ 15 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/controller/communityNews/CommentLikesController.java

@@ -1,6 +1,7 @@
 package org.dromara.controller.communityNews;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.dev33.satoken.annotation.SaIgnore;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.constraints.NotEmpty;
 import jakarta.validation.constraints.NotNull;
@@ -15,8 +16,11 @@ import org.dromara.common.log.enums.BusinessType;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.web.core.BaseController;
+import org.dromara.domain.communityNews.CommentLikes;
 import org.dromara.domain.communityNews.bo.CommentLikesBo;
 import org.dromara.domain.communityNews.vo.CommentLikesVo;
+import org.dromara.factory.AsyncFactory;
+import org.dromara.manager.AsyncManager;
 import org.dromara.service.ICommentLikesService;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -103,4 +107,15 @@ public class CommentLikesController extends BaseController {
                           @PathVariable Long[] likesIds) {
         return toAjax(commentLikesService.deleteWithValidByIds(List.of(likesIds), true));
     }
+
+    /**
+     * 进行点赞操作
+     */
+    @SaIgnore
+    @PostMapping("/giveTheThumbs")
+    public R<Void> giveTheThumbs(@RequestBody CommentLikes commentLikes) {
+        AsyncManager.me().execute(AsyncFactory.giveTheThumbs(commentLikes));
+        System.out.println("点赞返回");
+        return R.ok();
+    }
 }

+ 19 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/controller/communityNews/CommunityNewsController.java

@@ -16,12 +16,14 @@ import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.web.core.BaseController;
 import org.dromara.domain.communityNews.bo.CommunityNewsBo;
+import org.dromara.domain.communityNews.vo.CommentInteractionVo;
 import org.dromara.domain.communityNews.vo.CommunityNewsVo;
 import org.dromara.service.ICommunityNewsService;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 社区资讯
@@ -103,4 +105,21 @@ public class CommunityNewsController extends BaseController {
                           @PathVariable Long[] communityIds) {
         return toAjax(communityNewsService.deleteWithValidByIds(List.of(communityIds), true));
     }
+
+    /**
+     * 获取未读互动数量
+     */
+    @SaCheckPermission("wuYe:news:getCommentInteractionCount")
+    @PostMapping("/getCommentInteractionCount")
+    public R<Integer> getCommentInteractionCount(@RequestBody CommentInteractionVo commentInteractionVo) {
+        return communityNewsService.getCommentInteractionCount(commentInteractionVo);
+    }
+    /**
+     * 获取未读互动列表
+     */
+    @SaCheckPermission("wuYe:news:getCommentInteraction")
+    @PostMapping("/getCommentInteraction")
+    public R<Map<String, Object>> getCommentInteraction(@RequestBody CommentInteractionVo commentInteractionVo) {
+        return communityNewsService.getCommentInteraction(commentInteractionVo);
+    }
 }

+ 10 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/controller/staffManage/StaffManageController.java

@@ -47,6 +47,16 @@ public class StaffManageController extends BaseController {
         return staffManageService.queryPageList(bo, pageQuery);
     }
 
+    /**
+     * 查询员工管理列表不分页
+     */
+    @SaCheckPermission("wuYe:staffManage:list")
+    @GetMapping("/listNoPage")
+    public TableDataInfo<StaffManageVo> listNoPage(StaffManageBo staffManage) {
+        List<StaffManageVo> list = staffManageService.queryList(staffManage);
+        return TableDataInfo.build(list);
+    }
+
     /**
      * 查询员工管理需要认证的列表
      */

+ 1 - 1
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/CommentContent.java

@@ -45,7 +45,7 @@ public class CommentContent extends TenantEntity {
     /**
      * 状态:1:待审核 2:审核通过 3:审核不通过 4:审核通过后下架
      */
-    private Long status;
+    private String status;
 
     /**
      * 类型:1:文字 2:图片

+ 1 - 1
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/CommentIndex.java

@@ -45,7 +45,7 @@ public class CommentIndex extends TenantEntity {
     /**
      * 根评论id 1:根评论 2:子评论
      */
-    private Long isRoot;
+    private Integer isRoot;
 
     /**
      * 父评论id

+ 2 - 1
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/CommentLikes.java

@@ -27,6 +27,8 @@ public class CommentLikes extends TenantEntity {
     @TableId(value = "likes_id")
     private Long likesId;
 
+    /** 社区资讯ID */
+    private Long communityId;
     /**
      * 点赞目标id
      */
@@ -68,5 +70,4 @@ public class CommentLikes extends TenantEntity {
      */
     private String remark;
 
-
 }

+ 7 - 7
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/CommunityNews.java

@@ -1,15 +1,14 @@
 package org.dromara.domain.communityNews;
 
-import org.dromara.common.tenant.core.TenantEntity;
-import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import org.dromara.common.translation.annotation.Translation;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.dromara.common.translation.constant.TransConstant;
+import org.dromara.common.tenant.core.TenantEntity;
 
 import java.io.Serial;
+import java.util.Date;
 
 /**
  * 社区资讯对象 community_news
@@ -47,8 +46,9 @@ public class CommunityNews extends TenantEntity {
     private String communityContent;
 
     /**
-     * 社区资讯状态(1正常 2关闭)
+     * 社区资讯状态(0正常 1关闭)
      */
+    @TableLogic
     private String status;
 
     /**

+ 1 - 1
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/bo/CommentContentBo.java

@@ -43,7 +43,7 @@ public class CommentContentBo extends BaseEntity {
     /**
      * 状态:1:待审核 2:审核通过 3:审核不通过 4:审核通过后下架
      */
-    private Long status;
+    private String status;
 
     /**
      * 类型:1:文字 2:图片

+ 1 - 1
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/bo/CommunityNewsBo.java

@@ -47,7 +47,7 @@ public class CommunityNewsBo extends BaseEntity {
     private String communityContent;
 
     /**
-     * 社区资讯状态(1正常 2关闭)
+     * 社区资讯状态(0正常 1关闭)
      */
     private String status;
 

+ 190 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommentChildrenVo.java

@@ -0,0 +1,190 @@
+package org.dromara.domain.communityNews.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 评论前端所需要格式主体的子集,子集里面是回复的人和被回复的人
+ * @Author: tjf
+ * @Date: 2025/2/25 15:55
+ * @Describe:
+ */
+public class CommentChildrenVo implements Serializable {
+    /**
+     * [
+     *         {
+     *           id: 1,
+     *           commentUser: {
+     *             id: 1,
+     *             nickName: "花非花",
+     *             avatar:
+     *               "http://qzapp.qlogo.cn/qzapp/101483738/6637A2B6611592A44A7699D14E13F7F7/50",
+     *           },
+     *           content:
+     *             "<a style='text-decoration:none;color: #409eff ' href='https://blog.csdn.net/qq_40942490?spm=1000.2115.3001.5113'>我的CSDN博客地址</a>[害羞][害羞][害羞]<br/>",
+     *           createDate: "2019-9-23 17:36:02",
+     *           childrenList: [
+     *             {
+     *               id: 2,
+     *               commentUser: {
+     *                 id: 2,
+     *                 nickName: "坏菠萝",
+     *                 avatar: "",
+     *               },
+     *               targetUser: {
+     *                 id: 1,
+     *                 nickName: "花非花",
+     *                 avatar:
+     *                   "http://qzapp.qlogo.cn/qzapp/101483738/6637A2B6611592A44A7699D14E13F7F7/50",
+     *               },
+     *               content: "真的就很棒!很Nice![爱你]",
+     *               createDate: "2019-9-23 17:45:26",
+     *             },
+     *           ],
+     */
+    private static final long serialVersionUID = 1L;
+    /**
+     * 评论主体id
+     */
+    private Long id;
+
+    /**
+     * 回复的人
+     */
+    private CommentUser commentUser;
+
+
+    /**
+     * 被回复的人
+     */
+    private TargetUser targetUser;
+
+    /**
+     * 内容
+     */
+    private String content;
+    /** 创建时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 点赞数量
+     */
+    private Integer likeCount;
+    /**
+     * 当前人员是否点赞
+     */
+    private String isLike;
+    /**
+     * 是否是二级回复的回复 Y:是 N:否
+     */
+    private String toRoot;
+    /**
+     * 是否是自己的评论 Y:是 N:否
+     */
+    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;
+    }
+
+    public void setIsMyself(String isMyself) {
+        this.isMyself = isMyself;
+    }
+
+    public String getToRoot() {
+        return toRoot;
+    }
+
+    public void setToRoot(String toRoot) {
+        this.toRoot = toRoot;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public CommentUser getCommentUser() {
+        return commentUser;
+    }
+
+    public void setCommentUser(CommentUser commentUser) {
+        this.commentUser = commentUser;
+    }
+
+    public TargetUser getTargetUser() {
+        return targetUser;
+    }
+
+    public void setTargetUser(TargetUser targetUser) {
+        this.targetUser = targetUser;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Integer getLikeCount() {
+        return likeCount;
+    }
+
+    public void setLikeCount(Integer likeCount) {
+        this.likeCount = likeCount;
+    }
+
+    public String getIsLike() {
+        return isLike;
+    }
+
+    public void setIsLike(String isLike) {
+        this.isLike = isLike;
+    }
+
+
+    @Override
+    public String toString() {
+        return "CommentChildrenVo{" +
+                "id=" + id +
+                ", commentUser=" + commentUser +
+                ", targetUser=" + targetUser +
+                ", content='" + content + '\'' +
+                ", createTime=" + createTime +
+                ", likeCount=" + likeCount +
+                ", isLike='" + isLike + '\'' +
+                ", toRoot='" + toRoot + '\'' +
+                ", isMyself='" + isMyself + '\'' +
+                ", isRoot='" + isRoot + '\'' +
+                '}';
+    }
+}

+ 84 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommentIndexShVo.java

@@ -0,0 +1,84 @@
+package org.dromara.domain.communityNews.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import org.dromara.domain.communityNews.CommentIndex;
+
+import java.io.Serializable;
+
+/**
+ * @Author: tjf
+ * @Date: 2025/2/26 17:19
+ * @Describe:
+ */
+@Data
+@ExcelIgnoreUnannotated
+@AutoMapper(target = CommentIndex.class)
+public class CommentIndexShVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /** 社区资讯评论ID */
+    private Long commentId;
+    /** 租户id */
+    private String tenantId;
+
+    /** 社区资讯ID */
+
+    private Long communityId;
+
+    /** 社区资讯标题 */
+
+    private String communityTitle;
+
+    /** 社区资讯类型(1:公告 2:通知 3:资讯) */
+
+    private String communityType;
+
+    /** 根评论id 1:根评论 2:子评论 */
+    private Integer isRoot;
+
+    /** 父评论id */
+
+    private Long parentId;
+
+    /** 用户id */
+
+    private Long userId;
+
+    /** 用户昵称 */
+
+    private String nickName;
+
+    /** 头像地址 */
+
+    private String avatar;
+
+    /** 所回复目标评论的用户id */
+
+    private Long toUserId;
+
+    /** 所回复目标评论的用户昵称 */
+
+    private String toNickName;
+
+    /** 所回复目标评论的头像地址 */
+
+    private String toAvatar;
+
+    /** 内容id */
+
+    private Long contentId;
+
+    /** 评论内容 */
+
+    private String commentContent;
+
+    /** 状态:1:待审核 2:审核通过 3:审核不通过 4:审核通过后下架 */
+
+    private String status;
+
+    /** 类型:1:文字 2:图片 */
+
+    private Integer type;
+}

+ 187 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommentIndexVoOld.java

@@ -0,0 +1,187 @@
+package org.dromara.domain.communityNews.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 评论前端所需要格式主体
+ * @Author: tjf
+ * @Date: 2025/2/25 15:49
+ * @Describe:
+ */
+public class CommentIndexVoOld implements Serializable {
+    /**
+     * [
+     *         {
+     *           id: 1,
+     *           commentUser: {
+     *             id: 1,
+     *             nickName: "花非花",
+     *             avatar:
+     *               "http://qzapp.qlogo.cn/qzapp/101483738/6637A2B6611592A44A7699D14E13F7F7/50",
+     *           },
+     *           content:
+     *             "<a style='text-decoration:none;color: #409eff ' href='https://blog.csdn.net/qq_40942490?spm=1000.2115.3001.5113'>我的CSDN博客地址</a>[害羞][害羞][害羞]<br/>",
+     *           createDate: "2019-9-23 17:36:02",
+     *           childrenList: [
+     *             {
+     *               id: 2,
+     *               commentUser: {
+     *                 id: 2,
+     *                 nickName: "坏菠萝",
+     *                 avatar: "",
+     *               },
+     *               targetUser: {
+     *                 id: 1,
+     *                 nickName: "花非花",
+     *                 avatar:
+     *                   "http://qzapp.qlogo.cn/qzapp/101483738/6637A2B6611592A44A7699D14E13F7F7/50",
+     *               },
+     *               content: "真的就很棒!很Nice![爱你]",
+     *               createDate: "2019-9-23 17:45:26",
+     *             },
+     *           ],
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 评论主体id
+     */
+    private Long id;
+    /**
+     * 回复的人
+     */
+    private CommentUser commentUser;
+    /**
+     * 内容
+     */
+    private String content;
+    /**
+     * 点赞数量
+     */
+    private Integer likeCount;
+    /**
+     * 当前人员是否点赞
+     */
+    private String isLike;
+    /** 创建时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 评论子集
+     */
+    private List<CommentChildrenVo> childrenList;
+    /**
+     * 子集总数
+     */
+    private  Integer childrenListCount;
+
+    /**
+     * 是否是自己的评论
+     */
+    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;
+    }
+
+    public void setIsMyself(String isMyself) {
+        this.isMyself = isMyself;
+    }
+
+    public Integer getChildrenListCount() {
+        return childrenListCount;
+    }
+
+    public void setChildrenListCount(Integer childrenListCount) {
+        this.childrenListCount = childrenListCount;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public CommentUser getCommentUser() {
+        return commentUser;
+    }
+
+    public void setCommentUser(CommentUser commentUser) {
+        this.commentUser = commentUser;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public Integer getLikeCount() {
+        return likeCount;
+    }
+
+    public void setLikeCount(Integer likeCount) {
+        this.likeCount = likeCount;
+    }
+
+    public String getIsLike() {
+        return isLike;
+    }
+
+    public void setIsLike(String isLike) {
+        this.isLike = isLike;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public List<CommentChildrenVo> getChildrenList() {
+        return childrenList;
+    }
+
+    public void setChildrenList(List<CommentChildrenVo> childrenList) {
+        this.childrenList = childrenList;
+    }
+
+    @Override
+    public String toString() {
+        return "CommentIndexVo{" +
+                "id=" + id +
+                ", commentUser=" + commentUser +
+                ", content='" + content + '\'' +
+                ", likeCount=" + likeCount +
+                ", isLike='" + isLike + '\'' +
+                ", createTime=" + createTime +
+                ", childrenList=" + childrenList +
+                ", childrenListCount=" + childrenListCount +
+                ", isMyself='" + isMyself + '\'' +
+                ", isRoot='" + isRoot + '\'' +
+                '}';
+    }
+}

+ 151 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommentInteractionVo.java

@@ -0,0 +1,151 @@
+package org.dromara.domain.communityNews.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 未读互动接收对象
+ * @Author: tjf
+ * @Date: 2025/3/4 9:09
+ * @Describe:
+ */
+public class CommentInteractionVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /** 目标id */
+    private Long targetId;
+
+    /** 目标类型(1:资讯评论 2:资讯点赞 3:资讯收藏 4:评论回复 5:回复点赞) */
+    private String targetType;
+    /**
+     * 目标标题
+     */
+    private String targetTitle;
+
+    /** 目标用户id */
+
+    private Long targetUserId;
+    /**
+     * 操作人员id
+     */
+    private Long userId;
+
+    /** 用户昵称 */
+
+    private String nickName;
+
+    /** 头像地址 */
+
+    private String avatar;
+
+    /** 创建时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+    /**
+     * 1:是新增 2:是删除
+     */
+    private String type;
+
+    /** 社区资讯ID 当是点赞回复的时候有值 */
+    private Long communityId;
+
+
+    public Long getCommunityId() {
+        return communityId;
+    }
+
+    public void setCommunityId(Long communityId) {
+        this.communityId = communityId;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public Long getTargetUserId() {
+        return targetUserId;
+    }
+
+    public void setTargetUserId(Long targetUserId) {
+        this.targetUserId = targetUserId;
+    }
+
+    public Long getTargetId() {
+        return targetId;
+    }
+
+    public void setTargetId(Long targetId) {
+        this.targetId = targetId;
+    }
+
+    public String getTargetType() {
+        return targetType;
+    }
+
+    public void setTargetType(String targetType) {
+        this.targetType = targetType;
+    }
+
+    public String getTargetTitle() {
+        return targetTitle;
+    }
+
+    public void setTargetTitle(String targetTitle) {
+        this.targetTitle = targetTitle;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    @Override
+    public String toString() {
+        return "CommentInteractionVo{" +
+                "targetId=" + targetId +
+                ", targetType='" + targetType + '\'' +
+                ", targetTitle='" + targetTitle + '\'' +
+                ", targetUserId=" + targetUserId +
+                ", userId=" + userId +
+                ", nickName='" + nickName + '\'' +
+                ", avatar='" + avatar + '\'' +
+                ", createTime=" + createTime +
+                ", type='" + type + '\'' +
+                ", communityId=" + communityId +
+                '}';
+    }
+}

+ 61 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommentUser.java

@@ -0,0 +1,61 @@
+package org.dromara.domain.communityNews.vo;
+
+import java.io.Serializable;
+
+/**
+ * 评论前端所需要格式回复的人
+ * @Author: tjf
+ * @Date: 2025/2/25 15:56
+ * @Describe:
+ */
+public class CommentUser implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * 人员的userID
+     */
+    private Long id;
+    /**
+     * 人员名称
+     */
+    private String nickName;
+    /**
+     * 头像
+     */
+    private String avatar;
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    @Override
+    public String toString() {
+        return "CommentUser{" +
+                "id=" + id +
+                ", nickName='" + nickName + '\'' +
+                ", avatar='" + avatar + '\'' +
+                '}';
+    }
+}

+ 20 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/CommunityNewsVo.java

@@ -147,5 +147,25 @@ public class CommunityNewsVo implements Serializable {
     @ExcelProperty(value = "备注")
     private String remark;
 
+    /**
+     * 是否有未读互动 N:否 Y:是
+     */
+    private String isInteraction;
+
+    /**
+     * 是否评论
+     */
+    private String isComment;
+
+    /**
+     * 是否点赞 N:未点赞 Y:点赞
+     */
+    private String isLike;
+
+
+    /**
+     * 是否收藏 N:未收藏 Y:收藏
+     */
+    private String isStar;
 
 }

+ 58 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/communityNews/vo/TargetUser.java

@@ -0,0 +1,58 @@
+package org.dromara.domain.communityNews.vo;
+
+import java.io.Serializable;
+
+/**
+ * 评论前端所需要格式被回复的人
+ * @Author: tjf
+ * @Date: 2025/2/25 15:54
+ * @Describe:
+ */
+public class TargetUser implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 人员的userID
+     */
+    private Long id;
+    /**
+     * 人员名称
+     */
+    private String nickName;
+    /**
+     * 头像
+     */
+    private String avatar;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    @Override
+    public String toString() {
+        return "TargetUser{" +
+                "id=" + id +
+                ", nickName='" + nickName + '\'' +
+                ", avatar='" + avatar + '\'' +
+                '}';
+    }
+}

+ 81 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/factory/AsyncFactory.java

@@ -0,0 +1,81 @@
+package org.dromara.factory;
+
+
+import org.dromara.common.core.utils.SpringUtils;
+import org.dromara.domain.communityNews.CommentLikes;
+import org.dromara.service.ICommentLikesService;
+
+import java.util.TimerTask;
+
+/**
+ * 异步工厂(产生任务用)
+ *
+ * @author ruoyi
+ */
+public class AsyncFactory
+{
+    /**
+     * 点赞操作
+     *
+     * @param commentLikes 点赞信息
+     * @return 任务task
+     */
+    public static TimerTask giveTheThumbs(final CommentLikes commentLikes)
+    {
+        return new TimerTask()
+        {
+            @Override
+            public void run()
+            {
+                System.out.println("进入异步点赞方法");
+                // 进行点赞操作
+                SpringUtils.getBean(ICommentLikesService.class).giveTheThumbs(commentLikes);
+                System.out.println("完成异步点赞方法");
+            }
+        };
+    }
+
+    /**
+     * 社区资讯收藏操作
+     *
+     * @param commentStars 收藏信息
+     * @return 任务task
+     */
+/*    public static TimerTask getStars(final CommentStars commentStars)
+    {
+        return new TimerTask()
+        {
+            @Override
+            public void run()
+            {
+                System.out.println("进入异步社区资讯收藏方法");
+                // 进行收藏操作
+                SpringUtils.getBean(ICommentStarsService.class).getStars(commentStars);
+                System.out.println("完成异步社区资讯收藏方法");
+            }
+        };
+    }
+
+    *//**
+     * 党建收藏操作
+     *
+     * @param commentStars 收藏信息
+     * @return 任务task
+     *//*
+    public static TimerTask getPartyNewsStars(final CommentStars commentStars)
+    {
+        return new TimerTask()
+        {
+            @Override
+            public void run()
+            {
+                System.out.println("进入异步党建收藏方法");
+                // 进行收藏操作
+                SpringUtils.getBean(ICommentStarsService.class).getPartyNewsStars(commentStars);
+                System.out.println("完成异步党建收藏方法");
+            }
+        };
+    }*/
+
+
+}

+ 56 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/manager/AsyncManager.java

@@ -0,0 +1,56 @@
+package org.dromara.manager;
+
+import org.dromara.common.core.utils.SpringUtils;
+import org.dromara.common.core.utils.Threads;
+
+import java.util.TimerTask;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 异步任务管理器
+ *
+ * @author ruoyi
+ */
+public class AsyncManager
+{
+    /**
+     * 操作延迟10毫秒
+     */
+    private final int OPERATE_DELAY_TIME = 10;
+
+    /**
+     * 异步操作任务调度线程池
+     */
+    private ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
+
+    /**
+     * 单例模式
+     */
+    private AsyncManager(){}
+
+    private static AsyncManager me = new AsyncManager();
+
+    public static AsyncManager me()
+    {
+        return me;
+    }
+
+    /**
+     * 执行任务
+     *
+     * @param task 任务
+     */
+    public void execute(TimerTask task)
+    {
+        executor.schedule(task, OPERATE_DELAY_TIME, TimeUnit.MILLISECONDS);
+    }
+
+    /**
+     * 停止任务线程池
+     */
+    public void shutdown()
+    {
+        Threads.shutdownAndAwaitTermination(executor);
+    }
+}

+ 4 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/mapper/CommentContentMapper.java

@@ -1,6 +1,7 @@
 package org.dromara.mapper;
 
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 import org.dromara.domain.communityNews.CommentContent;
 import org.dromara.domain.communityNews.vo.CommentContentVo;
@@ -13,4 +14,7 @@ import org.dromara.domain.communityNews.vo.CommentContentVo;
  */
 public interface CommentContentMapper extends BaseMapperPlus<CommentContent, CommentContentVo> {
 
+    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
+    int deleteCommentContentByCommentId(Long commentId);
+
 }

+ 40 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/mapper/CommentIndexMapper.java

@@ -1,9 +1,16 @@
 package org.dromara.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
 import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 import org.dromara.domain.communityNews.CommentIndex;
+import org.dromara.domain.communityNews.vo.CommentChildrenVo;
+import org.dromara.domain.communityNews.vo.CommentIndexShVo;
 import org.dromara.domain.communityNews.vo.CommentIndexVo;
 
+import java.util.List;
+
 /**
  * 社区资讯评论Mapper接口
  *
@@ -12,4 +19,37 @@ import org.dromara.domain.communityNews.vo.CommentIndexVo;
  */
 public interface CommentIndexMapper extends BaseMapperPlus<CommentIndex, CommentIndexVo> {
 
+    /**
+     * 查询社区资讯评论-----审核列表
+     */
+    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
+    Page<CommentIndexShVo> commentSh(@Param("page") Page<CommentIndexShVo> page, @Param("commentIndexShVo") CommentIndexShVo commentIndexShVo);
+
+    /**
+     * 根据查询所有一级评论组带子集总数组装成前端所需要的数据结构 带分页
+     *
+     * @param commentIndex
+     * @return
+     */
+    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
+    Page<CommentIndexVo> getRootComment(@Param("page") Page<CommentIndex> page, @Param("commentIndex") CommentIndex commentIndex);
+
+
+    /**
+     * 根据parent_id查询所有评论组装成前端所需要的子集数据结构 带分页
+     *
+     * @param commentIndex
+     * @return
+     */
+    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
+    Page<CommentChildrenVo> getParentComment(@Param("page") Page<CommentIndex> page,CommentIndex commentIndex);
+
+    /**
+     * //查找出所有parent_id = commentId的commentId
+     * @param commentId
+     * @return
+     */
+    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
+     List<CommentIndex> selectCommentIdListByCommentId(Long commentId);
+
 }

+ 3 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/mapper/CommentLikesMapper.java

@@ -1,6 +1,7 @@
 package org.dromara.mapper;
 
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 import org.dromara.domain.communityNews.CommentLikes;
 import org.dromara.domain.communityNews.vo.CommentLikesVo;
@@ -12,5 +13,7 @@ import org.dromara.domain.communityNews.vo.CommentLikesVo;
  * @date 2025-04-11
  */
 public interface CommentLikesMapper extends BaseMapperPlus<CommentLikes, CommentLikesVo> {
+    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
+    CommentLikes selectCommentLikes(CommentLikes commentLikes);
 
 }

+ 21 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/ICommentIndexService.java

@@ -2,7 +2,10 @@ package org.dromara.service;
 
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.domain.communityNews.CommentIndex;
 import org.dromara.domain.communityNews.bo.CommentIndexBo;
+import org.dromara.domain.communityNews.vo.CommentChildrenVo;
+import org.dromara.domain.communityNews.vo.CommentIndexShVo;
 import org.dromara.domain.communityNews.vo.CommentIndexVo;
 
 import java.util.Collection;
@@ -32,6 +35,20 @@ public interface ICommentIndexService {
      * @return 社区资讯评论分页列表
      */
     TableDataInfo<CommentIndexVo> queryPageList(CommentIndexBo bo, PageQuery pageQuery);
+    /**
+     * 查询社区资讯评论-----审核列表
+     */
+    TableDataInfo<CommentIndexShVo> commentSh(CommentIndexShVo bo, PageQuery pageQuery);
+    /**
+     * 根据查询所有一级评论组带子集总数组装成前端所需要的数据结构 带分页
+     * @param commentIndex
+     * @return
+     */
+    TableDataInfo<CommentIndexVo> getRootComment(CommentIndex commentIndex, PageQuery pageQuery);
+    /**
+     * 根据parent_id查询所有评论组装成前端所需要的子集数据结构 带分页
+     */
+    TableDataInfo<CommentChildrenVo> getParentComment(CommentIndex commentIndex, PageQuery pageQuery);
 
     /**
      * 查询符合条件的社区资讯评论列表
@@ -65,4 +82,8 @@ public interface ICommentIndexService {
      * @return 是否删除成功
      */
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+    /**
+     * 逻辑删除社区资讯评论
+     */
+    Boolean deleteCommentIndexByCommentId(Long commentId);
 }

+ 7 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/ICommentLikesService.java

@@ -1,7 +1,9 @@
 package org.dromara.service;
 
+import org.dromara.common.core.domain.R;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.domain.communityNews.CommentLikes;
 import org.dromara.domain.communityNews.bo.CommentLikesBo;
 import org.dromara.domain.communityNews.vo.CommentLikesVo;
 
@@ -65,4 +67,9 @@ public interface ICommentLikesService {
      * @return 是否删除成功
      */
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+    /**
+     * 进行点赞操作
+     */
+     R<Void> giveTheThumbs(CommentLikes commentLikes);
 }

+ 24 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/ICommunityNewsService.java

@@ -1,12 +1,15 @@
 package org.dromara.service;
 
+import org.dromara.common.core.domain.R;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.domain.communityNews.bo.CommunityNewsBo;
+import org.dromara.domain.communityNews.vo.CommentInteractionVo;
 import org.dromara.domain.communityNews.vo.CommunityNewsVo;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 社区资讯Service接口
@@ -65,4 +68,25 @@ public interface ICommunityNewsService {
      * @return 是否删除成功
      */
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+    /**
+     * 设置未读互动
+     * @param commentInteractionVo 接收未读互动的参数
+     */
+    public void setCommentInteraction(CommentInteractionVo commentInteractionVo);
+
+    /**
+     * 获取未读互动列表
+     *
+     * @param commentInteractionVo
+     * @return
+     */
+    public R<Map<String, Object>> getCommentInteraction(CommentInteractionVo commentInteractionVo);
+
+    /**
+     * 获取未读互动数量
+     *
+     * @param commentInteractionVo
+     * @return
+     */
+    public R<Integer> getCommentInteractionCount(CommentInteractionVo commentInteractionVo);
 }

+ 49 - 3
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/impl/CommentContentServiceImpl.java

@@ -4,21 +4,30 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.utils.DateUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.domain.communityNews.CommentContent;
+import org.dromara.domain.communityNews.CommentIndex;
+import org.dromara.domain.communityNews.CommunityNews;
 import org.dromara.domain.communityNews.bo.CommentContentBo;
 import org.dromara.domain.communityNews.vo.CommentContentVo;
+import org.dromara.domain.communityNews.vo.CommentInteractionVo;
 import org.dromara.mapper.CommentContentMapper;
+import org.dromara.mapper.CommentIndexMapper;
+import org.dromara.mapper.CommunityNewsMapper;
 import org.dromara.service.ICommentContentService;
+import org.dromara.service.ICommunityNewsService;
 import org.springframework.stereotype.Service;
 
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import static org.dromara.common.core.constant.Constants.*;
+
 /**
  * 社区资讯评论内容Service业务层处理
  *
@@ -30,6 +39,9 @@ import java.util.Map;
 public class CommentContentServiceImpl implements ICommentContentService {
 
     private final CommentContentMapper baseMapper;
+    private final CommentIndexMapper commentIndexMapper;
+    private final CommunityNewsMapper communityNewsMapper;
+    private final ICommunityNewsService communityNewsService;
 
     /**
      * 查询社区资讯评论内容
@@ -106,9 +118,43 @@ public class CommentContentServiceImpl implements ICommentContentService {
      */
     @Override
     public Boolean updateByBo(CommentContentBo bo) {
-        CommentContent update = MapstructUtils.convert(bo, CommentContent.class);
-        validEntityBeforeSave(update);
-        return baseMapper.updateById(update) > 0;
+        CommentContent commentContent = MapstructUtils.convert(bo, CommentContent.class);
+        validEntityBeforeSave(commentContent);
+        boolean flag = baseMapper.updateById(commentContent) > 0;
+        if (TWO.equals(commentContent.getStatus())) {
+            CommentIndex commentIndex = commentIndexMapper.selectById(commentContent.getCommentId());
+            Long communityId = commentIndex.getCommunityId();
+            Long userId = commentIndex.getUserId();
+            //评论审核通过
+            //------设置未读互动,评论的谁就给谁在redis中新增一条未读的互动--------
+            CommentInteractionVo commentInteractionVo = new CommentInteractionVo();
+            Integer isRoot = commentIndex.getIsRoot();
+            //默认是子评论
+            commentInteractionVo.setTargetType(FOR);
+            commentInteractionVo.setTargetUserId(commentIndex.getToUserId());
+            //默认标题是子评论的评论
+            commentInteractionVo.setTargetTitle(commentIndex.getCommentContent());
+            if (1 == isRoot) {
+                //说明是根评论
+                //查询该资讯是谁发的
+                CommunityNews communityNews = communityNewsMapper.selectById(communityId);
+                commentInteractionVo.setTargetUserId(communityNews.getUserId());
+                commentInteractionVo.setTargetType(ONE);
+                //社区资讯标题
+                commentInteractionVo.setTargetTitle(commentIndex.getCommunityTitle());
+            }
+            commentInteractionVo.setUserId(userId);
+            commentInteractionVo.setAvatar(commentIndex.getAvatar());
+            commentInteractionVo.setNickName(commentIndex.getNickName());
+            commentInteractionVo.setCreateTime(DateUtils.getNowDate());
+            commentInteractionVo.setTargetId(commentIndex.getCommentId());
+            //新增
+            commentInteractionVo.setType(ONE);
+            communityNewsService.setCommentInteraction(commentInteractionVo);
+            //----------------------设置未读互动完成--------
+        }
+
+        return flag;
     }
 
     /**

+ 256 - 9
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/impl/CommentIndexServiceImpl.java

@@ -1,24 +1,38 @@
 package org.dromara.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.ObjectUtils;
+import org.dromara.common.core.utils.DateUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.redis.utils.RedisUtils;
+import org.dromara.common.satoken.utils.LoginHelper;
+import org.dromara.domain.communityNews.CommentContent;
 import org.dromara.domain.communityNews.CommentIndex;
+import org.dromara.domain.communityNews.CommunityNews;
 import org.dromara.domain.communityNews.bo.CommentIndexBo;
+import org.dromara.domain.communityNews.vo.CommentChildrenVo;
+import org.dromara.domain.communityNews.vo.CommentIndexShVo;
 import org.dromara.domain.communityNews.vo.CommentIndexVo;
+import org.dromara.mapper.CommentContentMapper;
 import org.dromara.mapper.CommentIndexMapper;
+import org.dromara.mapper.CommunityNewsMapper;
 import org.dromara.service.ICommentIndexService;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import static org.dromara.common.core.constant.Constants.*;
+
 /**
  * 社区资讯评论Service业务层处理
  *
@@ -30,7 +44,8 @@ import java.util.Map;
 public class CommentIndexServiceImpl implements ICommentIndexService {
 
     private final CommentIndexMapper baseMapper;
-
+    private final CommentContentMapper commentContentMapper;
+    private final CommunityNewsMapper communityNewsMapper;
     /**
      * 查询社区资讯评论
      *
@@ -38,7 +53,7 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
      * @return 社区资讯评论
      */
     @Override
-    public CommentIndexVo queryById(Long commentId){
+    public CommentIndexVo queryById(Long commentId) {
         return baseMapper.selectVoById(commentId);
     }
 
@@ -56,6 +71,59 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
         return TableDataInfo.build(result);
     }
 
+    /**
+     * 查询社区资讯评论-----审核列表
+     */
+    @Override
+    public TableDataInfo<CommentIndexShVo> commentSh(CommentIndexShVo commentIndexShVo, PageQuery pageQuery) {
+        Page<CommentIndexShVo> result = baseMapper.commentSh(pageQuery.build(), commentIndexShVo);
+        return TableDataInfo.build(result);
+    }
+
+    /**
+     * 根据查询所有一级评论组带子集总数组装成前端所需要的数据结构 带分页
+     *
+     * @param commentIndex
+     * @return
+     */
+    @Override
+    public TableDataInfo<CommentIndexVo> getRootComment(CommentIndex commentIndex, PageQuery pageQuery) {
+        Page<CommentIndexVo> result = baseMapper.getRootComment(pageQuery.build(), commentIndex);
+        return TableDataInfo.build(result);
+    }
+
+    /**
+     * 根据parent_id查询所有评论组装成前端所需要的子集数据结构 带分页
+     */
+    @Override
+    public TableDataInfo<CommentChildrenVo> getParentComment(CommentIndex commentIndex, PageQuery pageQuery) {
+        Long userId = LoginHelper.getUserId();
+        Page<CommentChildrenVo> parentComment = baseMapper.getParentComment(pageQuery.build(), commentIndex);
+        List<CommentChildrenVo> allComment = parentComment.getRecords();
+        //要判断所有评论当前人员是否点赞过
+        if (allComment != null && allComment.size() > 0) {
+            //要判断所有评论当前人员是否点赞过
+            //该用户点赞回复的key
+            String myLikeTwoKey = TWO_MY_LIKE + userId;
+            List<Long> communityIdList = RedisUtils.getCacheList(myLikeTwoKey);
+            if (communityIdList != null && communityIdList.size() > 0) {
+                for (CommentChildrenVo commentChildrenVo : allComment) {
+                    if (communityIdList.contains(commentChildrenVo.getId())) {
+                        commentChildrenVo.setIsLike("Y");
+                    }
+                }
+            }
+            for (CommentChildrenVo commentChildrenVo : allComment) {
+                //是否是自己的评论
+                if (commentChildrenVo.getCommentUser().getId().equals(userId)) {
+                    commentChildrenVo.setIsMyself("Y");
+                }
+            }
+        }
+        return TableDataInfo.build(parentComment);
+    }
+
+
     /**
      * 查询符合条件的社区资讯评论列表
      *
@@ -97,11 +165,33 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
      */
     @Override
     public Boolean insertByBo(CommentIndexBo bo) {
-        CommentIndex add = MapstructUtils.convert(bo, CommentIndex.class);
-        validEntityBeforeSave(add);
-        boolean flag = baseMapper.insert(add) > 0;
-        if (flag) {
-            bo.setCommentId(add.getCommentId());
+        CommentIndex commentIndex = MapstructUtils.convert(bo, CommentIndex.class);
+        validEntityBeforeSave(commentIndex);
+        boolean flag = true;
+        //有社区资讯ID才能新增评论
+        Long communityId = commentIndex.getCommunityId();
+        if (communityId != null) {
+            Long userId = commentIndex.getUserId();
+            //需要插入评论内容表
+            CommentContent commentContent = new CommentContent();
+            commentContent.setUserId(userId);
+            commentContent.setCommentContent(commentIndex.getCommentContent());
+            commentContentMapper.insert(commentContent);
+            commentIndex.setCreateTime(DateUtils.getNowDate());
+            commentIndex.setContentId(commentContent.getContentId());
+            flag = baseMapper.insert(commentIndex) > 0;
+            //再把评论内容表更新上资讯评论表id
+            commentContent.setCommentId(commentIndex.getCommentId());
+            commentContentMapper.updateById(commentContent);
+            //记录该社区资讯评论的数量
+            String communityCommentCountKey = COMMUNITY_COMMENT_COUNT + communityId;
+            Integer communityCommentCount = RedisUtils.getCacheObject(communityCommentCountKey);
+            if (communityCommentCount == null) {
+                RedisUtils.setCacheObject(communityCommentCountKey, 1);
+            } else {
+                //评论数量+1
+                RedisUtils.setCacheObject(communityCommentCountKey, communityCommentCount + 1);
+            }
         }
         return flag;
     }
@@ -122,7 +212,7 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
     /**
      * 保存前的数据校验
      */
-    private void validEntityBeforeSave(CommentIndex entity){
+    private void validEntityBeforeSave(CommentIndex entity) {
         //TODO 做一些数据校验,如唯一约束
     }
 
@@ -135,9 +225,166 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
      */
     @Override
     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
-        if(isValid){
+        if (isValid) {
             //TODO 做一些业务上的校验,判断是否需要校验
         }
         return baseMapper.deleteByIds(ids) > 0;
     }
+
+    /**
+     * 逻辑删除社区资讯评论
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean deleteCommentIndexByCommentId(Long commentId) {
+        //todo 管理员能删除评论
+        //只能删除自己的评论
+        CommentIndex commentIndex = baseMapper.selectById(commentId);
+        Boolean flag = false;
+        int result = 0;
+        int communityCommentCount = 0;
+        Long userId = LoginHelper.getUserId();
+        //查找出所有parent_id = commentId的commentId
+        if (commentIndex != null && commentIndex.getUserId().equals(userId)) {
+            //社区资讯id
+            Long communityId = commentIndex.getCommunityId();
+            commentIndex.setDelFlag(Y);
+            flag = baseMapper.updateById(commentIndex) > 0;
+            CommentContent commentContent = new CommentContent();
+            commentContent.setCommentId(commentId);
+            commentContent.setDelFlag(Y);
+            //删除评论内容表数据
+            commentContentMapper.updateById(commentContent);
+            //如果是根评论删除,删除所有子评论
+            if (1 == commentIndex.getIsRoot()) {
+                //查找出所有parent_id = commentId的commentId
+                //commentIdList = commentIndexMapper.selectCommentIdListByCommentId(commentId);
+                int i = baseMapper.update(commentIndex, new LambdaUpdateWrapper<CommentIndex>().eq(CommentIndex::getParentId, commentId));
+                result = result + i;
+                //删除评论内容表子集数据
+                commentContentMapper.deleteCommentContentByCommentId(commentId);
+            }
+            //删除该资讯的评论数量
+            String communityCommentCountKey = COMMUNITY_COMMENT_COUNT + communityId;
+            communityCommentCount = RedisUtils.getCacheObject(communityCommentCountKey);
+            if (communityCommentCount != 0) {
+                //删除所有的评论数量 = 根评论数量+子评论数量
+                communityCommentCount = communityCommentCount - result;
+                if (communityCommentCount < 0) {
+                    communityCommentCount = 0;
+                }
+                RedisUtils.setCacheObject(communityCommentCountKey, communityCommentCount);
+            }
+            //删除社区资讯评论点赞的数量永久key key=two_like_count:{评论id} value = 该评论的点赞数量
+            RedisUtils.deleteObject(TWO_LIKE_COUNT + commentId);
+            //社区资讯回复点赞的人员集合的key
+            RedisUtils.deleteObject(TWO_LIKE + commentId);
+            //对应用户点赞的回复key=two_my_like:{用户id} value = [评论id]
+            List<Long> commentIdList = RedisUtils.getCacheList(TWO_MY_LIKE + userId);
+            if (commentIdList != null && commentIdList.size() > 0) {
+                commentIdList.remove(commentId);
+            }
+            RedisUtils.deleteObject(TWO_MY_LIKE + userId);
+            if (commentIdList != null && commentIdList.size() > 0) {
+                RedisUtils.setCacheList(TWO_MY_LIKE + userId, commentIdList);
+            }
+/*            //删除该资讯点赞的数量需要知道所有评论的id
+            //首先获取该文章资讯的总点赞数量
+            Integer likeCount = redisCache.getCacheObject(ONE_LIKE_COUNT + communityId);
+            //再获取删除的评论的点赞数量
+            Integer commentLikeCount = redisCache.getCacheObject(TWO_LIKE_COUNT + commentId);
+            //所有子集的点赞数量
+            int commentLikeChildrenCount = 0;
+            if (commentIdList.size() > 0) {
+                //说明删除了子集、获取所有子集的点赞数量
+                for (Long commentIdChildren : commentIdList) {
+                    String commentLikeChildrenCountString = redisCache.getCacheObject(TWO_LIKE_COUNT + commentIdChildren);
+                    if (StringUtils.isNotBlank(commentLikeChildrenCountString)) {
+                        commentLikeChildrenCount = commentLikeChildrenCount + Integer.parseInt(commentLikeChildrenCountString);
+                    }
+                }
+            }
+            if (commentLikeCount == null){
+                commentLikeCount = 0;
+            }
+            if (likeCount == null){
+                likeCount = 0;
+            }
+            //把删除后点赞数量写入到redis
+            likeCount = likeCount - commentLikeCount - commentLikeChildrenCount;
+            if (likeCount < 0){
+                likeCount = 0;
+            }
+            redisCache.setCacheObject(ONE_LIKE_COUNT + communityId, likeCount);*/
+            //删除评论需要根据这个评论是根评论还子评论,根评论删除对应资讯发布人的未读互动里面对应的值(如果有)根评论还会删除所有子评论,子评论删除评论对象的未读互动
+            Integer isRoot = commentIndex.getIsRoot();
+            if (1 == isRoot) {
+                //如果是根评论先查询是否有子集评论
+                List<CommentIndex> commentIndexList = baseMapper.selectCommentIdListByCommentId(commentId);
+                if (commentIndexList != null && commentIndexList.size() > 0) {
+                    for (CommentIndex index : commentIndexList) {
+                        //删除未读互动中的子评论相关信息
+                        deleteCommentChildren(index);
+                    }
+                }
+                //删除根评论相关信息
+                //根据资讯id查询资讯发布人的id
+                CommunityNews communityNews = communityNewsMapper.selectById(communityId);
+                Long toUserId = communityNews.getUserId();
+                String commentInteractionUserKey = COMMENT_INTERACTION_USER + toUserId;
+                //hKey={targetType:targetId}
+                String hKey = ONE + ":" + commentId;
+                if (RedisUtils.hasCacheMapKey(commentInteractionUserKey, hKey)) {
+                    //说明有对应的未读互动删除对应的key
+                    RedisUtils.delCacheMapValue(commentInteractionUserKey, hKey);
+                    //目标人员的未读数量-1
+                    String commentInteractionUserCountKey = COMMENT_INTERACTION_USER_COUNT + toUserId;
+                    Object commentInteractionUserCount = RedisUtils.getCacheObject(commentInteractionUserCountKey);
+                    if (ObjectUtils.isNotEmpty(commentInteractionUserCount)) {
+                        RedisUtils.setCacheObject(commentInteractionUserCountKey, Math.max(Integer.parseInt(commentInteractionUserCount.toString()) - 1, 0));
+                    }
+                    //对应资讯下的未读数量-1
+                    Object communityUserCount = RedisUtils.getCacheMapValue(COMMENT_INTERACTION_COMMUNITY_USER_COUNT + toUserId, communityId.toString());
+                    if (ObjectUtils.isNotEmpty(communityUserCount)) {
+                        RedisUtils.setCacheMapValue(COMMENT_INTERACTION_COMMUNITY_USER_COUNT + toUserId, communityId.toString(), Math.max(Integer.parseInt(communityUserCount.toString()) - 1, 0));
+                    }
+                }
+            } else {
+                //删除未读互动中的子评论相关信息
+                deleteCommentChildren(commentIndex);
+            }
+        }
+        return flag;
+    }
+    /**
+     * 删除未读互动中的子评论相关信息
+     *
+     * @param commentIndex
+     */
+    public void deleteCommentChildren(CommentIndex commentIndex) {
+        Long commentId = commentIndex.getCommentId();
+        Long communityId = commentIndex.getCommunityId();
+        //子评论
+        //获取到回复的人的id
+        Long toUserId = commentIndex.getToUserId();
+        //判断该用户是否有未读的子评论互动
+        String commentInteractionUserKey = COMMENT_INTERACTION_USER + toUserId;
+        //hKey={targetType:targetId}
+        String hKey = FOR + ":" + commentId;
+        if (RedisUtils.hasCacheMapKey(commentInteractionUserKey, hKey)) {
+            //说明有对应的未读互动删除对应的key
+            RedisUtils.delCacheMapValue(commentInteractionUserKey, hKey);
+            //目标人员的未读数量-1
+            String commentInteractionUserCountKey = COMMENT_INTERACTION_USER_COUNT + toUserId;
+            Object commentInteractionUserCount = RedisUtils.getCacheObject(commentInteractionUserCountKey);
+            if (ObjectUtils.isNotEmpty(commentInteractionUserCount)) {
+                RedisUtils.setCacheObject(commentInteractionUserCountKey, Math.max(Integer.parseInt(commentInteractionUserCount.toString()) - 1, 0));
+            }
+            //对应资讯下的未读数量-1
+            Object communityUserCount = RedisUtils.getCacheMapValue(COMMENT_INTERACTION_COMMUNITY_USER_COUNT + toUserId, communityId.toString());
+            if (ObjectUtils.isNotEmpty(communityUserCount)) {
+                RedisUtils.setCacheMapValue(COMMENT_INTERACTION_COMMUNITY_USER_COUNT + toUserId, communityId.toString(), Math.max(Integer.parseInt(communityUserCount.toString()) - 1, 0));
+            }
+        }
+    }
 }

+ 337 - 1
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/impl/CommentLikesServiceImpl.java

@@ -4,21 +4,34 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.domain.R;
+import org.dromara.common.core.utils.DateUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.redis.utils.RedisUtils;
+import org.dromara.domain.communityNews.CommentIndex;
 import org.dromara.domain.communityNews.CommentLikes;
+import org.dromara.domain.communityNews.CommunityNews;
 import org.dromara.domain.communityNews.bo.CommentLikesBo;
+import org.dromara.domain.communityNews.vo.CommentInteractionVo;
 import org.dromara.domain.communityNews.vo.CommentLikesVo;
+import org.dromara.mapper.CommentIndexMapper;
 import org.dromara.mapper.CommentLikesMapper;
+import org.dromara.mapper.CommunityNewsMapper;
 import org.dromara.service.ICommentLikesService;
+import org.dromara.service.ICommunityNewsService;
 import org.springframework.stereotype.Service;
 
+import java.time.Duration;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import static org.dromara.common.core.constant.Constants.*;
+
 /**
  * 社区资讯点赞Service业务层处理
  *
@@ -30,7 +43,9 @@ import java.util.Map;
 public class CommentLikesServiceImpl implements ICommentLikesService {
 
     private final CommentLikesMapper baseMapper;
-
+    private final CommunityNewsMapper communityNewsMapper;
+    private final ICommunityNewsService communityNewsService;
+    private final CommentIndexMapper commentIndexMapper;
     /**
      * 查询社区资讯点赞
      *
@@ -132,4 +147,325 @@ public class CommentLikesServiceImpl implements ICommentLikesService {
         }
         return baseMapper.deleteByIds(ids) > 0;
     }
+
+    /**
+     * 进行点赞操作
+     * //点赞数据存储到redis,设置redis过期key监听,继承onMessage类把数据更新到数据库中
+     * //点赞目标id + 目标类型 + 用户信息组装成CommentLikes写入数据库
+     * //文章需要统计点赞的数量和当前登录用户是否已经点赞
+     * //点赞之前应该去查一遍该文章或者回复的点赞key,value应该是点赞的人员id判断用户是否已经点赞过了,点赞过了就取消,没点赞过就加入
+     * //还需要同步到数据库,需要一个完整的点赞key 一个设置过期时间的监听key
+     */
+    @Override
+    public R<Void> giveTheThumbs(CommentLikes commentLikes) {
+        String targetType = commentLikes.getTargetType();
+        Long targetId = commentLikes.getTargetId();
+        Long userId = commentLikes.getUserId();
+        //保存点赞信息
+        //根据点赞目标id' 点赞目标类型(1:资讯 2:回复) 用户id查询是否已经点赞过
+        CommentLikes commentLikesOld = baseMapper.selectCommentLikes(commentLikes);
+        if (commentLikesOld != null) {
+            commentLikesOld.setDelFlag("Y");
+            baseMapper.updateById(commentLikesOld);
+        } else {
+            baseMapper.insert(commentLikes);
+        }
+        if (StringUtils.isNotBlank(targetType)) {
+            //设置未读点赞互动的方法
+            setCommentInteractionVo(commentLikes);
+            if (ONE.equals(targetType)) {
+                // 社区资讯文章点赞的人员集合的key key = LIKE_ONE:{targetId} value = [userId,userId];
+                String likeOneKey = ONE_LIKE + targetId;
+                //社区资讯文章点赞的数量数据库同步的key
+                String likeOneCountTimeKey = ONE_LIKE_COUNT_TIME + targetId;
+                //文章永久点赞的数量key
+                String likeOneCountKey = ONE_LIKE_COUNT + targetId;
+                //先去查看key对应的value集合 value = 点赞人员的id集合
+                List<Long> userIdListValue = RedisUtils.getCacheList(likeOneKey);
+                //该用户点赞文章的key
+                String myLikeOneKey = ONE_MY_LIKE + userId;
+                List<Long> communityIdList = RedisUtils.getCacheList(myLikeOneKey);
+                if (userIdListValue != null && userIdListValue.size() > 0) {
+                    //说明该文章被点过赞
+                    //判断该用户是否点过赞
+                    if (userIdListValue.contains(userId)) {
+                        //进行取消点赞
+                        return unLike(commentLikes);
+                    } else {
+                        //新增点赞信息
+                        return isLike(commentLikes);
+                    }
+                } else {
+                    //该文章没有被点过赞直接新增
+                    userIdListValue = new ArrayList<>();
+                    userIdListValue.add(userId);
+                    RedisUtils.setCacheList(likeOneKey, userIdListValue);
+                    //给数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间  key=like_one_count_time:{文章id}#{数量}
+                    RedisUtils.setCacheObject(likeOneCountTimeKey + "#" + 1, 1,  Duration.ofMinutes(1));
+                    //给该用户点赞文章的key添加值
+                    communityIdList.add(targetId);
+                    RedisUtils.setCacheList(myLikeOneKey, communityIdList);
+                    //给该文章永久点赞数量的key添加值
+                    RedisUtils.setCacheObject(likeOneCountKey, 1);
+                    return R.ok();
+                }
+            } else {
+                //对回复进行点赞
+                // 社区资讯回复点赞的人员集合的key key = LIKE_ONE:{targetId} value = [userId,userId];
+                String likeTwoKey = TWO_LIKE + targetId;
+                //社区资讯回复点赞的数量数据库同步的key
+                String likeTwoCountTimeKey = TWO_LIKE_COUNT_TIME + targetId;
+                //回复永久点赞的数量key
+                String likeTwoCountKey = TWO_LIKE_COUNT + targetId;
+                //先去查看key对应的value集合 value = 点赞人员的id集合
+                List<Long> userIdListValue = RedisUtils.getCacheList(likeTwoKey);
+                //该用户点赞回复的key
+                String myLikeTwoKey = TWO_MY_LIKE + userId;
+                List<Long> communityIdList = RedisUtils.getCacheList(myLikeTwoKey);
+                if (userIdListValue != null && userIdListValue.size() > 0) {
+                    //说明该回复被点过赞
+                    //判断该用户是否点过赞
+                    if (userIdListValue.contains(userId)) {
+                        //进行取消点赞
+                        return unLike(commentLikes);
+                    } else {
+                        //新增点赞信息
+                        return isLike(commentLikes);
+                    }
+                } else {
+                    //该回复没有被点过赞直接新增
+                    userIdListValue = new ArrayList<>();
+                    userIdListValue.add(userId);
+                    RedisUtils.setCacheList(likeTwoKey, userIdListValue);
+                    //给数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间
+                    RedisUtils.setCacheObject(likeTwoCountTimeKey + "#" + 1, 1, Duration.ofMinutes(1));
+                    //给该用户点赞回复的key添加值
+                    communityIdList.add(targetId);
+                    RedisUtils.setCacheList(myLikeTwoKey, communityIdList);
+                    //给该回复永久点赞数量的key添加值
+                    RedisUtils.setCacheObject(likeTwoCountKey, 1);
+                    return R.ok();
+                }
+            }
+        }
+        return R.fail("点赞失败");
+    }
+
+    /**
+     * 用户点赞,但不是第一次点赞的方法
+     *
+     * @param commentLikes
+     * @return
+     */
+    public R<Void> isLike(CommentLikes commentLikes) {
+        String targetType = commentLikes.getTargetType();
+        Long targetId = commentLikes.getTargetId();
+        Long userId = commentLikes.getUserId();
+        if (ONE.equals(targetType)) {
+            // 社区资讯文章点赞的人员集合的key key = ONE_LIKE:{targetId} value = [userId,userId];
+            String likeOneKey = ONE_LIKE + targetId;
+            //社区资讯文章点赞的数量数据库同步的key
+            String likeOneCountTimeKey = ONE_LIKE_COUNT + targetId;
+            //文章永久点赞的数量key
+            String likeOneCountKey = ONE_LIKE_COUNT + targetId;
+            //先去查看key对应的value集合 value = 点赞人员的id集合
+            List<Long> userIdListValue = RedisUtils.getCacheList(likeOneKey);
+            //该用户点赞文章的key
+            String myLikeOneKey = ONE_MY_LIKE + userId;
+            List<Long> communityIdList = RedisUtils.getCacheList(myLikeOneKey);
+            //新增点赞信息
+            // 新增社区资讯文章点赞的人员集合
+            userIdListValue.add(userId);
+            RedisUtils.setCacheList(likeOneKey, userIdListValue);
+            //新增该用户点赞文章
+            communityIdList.add(targetId);
+            RedisUtils.setCacheList(myLikeOneKey, communityIdList);
+            //新增文章永久点赞数量的key更新值
+            Integer likeOneCount = RedisUtils.getCacheObject(likeOneCountKey);
+            likeOneCount = likeOneCount + 1;
+            RedisUtils.setCacheObject(likeOneCountKey, likeOneCount);
+            //新增数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间
+            RedisUtils.setCacheObject(likeOneCountTimeKey + "#" + likeOneCount, likeOneCount, Duration.ofMinutes(1));
+            return R.ok();
+        } else {
+            // 社区资讯文章回复的人员集合的key key = TWO_LIKE:{targetId} value = [userId,userId];
+            String likeTwoKey = TWO_LIKE + targetId;
+            //社区资讯文章回复的数量数据库同步的key
+            String likeTwoCountTimeKey = TWO_LIKE_COUNT_TIME + targetId;
+            //文章永久回复的数量key
+            String likeTwoCountKey = TWO_LIKE_COUNT + targetId;
+            //先去查看key对应的value集合 value = 点赞人员的id集合
+            List<Long> userIdListValue = RedisUtils.getCacheList(likeTwoKey);
+            //该用户点赞回复的key
+            String myLikeTwoKey = TWO_MY_LIKE + userId;
+            List<Long> communityIdList = RedisUtils.getCacheList(myLikeTwoKey);
+            //新增点赞信息
+            // 新增社区资讯回复点赞的人员集合
+            userIdListValue.add(userId);
+            RedisUtils.setCacheList(likeTwoKey, userIdListValue);
+            //新增该用户点赞回复
+            communityIdList.add(targetId);
+            RedisUtils.setCacheList(myLikeTwoKey, communityIdList);
+            //新增回复永久点赞数量的key更新值
+            Integer likeTwoCount = RedisUtils.getCacheObject(likeTwoCountKey);
+            likeTwoCount = likeTwoCount + 1;
+            RedisUtils.setCacheObject(likeTwoCountKey, likeTwoCount);
+            //新增数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间
+            RedisUtils.setCacheObject(likeTwoCountTimeKey + "#" + likeTwoCount, likeTwoCount, Duration.ofMinutes(1));
+            return R.ok();
+        }
+    }
+    /**
+     * 用户取消点赞
+     *
+     * @param commentLikes
+     * @return
+     */
+    public R<Void> unLike(CommentLikes commentLikes) {
+        //用户点过赞 进行取消点赞
+        String targetType = commentLikes.getTargetType();
+        Long targetId = commentLikes.getTargetId();
+        Long userId = commentLikes.getUserId();
+        if (ONE.equals(targetType)) {
+            //文章永久点赞的数量key
+            String likeOneCountKey = ONE_LIKE_COUNT + targetId;
+            //社区资讯文章点赞的数量数据库同步的key
+            String likeOneCountTimeKey = ONE_LIKE_COUNT_TIME + targetId;
+            //-------------------------删除 社区资讯文章点赞的人员集合value中的userId
+            //  key = ONE_LIKE:{targetId} value = [userId,userId];
+            String likeOneKey = ONE_LIKE + targetId;
+            //先去查看key对应的value集合
+            List<Long> userIdListValue = RedisUtils.getCacheList(likeOneKey);
+            userIdListValue.remove(userId);
+            if (userIdListValue.size() == 0) {
+                RedisUtils.deleteObject(likeOneKey);
+            } else {
+                RedisUtils.deleteObject(likeOneKey);
+                // 社区资讯文章点赞的人员集合中删除该用户
+                RedisUtils.setCacheList(likeOneKey, userIdListValue);
+            }
+
+            //-------------------------删除 该用户点赞文章value中的文章id
+            String myLikeOneKey = ONE_MY_LIKE + userId;
+            List<Long> communityIdListValue = RedisUtils.getCacheList(myLikeOneKey);
+            communityIdListValue.remove(targetId);
+            if (communityIdListValue.size() == 0) {
+                RedisUtils.deleteObject(myLikeOneKey);
+            } else {
+                RedisUtils.deleteObject(myLikeOneKey);
+                RedisUtils.setCacheList(myLikeOneKey, communityIdListValue);
+            }
+            // ---------点赞数量操作------------------
+            //先获取永久点赞数量的值
+            Integer likeCount = RedisUtils.getCacheObject(likeOneCountKey);
+            //更新永久点赞数量
+            RedisUtils.setCacheObject(likeOneCountKey, Math.max(likeCount - 1,0));
+            //给数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间
+            RedisUtils.setCacheObject(likeOneCountTimeKey + "#" + likeCount, likeCount, Duration.ofMinutes(1));
+            return R.ok();
+        } else {
+            //评论的删除
+            //评论永久点赞的数量key
+            String likeTwoCountKey = TWO_LIKE_COUNT + targetId;
+            //社区资讯评论点赞的数量数据库同步的key
+            String likeTwoCountTimeKey = TWO_LIKE_COUNT_TIME + targetId;
+            //-------------------------删除 社区资讯文章评论的人员集合value中的userId
+            //  key = LIKE_ONE:{targetId} value = [userId,userId];
+            String likeTwoKey = TWO_LIKE + targetId;
+            //先去查看key对应的value集合
+            List<Long> userIdListValue = RedisUtils.getCacheList(likeTwoKey);
+            userIdListValue.remove(userId);
+            if (userIdListValue.size() == 0) {
+                RedisUtils.deleteObject(likeTwoKey);
+            } else {
+                RedisUtils.deleteObject(likeTwoKey);
+                // 社区资讯文章评论的人员集合中删除该用户
+                RedisUtils.setCacheList(likeTwoKey, userIdListValue);
+            }
+            //-------------------------删除 该用户点赞评论value中的文章id
+            String myLikeTwoKey = TWO_MY_LIKE + userId;
+            List<Long> communityIdListValue = RedisUtils.getCacheList(myLikeTwoKey);
+            communityIdListValue.remove(targetId);
+            if (communityIdListValue.size() == 0) {
+                RedisUtils.deleteObject(myLikeTwoKey);
+            } else {
+                RedisUtils.deleteObject(myLikeTwoKey);
+                RedisUtils.setCacheList(myLikeTwoKey, communityIdListValue);
+            }
+            // ---------点赞数量操作------------------
+            //先获取永久点赞数量的值
+            Integer likeCount = RedisUtils.getCacheObject(likeTwoCountKey);
+            //更新永久点赞数量
+            RedisUtils.setCacheObject(likeTwoCountKey, Math.max(likeCount - 1,0));
+            //给数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间
+            RedisUtils.setCacheObject(likeTwoCountTimeKey + "#" + likeCount, likeCount, Duration.ofMinutes(1));
+            return R.ok();
+        }
+    }
+
+    /**
+     * 设置未读点赞互动的方法
+     *
+     * @param commentLikes
+     */
+    public void setCommentInteractionVo(CommentLikes commentLikes) {
+        Long userId = commentLikes.getUserId();
+        Long targetId = commentLikes.getTargetId();
+        //------设置未读收藏,在redis中新增一条未读的互动--------
+        CommentInteractionVo commentInteractionVo = new CommentInteractionVo();
+        //先判断是资讯点赞还是回复点赞
+        String targetType = commentLikes.getTargetType();
+        commentInteractionVo.setTargetType(TWO);
+        commentInteractionVo.setType(ONE);
+        if (ONE.equals(targetType)) {
+            //说明是资讯点赞
+            //根据targetId获取该资讯的内容
+            CommunityNews communityNews = communityNewsMapper.selectById(targetId);
+            commentInteractionVo.setTargetUserId(communityNews.getUserId());
+            //-------------判断是点赞还是取消点赞-------------------
+            // 社区资讯文章点赞的人员集合的key key = LIKE_ONE:{targetId} value = [userId,userId];
+            String likeOneKey = ONE_LIKE + targetId;
+            //先去查看key对应的value集合 value = 点赞人员的id集合
+            List<Long> userIdListValue = RedisUtils.getCacheList(likeOneKey);
+            if (userIdListValue != null && userIdListValue.size() > 0) {
+                //说明该文章被点过赞
+                //判断该用户是否点过赞
+                if (userIdListValue.contains(userId)) {
+                    //设置取消点赞
+                    commentInteractionVo.setType(TWO);
+                }
+            }
+            //-------------判断是点赞还是取消点赞结束-------------------
+        } else if (TWO.equals(targetType)) {
+            //说明是回复点赞
+            commentInteractionVo.setTargetType(FIV);
+            //根据targetId获取该评论的内容
+            CommentIndex commentIndex = commentIndexMapper.selectById(targetId);
+            commentInteractionVo.setTargetUserId(commentIndex.getUserId());
+            commentInteractionVo.setCommunityId(commentLikes.getCommunityId());
+
+            //-------------判断是点赞还是取消点赞-------------------
+            // 社区资讯回复点赞的人员集合的key key = LIKE_ONE:{targetId} value = [userId,userId];
+            String likeTwoKey = TWO_LIKE + targetId;
+            //先去查看key对应的value集合 value = 点赞人员的id集合
+            List<Long> userIdListValue = RedisUtils.getCacheList(likeTwoKey);
+            if (userIdListValue != null && userIdListValue.size() > 0) {
+                //说明该回复被点过赞
+                //判断该用户是否点过赞
+                if (userIdListValue.contains(userId)) {
+                    //设置取消点赞
+                    commentInteractionVo.setType(TWO);
+                }
+            }
+            //-------------判断是点赞还是取消点赞-------------------
+        }
+        commentInteractionVo.setTargetTitle(commentLikes.getTargetTitle());
+        commentInteractionVo.setUserId(commentLikes.getUserId());
+        commentInteractionVo.setAvatar(commentLikes.getAvatar());
+        commentInteractionVo.setNickName(commentLikes.getNickName());
+        commentInteractionVo.setCreateTime(DateUtils.getNowDate());
+        commentInteractionVo.setTargetId(commentLikes.getTargetId());
+        communityNewsService.setCommentInteraction(commentInteractionVo);
+        //----------------------设置未读互动完成--------
+    }
 }

+ 176 - 4
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/impl/CommunityNewsServiceImpl.java

@@ -4,20 +4,25 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.ObjectUtils;
+import org.dromara.common.core.domain.R;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.redis.utils.RedisUtils;
+import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.domain.communityNews.CommunityNews;
 import org.dromara.domain.communityNews.bo.CommunityNewsBo;
+import org.dromara.domain.communityNews.vo.CommentInteractionVo;
 import org.dromara.domain.communityNews.vo.CommunityNewsVo;
 import org.dromara.mapper.CommunityNewsMapper;
 import org.dromara.service.ICommunityNewsService;
 import org.springframework.stereotype.Service;
 
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+
+import static org.dromara.common.core.constant.Constants.*;
 
 /**
  * 社区资讯Service业务层处理
@@ -39,7 +44,42 @@ public class CommunityNewsServiceImpl implements ICommunityNewsService {
      */
     @Override
     public CommunityNewsVo queryById(Long communityId){
-        return baseMapper.selectVoById(communityId);
+        CommunityNewsVo communityNews = baseMapper.selectVoById(communityId);
+        communityNews.setIsStar("N");
+        communityNews.setIsLike("N");
+        Long userId = LoginHelper.getUserId();
+        String likeOneKey = ONE_LIKE + communityId;
+        List<Long> userIdList = RedisUtils.getCacheList(likeOneKey);
+        if (userIdList != null && userIdList.size() > 0) {
+            if (userIdList.contains(userId)) {
+                communityNews.setIsLike("Y");
+            }
+        }
+        //该资讯收藏人员的key
+        String starsCommunityKey = STARS_COMMUNITY + communityId;
+        List<Long> userIdListStars = RedisUtils.getCacheList(starsCommunityKey);
+        if (userIdListStars != null && userIdListStars.size() > 0) {
+            //判断该用户是否收藏过
+            if (userIdListStars.contains(userId)) {
+                communityNews.setIsStar("Y");
+            }
+        }
+        //查询redis中的点赞数量,收藏数量,评论数量
+        Object likeCount = RedisUtils.getCacheObject(ONE_LIKE_COUNT + communityId);
+        if (ObjectUtils.isNotEmpty(likeCount)) {
+            communityNews.setUserLikes(likeCount.toString());
+        }
+        //收藏
+        Object startCount = RedisUtils.getCacheObject(STARS_USER_COUNT + communityId);
+        if (ObjectUtils.isNotEmpty(startCount)) {
+            communityNews.setUserStars(startCount.toString());
+        }
+        //评论
+        Object communityCommentCount = RedisUtils.getCacheObject(COMMUNITY_COMMENT_COUNT + communityId);
+        if (ObjectUtils.isNotEmpty(communityCommentCount)) {
+            communityNews.setUserComment(communityCommentCount.toString());
+        }
+        return communityNews;
     }
 
     /**
@@ -51,8 +91,20 @@ public class CommunityNewsServiceImpl implements ICommunityNewsService {
      */
     @Override
     public TableDataInfo<CommunityNewsVo> queryPageList(CommunityNewsBo bo, PageQuery pageQuery) {
+        Long userId = LoginHelper.getUserId();
         LambdaQueryWrapper<CommunityNews> lqw = buildQueryWrapper(bo);
         Page<CommunityNewsVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+        List<CommunityNewsVo> communityNewsList = result.getRecords();
+        //设置是否有未读互动
+        if (communityNewsList != null && communityNewsList.size() > 0) {
+            for (CommunityNewsVo news : communityNewsList) {
+                news.setIsInteraction("N");
+                //key=comment_interaction_community_user_count:{userId} hkey = {community_id} value = 资讯下有多少个未读的互动(点赞,收藏,回复)
+                if (RedisUtils.hasCacheMapKey(COMMENT_INTERACTION_COMMUNITY_USER_COUNT + userId, news.getCommunityId().toString())) {
+                    news.setIsInteraction("Y");
+                }
+            }
+        }
         return TableDataInfo.build(result);
     }
 
@@ -101,6 +153,7 @@ public class CommunityNewsServiceImpl implements ICommunityNewsService {
     public Boolean insertByBo(CommunityNewsBo bo) {
         CommunityNews add = MapstructUtils.convert(bo, CommunityNews.class);
         validEntityBeforeSave(add);
+        add.setUserId(LoginHelper.getUserId());
         boolean flag = baseMapper.insert(add) > 0;
         if (flag) {
             bo.setCommunityId(add.getCommunityId());
@@ -142,4 +195,123 @@ public class CommunityNewsServiceImpl implements ICommunityNewsService {
         }
         return baseMapper.deleteByIds(ids) > 0;
     }
+    /**
+     * 设置未读互动
+     *
+     * @return
+     */
+    @Override
+    public void setCommentInteraction(CommentInteractionVo commentInteractionVo) {
+        //把对应用户的未读互动存储到redis 还需要记录数量
+        //目标用户id
+        Long targetUserId = commentInteractionVo.getTargetUserId();
+        String targetType = commentInteractionVo.getTargetType();
+        String type = commentInteractionVo.getType();
+        Long targetId = commentInteractionVo.getTargetId();
+        /* 社区资讯ID 当是点赞回复的时候有值 */
+        Long communityId = commentInteractionVo.getTargetId();
+        //判断是否是点赞回复
+        if (targetType.equals(FIV)) {
+            communityId = commentInteractionVo.getCommunityId();
+        }
+        //-------------------获取设置用户的未读互动数量----------------
+        String commentInteractionUserCountKey = COMMENT_INTERACTION_USER_COUNT + targetUserId;
+        Object commentInteractionUserCount = RedisUtils.getCacheObject(commentInteractionUserCountKey);
+        if (commentInteractionUserCount != null) {
+            //判断是删除还是新增
+            if (ONE.equals(type)) {
+                RedisUtils.setCacheObject(commentInteractionUserCountKey, Integer.parseInt(commentInteractionUserCount.toString()) + 1);
+            } else {
+                RedisUtils.setCacheObject(commentInteractionUserCountKey, Math.max(Integer.parseInt(commentInteractionUserCount.toString()) - 1, 0));
+            }
+        } else {
+            if (ONE.equals(type)) {
+                RedisUtils.setCacheObject(commentInteractionUserCountKey, 1);
+            }
+        }
+        //-------------------设置用户的未读互动数量结束----------------
+        //-------------------设置用户的未读资讯的id和该资讯下一共有多少未读互动数量----------------
+        //key=comment_interaction_community_user_count:{userId} hkey = {community_id} value = 资讯下有多少个未读的互动(点赞,收藏,回复)
+        String commentInteractionCommunityUserCount = RedisUtils.getCacheMapValue(COMMENT_INTERACTION_COMMUNITY_USER_COUNT + targetUserId, communityId.toString());
+        //判断是删除还是新增
+        if (ONE.equals(type)) {
+            //新增
+            if (StringUtils.isNotBlank(commentInteractionCommunityUserCount)) {
+                RedisUtils.setCacheMapValue(COMMENT_INTERACTION_COMMUNITY_USER_COUNT + targetUserId, communityId.toString(), String.valueOf(Integer.parseInt(commentInteractionCommunityUserCount) + 1));
+            } else {
+                RedisUtils.setCacheMapValue(COMMENT_INTERACTION_COMMUNITY_USER_COUNT + targetUserId, communityId.toString(), ONE);
+            }
+        } else {
+            //删除
+            if (StringUtils.isNotBlank(commentInteractionCommunityUserCount)) {
+                int commentInteractionCommunityUserCountResult = Integer.parseInt(commentInteractionCommunityUserCount) - 1;
+                if (commentInteractionCommunityUserCountResult <= 0) {
+                    RedisUtils.delCacheMapValue(COMMENT_INTERACTION_COMMUNITY_USER_COUNT + targetUserId, communityId.toString());
+                } else {
+                    RedisUtils.setCacheMapValue(COMMENT_INTERACTION_COMMUNITY_USER_COUNT + targetUserId, communityId.toString(), commentInteractionCommunityUserCountResult);
+                }
+            }
+        }
+        //-------------------设置用户的未读资讯的id和该资讯下一共有多少未读互动数量结束----------------
+        //-------------------存储用户的未读资讯数据----------------
+        String commentInteractionUserKey = COMMENT_INTERACTION_USER + targetUserId;
+        Map<String, Object> commentInteractionUserMap = RedisUtils.getCacheMap(commentInteractionUserKey);
+        //hKey={targetType:targetId}
+        String hKey = targetType + ":" + targetId;
+        if (ONE.equals(type)) {
+            //新增/追加一条数据
+            RedisUtils.setCacheMapValue(commentInteractionUserKey, hKey, commentInteractionVo);
+        } else {
+            //删除
+            if (commentInteractionUserMap != null && commentInteractionUserMap.size() > 0) {
+                //删除一条数据
+                RedisUtils.delCacheMapValue(commentInteractionUserKey, hKey);
+            }
+        }
+        //-------------------存储用户的未读资讯数据结束----------------
+    }
+
+    /**
+     * 获取未读互动列表
+     */
+    @Override
+    public R<Map<String, Object>> getCommentInteraction(CommentInteractionVo commentInteractionVo) {
+        Long userId = LoginHelper.getUserId();
+        Map<String, Object> resultMap = new HashMap<>();
+        String commentInteractionUserCountKey = COMMENT_INTERACTION_USER_COUNT + userId;
+        Object commentInteractionUserCount = RedisUtils.getCacheObject(commentInteractionUserCountKey);
+        int commentInteractionUserCountInt = 0;
+        if (ObjectUtils.isNotEmpty(commentInteractionUserCount)) {
+            commentInteractionUserCountInt = Integer.parseInt(commentInteractionUserCount.toString());
+        }
+        resultMap.put("total", commentInteractionUserCountInt);
+        //-------------------存储用户的未读资讯数据----------------
+        String commentInteractionUserKey = COMMENT_INTERACTION_USER + userId;
+        Map<String, Object> commentInteractionUserMap = RedisUtils.getCacheMap(commentInteractionUserKey);
+        List<Object> resultList = new ArrayList<>();
+        if (commentInteractionUserMap != null && commentInteractionUserMap.size() > 0) {
+            resultList.addAll(commentInteractionUserMap.values());
+        }
+        resultMap.put("list", resultList);
+        //清空未读key
+        RedisUtils.deleteObject(commentInteractionUserCountKey);
+        RedisUtils.deleteObject(commentInteractionUserKey);
+        RedisUtils.deleteObject(COMMENT_INTERACTION_COMMUNITY_USER_COUNT + userId);
+        return R.ok(resultMap);
+    }
+
+    /**
+     * 获取未读互动数量
+     */
+    @Override
+    public R<Integer> getCommentInteractionCount(CommentInteractionVo commentInteractionVo) {
+        Long userId = LoginHelper.getUserId();
+        String commentInteractionUserCountKey = COMMENT_INTERACTION_USER_COUNT + userId;
+        Object commentInteractionUserCount = RedisUtils.getCacheObject(commentInteractionUserCountKey);
+        int commentInteractionUserCountInt = 0;
+        if (ObjectUtils.isNotEmpty(commentInteractionUserCount)) {
+            commentInteractionUserCountInt = Integer.parseInt(commentInteractionUserCount.toString());
+        }
+        return R.ok(commentInteractionUserCountInt);
+    }
 }

+ 3 - 0
ruoyi-modules/ruoyi-wuye/src/main/resources/mapper/wuYe/CommentContentMapper.xml

@@ -4,4 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.dromara.mapper.CommentContentMapper">
 
+    <update id="deleteCommentContentByCommentId" parameterType="org.dromara.domain.communityNews.CommentContent">
+        update comment_content set del_flag = 'Y' where comment_id in(select comment_id from comment_index where parent_id = #{commentId})
+    </update>
 </mapper>

+ 219 - 0
ruoyi-modules/ruoyi-wuye/src/main/resources/mapper/wuYe/CommentIndexMapper.xml

@@ -3,5 +3,224 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.dromara.mapper.CommentIndexMapper">
+    <resultMap type="org.dromara.domain.communityNews.CommentIndex" id="CommentIndexResult">
+        <result property="commentId" column="comment_id"/>
+        <result property="communityId" column="community_id"/>
+        <result property="communityType" column="community_type"/>
+        <result property="communityTitle"    column="community_title"    />
+        <result property="isRoot" column="is_root"/>
+        <result property="parentId" column="parent_id"/>
+        <result property="userId" column="user_id"/>
+        <result property="nickName" column="nick_name"/>
+        <result property="avatar" column="avatar"/>
+        <result property="toUserId" column="to_user_id"/>
+        <result property="toNickName" column="to_nick_name"/>
+        <result property="toAvatar" column="to_avatar"/>
+        <result property="toRoot" column="to_root"/>
+        <result property="contentId" column="content_id"/>
+        <result property="commentContent" column="comment_content"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+    <resultMap type="org.dromara.domain.communityNews.vo.CommentIndexShVo" id="CommentIndexShVoResult">
+        <result property="commentId" column="comment_id"/>
+        <result property="communityId" column="community_id"/>
+        <result property="communityType" column="community_type"/>
+        <result property="communityTitle"    column="community_title"    />
+        <result property="isRoot" column="is_root"/>
+        <result property="parentId" column="parent_id"/>
+        <result property="userId" column="user_id"/>
+        <result property="nickName" column="nick_name"/>
+        <result property="avatar" column="avatar"/>
+        <result property="toUserId" column="to_user_id"/>
+        <result property="toNickName" column="to_nick_name"/>
+        <result property="toAvatar" column="to_avatar"/>
+        <result property="contentId" column="content_id"/>
+        <result property="commentContent" column="comment_content"/>
+        <result property="status"    column="status"    />
+        <result property="type"    column="type"    />
+    </resultMap>
+    <!--回复列表返回给前端的格式-->
+    <resultMap type="org.dromara.domain.communityNews.vo.CommentIndexVoOld" 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"/>
+        <result property="createTime" column="ci_create_time"/>
+        <result property="childrenListCount" column="ci_children_list_count"/>
+        <association property="commentUser" javaType="org.dromara.domain.communityNews.vo.CommentUser"
+                     resultMap="CommentUserOneResult"/>
+        <collection property="childrenList" javaType="java.util.List" resultMap="ChildrenListResult"/>
+    </resultMap>
+    <resultMap id="ChildrenListResult" type="org.dromara.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"/>
+        <result property="createTime" column="cl_create_time"/>
+        <result property="toRoot" column="cl_to_root"/>
+        <association property="commentUser" javaType="org.dromara.domain.communityNews.vo.CommentUser"
+                     resultMap="CommentUserTwoResult"/>
+        <association property="targetUser" javaType="org.dromara.domain.communityNews.vo.TargetUser"
+                     resultMap="TargetUserVoResult"/>
+    </resultMap>
+    <!--一级评论对象评论人对象-->
+    <resultMap id="CommentUserOneResult" type="org.dromara.domain.communityNews.vo.CommentUser">
+        <id property="id" column="cu_one_id"/>
+        <result property="nickName" column="cu_one_nick_name"/>
+        <result property="avatar" column="cu_one_avatar"/>
+    </resultMap>
+    <!--子集评论评论人对象-->
+    <resultMap id="CommentUserTwoResult" type="org.dromara.domain.communityNews.vo.CommentUser">
+        <id property="id" column="cu_two_id"/>
+        <result property="nickName" column="cu_two_nick_name"/>
+        <result property="avatar" column="cu_two_avatar"/>
+    </resultMap>
+    <resultMap id="TargetUserVoResult" type="org.dromara.domain.communityNews.vo.TargetUser">
+        <id property="id" column="tu_id"/>
+        <result property="nickName" column="tu_nick_name"/>
+        <result property="avatar" column="tu_avatar"/>
+    </resultMap>
 
+
+    <select id="commentSh" parameterType="org.dromara.domain.communityNews.vo.CommentIndexShVo" resultMap="CommentIndexShVoResult">
+        SELECT
+        i.comment_id,
+        i.community_id,
+        i.community_type,
+        i.community_title,
+        i.is_root,
+        i.parent_id,
+        i.user_id,
+        i.nick_name,
+        i.avatar,
+        i.to_user_id,
+        i.to_nick_name,
+        i.to_avatar,
+        i.content_id,
+        i.comment_content,
+        c.status,
+        c.type
+        FROM
+        comment_index i
+        LEFT JOIN comment_content c ON i.content_id = c.content_id
+        <where>
+            i.del_flag = 'N'
+            and i.tenant_id = #{tenantId}
+            <if test="communityId != null ">and i.community_id = #{communityId}</if>
+            <if test="communityType != null  and communityType != ''">and i.community_type = #{communityType}</if>
+            <if test="isRoot != null ">and i.is_root = #{isRoot}</if>
+            <if test="parentId != null ">and i.parent_id = #{parentId}</if>
+            <if test="userId != null ">and i.user_id = #{userId}</if>
+            <if test="nickName != null  and nickName != ''">and i.nick_name like concat('%', #{nickName}, '%')</if>
+            <if test="avatar != null  and avatar != ''">and i.avatar = #{avatar}</if>
+            <if test="toUserId != null ">and i.to_user_id = #{toUserId}</if>
+            <if test="toNickName != null  and toNickName != ''">and i.to_nick_name like concat('%', #{toNickName}, '%')
+            </if>
+            <if test="toAvatar != null  and toAvatar != ''">and i.to_avatar = #{toAvatar}</if>
+            <if test="status != null and status != ''"> and c.status = #{status}</if>
+            <if test="type != null "> and c.type = #{type}</if>
+        </where>
+        order by i.create_time DESC
+    </select>
+
+    <select id="getRootComment" parameterType="org.dromara.domain.communityNews.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,
+        i.nick_name AS cu_one_nick_name,
+        i.avatar AS cu_one_avatar,
+        c.like_count AS ci_like_count,
+        ifnull(children.ci_children_list_count,0) AS ci_children_list_count
+        FROM
+        comment_index i
+        LEFT JOIN comment_content c ON i.content_id = c.content_id
+        LEFT JOIN (
+        SELECT
+        count( 1 ) AS ci_children_list_count,
+        i.parent_id AS ci_parent_id
+        FROM
+        comment_index i
+        LEFT JOIN comment_content c ON i.content_id = c.content_id
+        <where>
+            c.STATUS = '2'
+            AND i.is_root = 2
+            AND c.del_flag = 'N'
+            AND i.del_flag = 'N'
+            <if test="communityId != null ">and i.community_id = #{communityId}</if>
+        </where>
+        GROUP BY i.parent_id
+        ) AS children ON children.ci_parent_id = i.comment_id
+        <where>
+            c.STATUS = '2'
+            AND i.is_root = 1
+            AND c.del_flag = 'N'
+            AND i.del_flag = 'N'
+            <if test="communityId != null ">and i.community_id = #{communityId}</if>
+        </where>
+        ORDER BY
+        i.create_time DESC,
+        c.like_count DESC
+    </select>
+
+    <select id="getParentComment" parameterType="org.dromara.domain.communityNews.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,
+        i.to_user_id AS tu_id,
+        i.to_nick_name AS tu_nick_name,
+        i.to_avatar AS tu_avatar,
+        i.to_root AS cl_to_root,
+        i.create_time AS cl_create_time,
+        c.comment_content AS cl_content,
+        c.like_count AS cl_like_count
+        FROM
+        comment_index i
+        LEFT JOIN comment_content c ON i.content_id = c.content_id
+        <where>
+            c.STATUS = '2'
+            AND i.is_root = 2
+            AND c.del_flag = 'N'
+            AND i.del_flag = 'N'
+            <if test="parentId != null ">and i.parent_id = #{parentId}</if>
+        </where>
+        order by i.create_time DESC,c.like_count DESC
+    </select>
+
+    <select id="selectCommentIdListByCommentId" resultMap="CommentIndexResult">
+        SELECT
+            i.comment_id,
+            i.community_id,
+            i.community_type,
+            i.community_title,
+            i.is_root,
+            i.parent_id,
+            i.user_id,
+            i.nick_name,
+            i.avatar,
+            i.to_user_id,
+            i.to_nick_name,
+            i.to_avatar,
+            i.content_id,
+            i.comment_content
+        FROM
+            comment_index i
+                LEFT JOIN comment_content c ON i.comment_id = c.comment_id
+        WHERE
+            i.parent_id = #{commentId}
+          AND i.del_flag = 'N'
+          AND c.`status` = 2
+    </select>
 </mapper>

+ 27 - 1
ruoyi-modules/ruoyi-wuye/src/main/resources/mapper/wuYe/CommentLikesMapper.xml

@@ -3,5 +3,31 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.dromara.mapper.CommentLikesMapper">
-
+    <resultMap type="org.dromara.domain.communityNews.CommentLikes" id="CommentLikesResult">
+        <result property="likesId"    column="likes_id"    />
+        <result property="targetId"    column="target_id"    />
+        <result property="targetType"    column="target_type"    />
+        <result property="targetTitle"    column="target_title"    />
+        <result property="userId"    column="user_id"    />
+        <result property="nickName"    column="nick_name"    />
+        <result property="avatar"    column="avatar"    />
+        <result property="delFlag"    column="del_flag"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+    <sql id="selectCommentLikesVo">
+        select likes_id, target_id, target_type,target_title, user_id, nick_name, avatar, del_flag, create_by, create_time, update_by, update_time, remark from comment_likes
+    </sql>
+    <select id="selectCommentLikes" parameterType="org.dromara.domain.communityNews.CommentLikes" resultMap="CommentLikesResult">
+        <include refid="selectCommentLikesVo"/>
+        <where>
+            <if test="targetId != null "> and target_id = #{targetId}</if>
+            <if test="targetType != null  and targetType != ''"> and target_type = #{targetType}</if>
+            <if test="userId != null "> and user_id = #{userId}</if>
+        </where>
+         limit 1
+    </select>
 </mapper>