瀏覽代碼

通知功能全部优化 新增删除,过滤自己,分页

fangqing 3 月之前
父節點
當前提交
fd78e3f116
共有 16 個文件被更改,包括 204 次插入19 次删除
  1. 117 4
      ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityCommentController.java
  2. 5 0
      ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticleAt.java
  3. 6 0
      ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticleCollect.java
  4. 5 0
      ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticleComment.java
  5. 6 0
      ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticleRecommend.java
  6. 5 0
      ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityCommentLike.java
  7. 5 0
      ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityCommentReply.java
  8. 5 0
      ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityUserLike.java
  9. 4 1
      ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleCollectMapper.java
  10. 4 1
      ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleCommentMapper.java
  11. 4 1
      ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityUserLikeMapper.java
  12. 2 2
      ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleCommentServiceImpl.java
  13. 5 1
      ruoyi-generator/src/main/java/com/ruoyi/generator/service/ICommunityArticleCommentService.java
  14. 11 5
      ruoyi-generator/src/main/resources/mapper/community/CommunityArticleCollectMapper.xml
  15. 12 3
      ruoyi-generator/src/main/resources/mapper/community/CommunityArticleCommentMapper.xml
  16. 8 1
      ruoyi-generator/src/main/resources/mapper/community/CommunityUserLikeMapper.xml

+ 117 - 4
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityCommentController.java

@@ -514,7 +514,11 @@ public class CommunityCommentController extends BaseController {
     @ApiOperation("获取当前登录用户的评论和回复")
     public AjaxResult getCommentInfoByUserId() {
         Long userId = SecurityUtils.getUserId();
-        return success(communityArticleCommentService.getCommentInfoByUserId(userId));
+        int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
+        int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
+        int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 1);
+        int offset = (pageNum - 1) * pageSize;
+        return success(communityArticleCommentService.getCommentInfoByUserId(userId,offset,pageSize,searchType));
     }
 
     /**
@@ -526,7 +530,11 @@ public class CommunityCommentController extends BaseController {
     @ApiOperation("获取当前登录用户被推荐和收藏的信息")
     public AjaxResult getLikeAndCollect() {
         Long userId = SecurityUtils.getUserId();
-        return success(communityArticleCollectMapper.selectRecommendAndCollectByUserId(userId));
+        int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
+        int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
+        int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 1);
+        int offset = (pageNum - 1) * pageSize;
+        return success(communityArticleCollectMapper.selectRecommendAndCollectByUserId(userId,offset,pageSize,searchType));
     }
 
     /**
@@ -538,7 +546,11 @@ public class CommunityCommentController extends BaseController {
     @ApiOperation("获取当前登录用户新增关注列表")
     public AjaxResult getLikeList() {
         Long userId = SecurityUtils.getUserId();
-        return success(communityUserLikeMapper.selectLikeByUserId(userId));
+        int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
+        int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
+        int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 1);
+        int offset = (pageNum - 1) * pageSize;
+        return success(communityUserLikeMapper.selectLikeByUserId(userId,offset,pageSize,searchType));
     }
 
     /**
@@ -576,7 +588,12 @@ public class CommunityCommentController extends BaseController {
                 break;
             case "3":
                 //回复点赞
-                communityCommentReplyService.update(new UpdateWrapper<CommunityCommentReply>()
+                /*communityCommentReplyService.update(new UpdateWrapper<CommunityCommentReply>()
+                        .set("is_read", true)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId())
+                        .eq("id", id));*/
+                commentLikeService.update(new UpdateWrapper<CommunityCommentLike>()
                         .set("is_read", true)
                         .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
                         .set("update_by", SecurityUtils.getUserId())
@@ -637,4 +654,100 @@ public class CommunityCommentController extends BaseController {
         return success();
     }
 
+    /**
+     * 用户删除通知
+     *
+     * @return 用户删除通知
+     */
+    @PutMapping("/deleteMsgRead")
+    @ApiOperation("用户点击通知后,更新通知消息已读")
+    public AjaxResult deleteMsgRead(String type, String id) {
+        switch (type) {
+            case "0":
+                //文章推荐
+                communityArticleRecommendServiceImpl.update(new UpdateWrapper<CommunityArticleRecommend>()
+                        .set("is_notice", true)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId())
+                        .eq("id", id));
+                break;
+            case "1":
+                //文章收藏
+                articleCollectService.update(new UpdateWrapper<CommunityArticleCollect>()
+                        .set("is_notice", true)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId())
+                        .eq("id", id));
+                break;
+            case "2":
+                //评论点赞
+                commentLikeService.update(new UpdateWrapper<CommunityCommentLike>()
+                        .set("is_notice", true)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId())
+                        .eq("id", id));
+                break;
+            case "3":
+                //回复点赞
+                commentLikeService.update(new UpdateWrapper<CommunityCommentLike>()
+                        .set("is_notice", true)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId())
+                        .eq("id", id));
+                break;
+            case "4":
+                //新增关注已读
+                userLikeService.update(new UpdateWrapper<CommunityUserLike>()
+                        .set("is_notice", true)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId())
+                        .eq("id", id));
+                break;
+            case "5":
+                //文章@
+                communityArticleAtService.update(new UpdateWrapper<CommunityArticleAt>()
+                        .set("is_notice", true)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId())
+                        .eq("id", id)
+                        .eq("type",0));
+                break;
+            case "6":
+                //文章评论@
+                communityArticleAtService.update(new UpdateWrapper<CommunityArticleAt>()
+                        .set("is_notice", true)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId())
+                        .eq("id", id)
+                        .eq("type",1));
+                break;
+            case "7":
+                //文章回复@
+                communityArticleAtService.update(new UpdateWrapper<CommunityArticleAt>()
+                        .set("is_notice", true)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId())
+                        .eq("id", id)
+                        .eq("type",2));
+                break;
+            case "8":
+                //文章评论
+                communityArticleCommentService.update(new UpdateWrapper<CommunityArticleComment>()
+                        .set("is_notice", true)
+                        .in("id", id)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId()));
+                break;
+            case "9":
+                //文章回复
+                communityCommentReplyService.update(new UpdateWrapper<CommunityCommentReply>()
+                        .set("is_notice", true)
+                        .in("id", id)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId()));;
+                break;
+        }
+        return success();
+    }
+
 }

