Browse Source

获取当前用户的评论和回复 新增@

fangqing 3 months ago
parent
commit
c8477a16b8

+ 27 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityArticleController.java

@@ -123,6 +123,9 @@ public class CommunityArticleController extends BaseController {
     @Autowired
     private CommunityArticleTagMapper communityArticleTagMapper;
 
+    @Autowired
+    private CommunityArticleAtMapper communityArticleAtMapper;
+
     /**
      * 生成唯一的缓存键(基于请求参数)
      */
@@ -1212,7 +1215,9 @@ public class CommunityArticleController extends BaseController {
         return AjaxResult.success(communityCollectionUser);
     }
 
-
+    /**
+     * 获取个人中心信息
+     */
     @ApiOperation("获取个人中心信息")
     @GetMapping("/userPrompt")
     public AjaxResult userPrompt(Long userId) {
@@ -1284,4 +1289,25 @@ public class CommunityArticleController extends BaseController {
         return AjaxResult.success(communityAccompany);
     }
 
+    /**
+     * 插入at信息
+     */
+    @ApiOperation("插入at信息")
+    @PostMapping("/articleAt")
+    @Anonymous
+    public AjaxResult articleAt(@RequestBody CommunityArticleAt communityArticleAt) {
+        if (Objects.isNull(communityArticleAt.getPeerId()) ) {
+            return AjaxResult.error("@人ID不能为空");
+        }
+        Long  userId = SecurityUtils.getUserId();
+        try {
+            communityArticleAt.setCreateBy(userId);
+            communityArticleAt.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
+            communityArticleAtMapper.insert(communityArticleAt);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return AjaxResult.success(communityArticleAt);
+    }
+
 }

+ 30 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityCommentController.java

@@ -102,6 +102,9 @@ public class CommunityCommentController extends BaseController {
     @Autowired
     private CommunityCommentRaffleMapper communityCommentRaffleMapper;
 
+    @Autowired
+    private CommunityArticleAtServiceImpl communityArticleAtService;
+
     /**
      * 获取文章评论
      */
@@ -558,6 +561,33 @@ public class CommunityCommentController extends BaseController {
                         .set("update_by", SecurityUtils.getUserId())
                         .eq("id", id));
                 break;
+            case "5":
+                //文章@
+                communityArticleAtService.update(new UpdateWrapper<CommunityArticleAt>()
+                        .set("is_read", 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_read", 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_read", true)
+                        .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
+                        .set("update_by", SecurityUtils.getUserId())
+                        .eq("id", id)
+                        .eq("type",2));
+                break;
         }
         return success();
     }

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

@@ -0,0 +1,98 @@
+package com.ruoyi.generator.domain.Community;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+* 评价点赞表
+* @TableName Community_Article_At
+*/
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class CommunityArticleAt implements Serializable {
+
+    /**
+    * 唯一id
+    */
+    @NotNull(message="[唯一id]不能为空")
+    @ApiModelProperty("唯一id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long id;
+    /**
+     * 文章id
+     */
+    @ApiModelProperty("文章id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long articleId;
+    /**
+    * 评价id
+    */
+    @ApiModelProperty("评价id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long commentId;
+    /**
+     * 回复id
+     */
+    @ApiModelProperty("回复id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long replyId;
+    /**
+    * 用户id
+    */
+    @ApiModelProperty("用户id")
+    private Long userId;
+    /**
+     * 被@用户id
+     */
+    @ApiModelProperty("被@用户id")
+    private Long peerId;
+    /**
+     * 是否已读
+     */
+    @ApiModelProperty("是否已读")
+    private boolean isRead;
+    /**
+    * 创建人
+    */
+    @ApiModelProperty("创建人")
+    private Long createBy;
+    /**
+    * 创建时间
+    */
+    @ApiModelProperty("创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+    /**
+    * 更新人
+    */
+    @ApiModelProperty("更新人")
+    private Long updateBy;
+    /**
+    * 更新时间
+    */
+    @ApiModelProperty("更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+    /**
+     * 类型
+     */
+    @ApiModelProperty("类型")
+    private Long type;
+    /**
+     * 是否已删除
+     */
+    @ApiModelProperty("是否已删除")
+    private Boolean isDelete;
+
+}

+ 8 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleAtMapper.java

@@ -0,0 +1,8 @@
+package com.ruoyi.generator.mapper.community;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.generator.domain.Community.CommunityArticleAt;
+import com.ruoyi.generator.domain.Community.CommunityArticleRecommend;
+
+public interface CommunityArticleAtMapper extends BaseMapper<CommunityArticleAt> {
+}

+ 13 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleAtServiceImpl.java

@@ -0,0 +1,13 @@
+package com.ruoyi.generator.service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.generator.domain.Community.CommunityArticleAt;
+import com.ruoyi.generator.domain.Community.CommunityUserLike;
+import com.ruoyi.generator.mapper.community.CommunityArticleAtMapper;
+import com.ruoyi.generator.mapper.community.CommunityUserLikeMapper;
+import org.springframework.stereotype.Service;
+
+@Service
+public class CommunityArticleAtServiceImpl extends ServiceImpl<CommunityArticleAtMapper, CommunityArticleAt> implements ICommunityArticleAtService {
+
+}

+ 9 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/service/ICommunityArticleAtService.java

@@ -0,0 +1,9 @@
+package com.ruoyi.generator.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.generator.domain.Community.CommunityArticleAt;
+import com.ruoyi.generator.domain.Community.CommunityUserLike;
+
+public interface ICommunityArticleAtService extends IService<CommunityArticleAt> {
+
+}

+ 1 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/vo/CommentVo.java

@@ -23,4 +23,5 @@ public class CommentVo {
     private Date createTime;
     private String content;
     private boolean isRead;
+    private String imageUrl;
 }

+ 267 - 190
ruoyi-generator/src/main/resources/mapper/community/CommunityArticleCommentMapper.xml

@@ -6,116 +6,115 @@
     <select id="queryCommentCount" resultType="java.lang.Integer">
         select d.commentCount + d.replyCount
         from (select c.article_id,
-                     count(1)                 as commentCount,
+                     count(1) as commentCount,
                      (select count(1) as replyCount
                       from community_article_comment a
                                left join community_comment_reply b on a.id = b.comment_id
                       where a.article_id = #{articleId}
-                        and b.is_delete != 1) as replyCount
-              from community_article_comment c
-              where c.article_id = #{articleId} and  c.is_delete != 1 ) as d
+                        and b.is_delete != 1) as replyCount from community_article_comment c
+        where c.article_id = #{articleId} and c.is_delete != 1 ) as d
     </select>
 
     <select id="queryCommentReplyCount" resultType="java.lang.Integer">
-        select  d.commentCount + d.replyCount from  (
-                                                        select
-                                                            count(1) as   commentCount,
-                                                            (select
-                                                                 count(*)  count
-                                                        from
-                                                            community_article_comment   a
-                                                            left join community_comment_reply b on a.id = b.comment_id
-    <where>
-          <if test=" articleIds != null and articleIds.size > 0">
-            AND article_id in
-            <foreach collection="articleIds" item="articleId" index="index" open="(" close=")" separator=",">
-                #{articleId}
-            </foreach>
-          </if>
-          and b.id is not null
-          and (a.is_delete != 1 or a.is_delete is null)
-          and (b.is_delete != 1 or b.is_delete is null)
-    </where>
-            ) as replyCount
-            from community_article_comment c
-    <where>
-        <if test="articleIds  != null and articleIds.size > 0">
-            AND c.article_id in
-            <foreach collection="articleIds" item="articleId" index="index" open="(" close=")" separator=",">
-                #{articleId}
-            </foreach>
-        </if>
-        and (c.is_delete != 1 or c.is_delete is null)
-    </where>
-        )  as d
+        select d.commentCount + d.replyCount from (
+        select
+        count(1) as commentCount,
+        (select
+        count(*) count
+        from
+        community_article_comment a
+        left join community_comment_reply b on a.id = b.comment_id
+        <where>
+            <if test=" articleIds != null and articleIds.size > 0">
+                AND article_id in
+                <foreach collection="articleIds" item="articleId" index="index" open="(" close=")" separator=",">
+                    #{articleId}
+                </foreach>
+            </if>
+            and b.id is not null
+            and (a.is_delete != 1 or a.is_delete is null)
+            and (b.is_delete != 1 or b.is_delete is null)
+        </where>
+        ) as replyCount
+        from community_article_comment c
+        <where>
+            <if test="articleIds  != null and articleIds.size > 0">
+                AND c.article_id in
+                <foreach collection="articleIds" item="articleId" index="index" open="(" close=")" separator=",">
+                    #{articleId}
+                </foreach>
+            </if>
+            and (c.is_delete != 1 or c.is_delete is null)
+        </where>
+        ) as d
     </select>
 
 
     <select id="queryCommentReplyCountPerson" resultType="java.lang.Integer">
-        select count(1)  count  from (
-            select
-            f.user_id,sum(g.commentSum)  sum
-            from (
-            select
-            a.user_id,b.id   as  article_id
-            from sys_user a
-            left join community_article b on a.user_id = b. user_id
-            where  (a.status != 1 or a.status is null) and  (b.is_delete != 1 or b.is_delete is null)
-            and b.id is not null ) f
-            left join (select
-            d.article_id, d.commentCount + COALESCE(e.replyCount, 0) as commentSum
-            from (
-            select
-            c.article_id,
-            count(1) as   commentCount
-            from community_article_comment c
-            where (c.is_delete != 1 or c.is_delete is null)
-            group by c.article_id ) d
-            left join (select
-            a.article_id,count(1) replyCount
-            from
-            community_article_comment   a
-            left join community_comment_reply b on a.id = b.comment_id
-            where b.id is not null
-            and (a.is_delete != 1 or a.is_delete is null)
-            and (b.is_delete != 1 or b.is_delete is null)
-            group by a.article_id) e
-            on d.article_id = e.article_id ) g
-            on f.article_id = g.article_id
-            group by  f.user_id
-                <if test="commentSum  != null and commentSum > 0">
-                HAVING sum &lt;= #{commentSum}
-                </if>
-            ) h
+        select count(1) count from (
+        select
+        f.user_id,sum(g.commentSum) sum
+        from (
+        select
+        a.user_id,b.id as article_id
+        from sys_user a
+        left join community_article b on a.user_id = b. user_id
+        where (a.status != 1 or a.status is null) and (b.is_delete != 1 or b.is_delete is null)
+        and b.id is not null ) f
+        left join (select
+        d.article_id, d.commentCount + COALESCE(e.replyCount, 0) as commentSum
+        from (
+        select
+        c.article_id,
+        count(1) as commentCount
+        from community_article_comment c
+        where (c.is_delete != 1 or c.is_delete is null)
+        group by c.article_id ) d
+        left join (select
+        a.article_id,count(1) replyCount
+        from
+        community_article_comment a
+        left join community_comment_reply b on a.id = b.comment_id
+        where b.id is not null
+        and (a.is_delete != 1 or a.is_delete is null)
+        and (b.is_delete != 1 or b.is_delete is null)
+        group by a.article_id) e
+        on d.article_id = e.article_id ) g
+        on f.article_id = g.article_id
+        group by f.user_id
+        <if test="commentSum  != null and commentSum > 0">
+            HAVING sum &lt;= #{commentSum}
+        </if>
+        ) h
     </select>
     <select id="queryCommentReplyLikeCount" resultType="java.lang.Integer">
-        select sum(count) sum  from (
+        select sum(count) sum
+        from (
             select
-            a.user_id, count(1) count
+            a.user_id, count (1) count
             from community_article a
-            left join  community_like b
+            left join community_like b
             on a.id = b.article_id
-            where  (a.is_delete != 1 or a.is_delete is null)
+            where (a.is_delete != 1 or a.is_delete is null)
             and b.id is not null
             and a.user_id = #{userId}
-
             GROUP BY a.user_id
             union ALL
             select
-            a.user_id,count(1) count
+            a.user_id, count (1) count
             from
             community_article_comment a
             left join community_comment_like b
             on a.id = b.comment_id
-            where  (a.is_delete != 1 or a.is_delete is null)
-            and b.id is not null  	and  EXISTS (select distinct id  from community_article z where a.article_id = z.id and  (z.is_delete != 1 or z.is_delete is null))
-            and  a.user_id = #{userId}
-            group by  a.user_id
+            where (a.is_delete != 1 or a.is_delete is null)
+            and b.id is not null and EXISTS (select distinct id from community_article z where a.article_id = z.id and (z.is_delete != 1 or z.is_delete is null))
+            and a.user_id = #{userId}
+            group by a.user_id
             union all
             select
-            b.user_id,count(1) count
+            b.user_id, count (1) count
             from
-            community_article_comment   a
+            community_article_comment a
             left join community_comment_reply b on a.id = b.comment_id
             left join community_comment_like c on b.id = c.reply_id
             where
@@ -124,47 +123,47 @@
             and c.id is not null
             and (a.is_delete != 1 or a.is_delete is null)
             and (b.is_delete != 1 or b.is_delete is null)
-            and  EXISTS (select distinct id  from community_article z where a.article_id = z.id and  (z.is_delete != 1 or z.is_delete is null))
+            and EXISTS (select distinct id from community_article z where a.article_id = z.id and (z.is_delete != 1 or z.is_delete is null))
             group by b.user_id ) AA
         group by user_id
     </select>
 
     <select id="queryCommentReplyLikeCountPerson" resultType="java.lang.Integer">
-        select count(*)  from (
-                                 select user_id,sum(count) counts  from (
-                                     select
-                                     a.user_id, count(1) count
-                                     from community_article a
-                                     left join  community_like b
-                                     on a.id = b.article_id
-                                     where  (a.is_delete != 1 or a.is_delete is null)
-                                     and b.id is not null
-                                     GROUP BY a.user_id
-                                     union ALL
-                                     select
-                                     a.user_id,count(1) count
-                                     from
-                                     community_article_comment a
-                                     left join community_comment_like b
-                                     on a.id = b.comment_id
-                                     where  (a.is_delete != 1 or a.is_delete is null)
-                                     and b.id is not null  	and  EXISTS (select distinct id  from community_article z where a.article_id = z.id and  (z.is_delete != 1 or z.is_delete is null))
-                                     group by  a.user_id
-                                     union all
-                                     select
-                                     b.user_id,count(1) count
-                                     from
-                                     community_article_comment   a
-                                     left join community_comment_reply b on a.id = b.comment_id
-                                     left join community_comment_like c on b.id = c.reply_id
-                                     where
-                                     b.id is not null
-                                     and c.id is not null
-                                     and (a.is_delete != 1 or a.is_delete is null)
-                                     and (b.is_delete != 1 or b.is_delete is null)
-                                     and  EXISTS (select distinct id  from community_article z where a.article_id = z.id and  (z.is_delete != 1 or z.is_delete is null))
-                                     group by b.user_id ) AA
-                                 group by user_id
+        select count(*) from (
+        select user_id,sum(count) counts from (
+        select
+        a.user_id, count(1) count
+        from community_article a
+        left join community_like b
+        on a.id = b.article_id
+        where (a.is_delete != 1 or a.is_delete is null)
+        and b.id is not null
+        GROUP BY a.user_id
+        union ALL
+        select
+        a.user_id,count(1) count
+        from
+        community_article_comment a
+        left join community_comment_like b
+        on a.id = b.comment_id
+        where (a.is_delete != 1 or a.is_delete is null)
+        and b.id is not null and EXISTS (select distinct id from community_article z where a.article_id = z.id and (z.is_delete != 1 or z.is_delete is null))
+        group by a.user_id
+        union all
+        select
+        b.user_id,count(1) count
+        from
+        community_article_comment a
+        left join community_comment_reply b on a.id = b.comment_id
+        left join community_comment_like c on b.id = c.reply_id
+        where
+        b.id is not null
+        and c.id is not null
+        and (a.is_delete != 1 or a.is_delete is null)
+        and (b.is_delete != 1 or b.is_delete is null)
+        and EXISTS (select distinct id from community_article z where a.article_id = z.id and (z.is_delete != 1 or z.is_delete is null))
+        group by b.user_id ) AA
+        group by user_id
         <if test="likeSum  != null and likeSum > 0">
             HAVING counts &lt;= #{likeSum}
         </if>
@@ -173,82 +172,160 @@
 
     </select>
     <select id="queryComment" resultType="com.ruoyi.generator.domain.Community.CommunityArticleComment">
-            SELECT A.id,#{articleId} as articleId,A.content,A.user_id,A.image_url,A.create_time,A.create_by,A.update_time,A.update_by,A.address
-            FROM (
-                     SELECT id,image_url,user_id,create_time,create_by,update_time,update_by,content,address
-                     FROM community_article_comment
-                     WHERE article_id =   #{articleId}
-                       AND (is_delete != 1 OR is_delete IS NULL)
-                     UNION ALL
-                     SELECT id,image_url,user_id,create_time,create_by,update_time,update_by,content,address
-                     FROM community_comment_reply
-                     WHERE comment_id IN (
-                         SELECT id
-                         FROM community_article_comment
-                         WHERE article_id =   #{articleId}
-                           AND (is_delete != 1 OR is_delete IS NULL)
-                     )
-                       AND (is_delete != 1 OR is_delete IS NULL)
-                 ) AS A
-            WHERE A.content LIKE CONCAT('%', #{comment}, '%')
-            limit #{offset},#{limit};
+        SELECT A.id,
+               #{articleId} as articleId,
+               A.content,
+               A.user_id,
+               A.image_url,
+               A.create_time,
+               A.create_by,
+               A.update_time,
+               A.update_by,
+               A.address
+        FROM (SELECT id,
+                     image_url,
+                     user_id,
+                     create_time,
+                     create_by,
+                     update_time,
+                     update_by,
+                     content,
+                     address
+              FROM community_article_comment
+              WHERE article_id = #{articleId}
+                AND (is_delete != 1 OR is_delete IS NULL)
+              UNION ALL
+              SELECT id,
+                     image_url,
+                     user_id,
+                     create_time,
+                     create_by,
+                     update_time,
+                     update_by,
+                     content,
+                     address
+              FROM community_comment_reply
+              WHERE comment_id IN (SELECT id
+                                   FROM community_article_comment
+                                   WHERE article_id = #{articleId}
+                                     AND (is_delete != 1 OR is_delete IS NULL))
+                AND (is_delete != 1 OR is_delete IS NULL)) AS A
+        WHERE A.content LIKE CONCAT('%', #{comment}, '%')
+            limit #{offset}
+            , #{limit};
     </select>
 
 
     <select id="getCommentListByUserId" resultType="com.ruoyi.generator.vo.CommentVo">
-        select id,
-               article_id,
-               type,
-               avatar,
-               nick_name,
-               create_time,
-               content,
-               is_read
-        from (select cac.id,
-                     cac.article_id,
-                     '0'                              as type,
-                     (select su.avatar
-                      from sys_user su
-                      where su.user_id = cac.user_id) as avatar,
-                     (select su.nick_name
-                      from sys_user su
-                      where su.user_id = cac.user_id) as nick_name,
-                     cac.create_time,
-                     cac.content,
-                     cac.is_read
-              from community_article ca
-                       left join community_article_comment cac on
-                  ca.id = cac.article_id
-              where ca.user_id = #{userId}
-                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)
-
-              union all
-
-              select ccr.id                   as id,
+        SELECT
+            c.id,
+            c.article_id,
+            c.image_url,
+            c.type,
+            c.avatar,
+            c.nick_name,
+            c.create_time,
+            c.content,
+            c.is_read
+        FROM (
+                 SELECT
+                     cac.id,
                      cac.article_id,
-                     '1'                              as type,
-                     (select su.avatar
-                      from sys_user su
-                      where su.user_id = ccr.user_id) as avatar,
-                     (select su.nick_name
-                      from sys_user su
-                      where su.user_id = ccr.user_id) as nick_name,
-                     ccr.create_time,
-                     ccr.content,
-                     ccr.is_read
-              from community_article_comment cac
-                       left join community_comment_reply ccr on
-                  cac.id = ccr.comment_id
-              where cac.user_id = #{userId}
-                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)) as comments
-        order by create_time desc
+                     (SELECT cai.image_url FROM community_article_images cai WHERE cac.article_id = cai.article_id AND (cai.is_delete IS NULL OR cai.is_delete != 1) ORDER BY cai.create_time DESC LIMIT 1) AS image_url,
+            '0' AS type,
+            su.avatar,
+            su.nick_name,
+            cac.create_time,
+            cac.content,
+            cac.is_read
+        FROM community_article ca
+            LEFT JOIN community_article_comment cac ON ca.id = cac.article_id
+            LEFT JOIN sys_user su ON cac.user_id = su.user_id
+        WHERE ca.user_id = #{userId}
+          AND cac.user_id != #{userId}
+          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)
+
+        UNION ALL
+
+        SELECT
+            ccr.id,
+            cac.article_id,
+            (SELECT cai.image_url FROM community_article_images cai WHERE cac.article_id = cai.article_id AND (cai.is_delete IS NULL OR cai.is_delete != 1) ORDER BY cai.create_time DESC LIMIT 1) AS image_url,
+        '1' AS type,
+        su.avatar,
+        su.nick_name,
+        ccr.create_time,
+        ccr.content,
+        ccr.is_read
+        FROM community_article_comment cac
+            LEFT JOIN community_comment_reply ccr ON cac.id = ccr.comment_id
+            LEFT JOIN sys_user su ON ccr.user_id = su.user_id
+        WHERE cac.user_id = #{userId}
+          AND ccr.user_id != #{userId}
+          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)
+
+        UNION ALL
+
+        SELECT
+            caa.id,
+            caa.article_id,
+            (SELECT cai.image_url FROM community_article_images cai WHERE caa.article_id = cai.article_id AND (cai.is_delete IS NULL OR cai.is_delete != 1) ORDER BY cai.create_time DESC LIMIT 1) AS image_url,
+        '5' AS type,
+        su.avatar,
+        su.nick_name,
+        caa.create_time,
+        NULL AS content,
+        caa.is_read
+        FROM community_article_at caa
+            LEFT JOIN sys_user su ON caa.user_id = su.user_id
+        WHERE caa.type = 0
+          AND caa.peer_id = #{userId}
+          AND (caa.is_delete IS NULL OR caa.is_delete != 1)
+
+        UNION ALL
+
+        SELECT
+            caa.id,
+            caa.article_id,
+            (SELECT cai.image_url FROM community_article_images cai WHERE caa.article_id = cai.article_id AND (cai.is_delete IS NULL OR cai.is_delete != 1) ORDER BY cai.create_time DESC LIMIT 1) AS image_url,
+        '6' AS type,
+        su.avatar,
+        su.nick_name,
+        caa.create_time,
+        cac.content,
+        caa.is_read
+        FROM community_article_at caa
+            LEFT JOIN community_article_comment cac ON caa.comment_id = cac.id
+            LEFT JOIN sys_user su ON caa.user_id = su.user_id
+        WHERE caa.type = 1
+          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)
+
+        UNION ALL
+
+        SELECT
+            caa.id,
+            caa.article_id,
+            (SELECT cai.image_url FROM community_article_images cai WHERE caa.article_id = cai.article_id AND (cai.is_delete IS NULL OR cai.is_delete != 1) ORDER BY cai.create_time DESC LIMIT 1) AS image_url,
+        '7' AS type,
+        su.avatar,
+        su.nick_name,
+        caa.create_time,
+        ccr.content,
+        caa.is_read
+        FROM community_article_at caa
+            LEFT JOIN community_comment_reply ccr ON caa.reply_id = ccr.id
+            LEFT JOIN sys_user su ON caa.user_id = su.user_id
+        WHERE caa.type = 2
+          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)
+            ) c
+        ORDER BY c.create_time DESC;
     </select>
 </mapper>