+ 5 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticleAt.java

@@ -94,5 +94,10 @@ public class CommunityArticleAt implements Serializable {
      */
     @ApiModelProperty("是否已删除")
     private Boolean isDelete;
+    /**
+     * 通知是否删除
+     */
+    @ApiModelProperty("通知是否删除")
+    private boolean isNotice;
 
 }

+ 6 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticleCollect.java

@@ -66,4 +66,10 @@ public class CommunityArticleCollect implements Serializable {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty("更新时间")
     private Date updateTime;
+
+    /**
+     * 通知是否删除
+     */
+    @ApiModelProperty("通知是否删除")
+    private boolean isNotice;
 }

+ 5 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticleComment.java

@@ -103,4 +103,9 @@ public class CommunityArticleComment implements Serializable {
     @ApiModelProperty("文章at")
     @TableField(exist = false)
     private List<Long> atUserIds;
+    /**
+     * 通知是否删除
+     */
+    @ApiModelProperty("通知是否删除")
+    private boolean isNotice;
 }

+ 6 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticleRecommend.java

@@ -68,4 +68,10 @@ public class CommunityArticleRecommend implements Serializable {
      */
     @ApiModelProperty("是否已读")
     private boolean isRead;
+
+    /**
+     * 通知是否删除
+     */
+    @ApiModelProperty("通知是否删除")
+    private boolean isNotice;
 }

+ 5 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityCommentLike.java

@@ -80,4 +80,9 @@ public class CommunityCommentLike implements Serializable {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date updateTime;
 
+    /**
+     * 通知是否删除
+     */
+    @ApiModelProperty("通知是否删除")
+    private boolean isNotice;
 }

+ 5 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityCommentReply.java

@@ -109,5 +109,10 @@ public class CommunityCommentReply implements Serializable {
     @ApiModelProperty("文章at")
     @TableField(exist = false)
     private List<Long> atUserIds;
+    /**
+     * 通知是否删除
+     */
+    @ApiModelProperty("通知是否删除")
+    private boolean isNotice;
 
 }

+ 5 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityUserLike.java

@@ -65,4 +65,9 @@ public class CommunityUserLike implements Serializable {
      */
     @ApiModelProperty("更新人")
     private Long updateBy;
+    /**
+     * 通知是否删除
+     */
+    @ApiModelProperty("通知是否删除")
+    private boolean isNotice;
 }

+ 4 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleCollectMapper.java

@@ -14,5 +14,8 @@ public interface CommunityArticleCollectMapper extends BaseMapper<CommunityArtic
      * 获取登录用户文章推荐和收藏
      * @param userId 用户id
      */
-    List<RecommendAndCollectVo> selectRecommendAndCollectByUserId(@Param("userId") Long userId);
+    List<RecommendAndCollectVo> selectRecommendAndCollectByUserId(@Param("userId") Long userId,
+                                                                  @Param("offset") int offset,
+                                                                  @Param("limit") int limit,
+                                                                  @Param("searchType") int searchType);
 }

+ 4 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleCommentMapper.java

@@ -55,5 +55,8 @@ public interface CommunityArticleCommentMapper extends BaseMapper<CommunityArtic
      * @param userId 当前用户id
      * @return 该用户的文章信息
      */
-    List<CommentVo> getCommentListByUserId(@Param("userId") Long userId);
+    List<CommentVo> getCommentListByUserId(@Param("userId") long userId,
+                                           @Param("offset") int offset,
+                                           @Param("limit") int limit,
+                                           @Param("searchType") int searchType);
 }

+ 4 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityUserLikeMapper.java

@@ -10,5 +10,8 @@ import java.util.List;
 
 @Mapper
 public interface CommunityUserLikeMapper extends BaseMapper<CommunityUserLike> {
-    List<LikeVo> selectLikeByUserId(@Param("userId") Long userId);
+    List<LikeVo> selectLikeByUserId(@Param("userId") Long userId,
+                                    @Param("offset") int offset,
+                                    @Param("limit") int limit,
+                                    @Param("searchType") int searchType);
 }

+ 2 - 2
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleCommentServiceImpl.java

@@ -22,7 +22,7 @@ public class CommunityArticleCommentServiceImpl extends ServiceImpl<CommunityArt
      * @return 该用户的文章信息
      */
     @Override
-    public List<CommentVo> getCommentInfoByUserId(long userId) {
-        return communityArticleCommentMapper.getCommentListByUserId(userId);
+    public List<CommentVo> getCommentInfoByUserId(long userId, int offset, int limit, int searchType) {
+        return communityArticleCommentMapper.getCommentListByUserId(userId,offset,limit,searchType);
     }
 }

+ 5 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/service/ICommunityArticleCommentService.java

@@ -3,6 +3,7 @@ package com.ruoyi.generator.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.generator.domain.Community.CommunityArticleComment;
 import com.ruoyi.generator.vo.CommentVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -14,5 +15,8 @@ public interface ICommunityArticleCommentService extends IService<CommunityArtic
      * @param userId 当前用户id
      * @return 该用户的文章信息
      */
-    List<CommentVo> getCommentInfoByUserId(long userId);
+    List<CommentVo> getCommentInfoByUserId(@Param("userId") long userId,
+                                           @Param("offset") int offset,
+                                           @Param("limit") int limit,
+                                           @Param("searchType") int searchType);
 }

+ 11 - 5
ruoyi-generator/src/main/resources/mapper/community/CommunityArticleCollectMapper.xml

@@ -20,7 +20,7 @@
                      '0'                                                                   as type
               from community_article_recommend car
                        left join community_article ca on car.article_id = ca.id
-              where ca.user_id = #{userId}
+              where ca.user_id = #{userId} and car.user_id != #{userId} and (car.is_notice != 1 or car.is_notice is null)
               union all
               select cac.id,
                      cac.article_id,
@@ -37,7 +37,7 @@
                      '1'                                                                   as type
               from community_article_collect cac
                        left join community_article ca on cac.article_id = ca.id
-              where ca.user_id = #{userId}
+              where ca.user_id = #{userId} and cac.user_id != #{userId} and (cac.is_notice != 1 or cac.is_notice is null)
               union all
               select ccl.id,
                      cac.article_id                                                        as article_id,
@@ -56,7 +56,7 @@
                      '2'                                                                   as type
               from community_comment_like ccl
                        left join community_article_comment cac on ccl.comment_id = cac.id
-              where cac.user_id = #{userId}
+              where cac.user_id = #{userId} and ccl.user_id != #{userId} and (ccl.is_notice != 1 or ccl.is_notice is null)
               union all
               select ccl.id,
                      cac.article_id                                                        as article_id,
@@ -76,7 +76,13 @@
               from community_comment_like ccl
                        left join community_comment_reply ccr on ccl.reply_id = ccr.id
                        left join community_article_comment cac on ccr.id = ccr.comment_id
-              where ccr.user_id = #{userId}) result
-        order by result.create_time desc
+              where ccr.user_id = #{userId} and ccl.user_id != #{userId} and (ccl.is_notice != 1 or ccl.is_notice is null) ) result
+        <if test="searchType == 1">
+            order by result.create_time desc
+        </if>
+        <if test="searchType == 2">
+            order by result.create_time asc
+        </if>
+        limit #{offset},#{limit}
     </select>
 </mapper>

+ 12 - 3
ruoyi-generator/src/main/resources/mapper/community/CommunityArticleCommentMapper.xml

@@ -246,6 +246,7 @@
           AND cac.id IS NOT NULL
           AND (ca.is_delete IS NULL OR ca.is_delete != 1)
           AND (cac.is_delete IS NULL OR cac.is_delete != 1)
+          AND (cac.is_notice != 1 or cac.is_notice is null)
 
         UNION ALL
 
@@ -267,6 +268,7 @@
           AND ccr.id IS NOT NULL
           AND (cac.is_delete IS NULL OR cac.is_delete != 1)
           AND (ccr.is_delete IS NULL OR ccr.is_delete != 1)
+          AND (ccr.is_notice != 1 or ccr.is_notice is null)
 
         UNION ALL
 
@@ -285,7 +287,7 @@
         WHERE caa.type = 0
           AND caa.peer_id = #{userId}
           AND (caa.is_delete IS NULL OR caa.is_delete != 1)
-
+          AND (caa.is_notice != 1 or caa.is_notice is null)
         UNION ALL
 
         SELECT
@@ -305,7 +307,7 @@
           AND caa.peer_id = #{userId}
           AND (caa.is_delete IS NULL OR caa.is_delete != 1)
           AND (cac.is_delete IS NULL OR cac.is_delete != 1)
-
+          AND (caa.is_notice != 1 or caa.is_notice is null)
         UNION ALL
 
         SELECT
@@ -325,7 +327,14 @@
           AND caa.peer_id = #{userId}
           AND (caa.is_delete IS NULL OR caa.is_delete != 1)
           AND (ccr.is_delete IS NULL OR ccr.is_delete != 1)
+          AND (caa.is_notice != 1 or caa.is_notice is null)
             ) c
-        ORDER BY c.create_time DESC;
+        <if test="searchType == 1">
+            order by c.create_time desc
+        </if>
+        <if test="searchType == 2">
+            order by c.create_time asc
+        </if>
+        limit #{offset},#{limit}
     </select>
 </mapper>

+ 8 - 1
ruoyi-generator/src/main/resources/mapper/community/CommunityUserLikeMapper.xml

@@ -12,6 +12,13 @@
                cul.is_read,
                '4' as type
         from community_user_like cul
-        where cul.like_user_id = #{userId}
+        where cul.like_user_id = #{userId} and (cul.is_notice != 1 or cul.is_notice is null)
+        <if test="searchType == 1">
+            order by cul.create_time desc
+        </if>
+        <if test="searchType == 2">
+            order by cul.create_time asc
+        </if>
+        limit #{offset},#{limit}
     </select>
 </mapper>