|
@@ -6,116 +6,115 @@
|
|
<select id="queryCommentCount" resultType="java.lang.Integer">
|
|
<select id="queryCommentCount" resultType="java.lang.Integer">
|
|
select d.commentCount + d.replyCount
|
|
select d.commentCount + d.replyCount
|
|
from (select c.article_id,
|
|
from (select c.article_id,
|
|
- count(1) as commentCount,
|
|
|
|
|
|
+ count(1) as commentCount,
|
|
(select count(1) as replyCount
|
|
(select count(1) as replyCount
|
|
from community_article_comment a
|
|
from community_article_comment a
|
|
left join community_comment_reply b on a.id = b.comment_id
|
|
left join community_comment_reply b on a.id = b.comment_id
|
|
where a.article_id = #{articleId}
|
|
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>
|
|
|
|
|
|
<select id="queryCommentReplyCount" resultType="java.lang.Integer">
|
|
<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>
|
|
|
|
|
|
|
|
|
|
<select id="queryCommentReplyCountPerson" resultType="java.lang.Integer">
|
|
<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 <= #{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 <= #{commentSum}
|
|
|
|
+ </if>
|
|
|
|
+ ) h
|
|
</select>
|
|
</select>
|
|
<select id="queryCommentReplyLikeCount" resultType="java.lang.Integer">
|
|
<select id="queryCommentReplyLikeCount" resultType="java.lang.Integer">
|
|
- select sum(count) sum from (
|
|
|
|
|
|
+ select sum(count) sum
|
|
|
|
+ from (
|
|
select
|
|
select
|
|
- a.user_id, count(1) count
|
|
|
|
|
|
+ a.user_id, count (1) count
|
|
from community_article a
|
|
from community_article a
|
|
- left join community_like b
|
|
|
|
|
|
+ left join community_like b
|
|
on a.id = b.article_id
|
|
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 b.id is not null
|
|
and a.user_id = #{userId}
|
|
and a.user_id = #{userId}
|
|
-
|
|
|
|
GROUP BY a.user_id
|
|
GROUP BY a.user_id
|
|
union ALL
|
|
union ALL
|
|
select
|
|
select
|
|
- a.user_id,count(1) count
|
|
|
|
|
|
+ a.user_id, count (1) count
|
|
from
|
|
from
|
|
community_article_comment a
|
|
community_article_comment a
|
|
left join community_comment_like b
|
|
left join community_comment_like b
|
|
on a.id = b.comment_id
|
|
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
|
|
union all
|
|
select
|
|
select
|
|
- b.user_id,count(1) count
|
|
|
|
|
|
+ b.user_id, count (1) count
|
|
from
|
|
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_reply b on a.id = b.comment_id
|
|
left join community_comment_like c on b.id = c.reply_id
|
|
left join community_comment_like c on b.id = c.reply_id
|
|
where
|
|
where
|
|
@@ -124,47 +123,47 @@
|
|
and c.id is not null
|
|
and c.id is not null
|
|
and (a.is_delete != 1 or a.is_delete is null)
|
|
and (a.is_delete != 1 or a.is_delete is null)
|
|
and (b.is_delete != 1 or b.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 b.user_id ) AA
|
|
group by user_id
|
|
group by user_id
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="queryCommentReplyLikeCountPerson" resultType="java.lang.Integer">
|
|
<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">
|
|
<if test="likeSum != null and likeSum > 0">
|
|
HAVING counts <= #{likeSum}
|
|
HAVING counts <= #{likeSum}
|
|
</if>
|
|
</if>
|
|
@@ -173,82 +172,160 @@
|
|
|
|
|
|
</select>
|
|
</select>
|
|
<select id="queryComment" resultType="com.ruoyi.generator.domain.Community.CommunityArticleComment">
|
|
<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>
|
|
|
|
|
|
|
|
|
|
<select id="getCommentListByUserId" resultType="com.ruoyi.generator.vo.CommentVo">
|
|
<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,
|
|
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>
|
|
</select>
|
|
</mapper>
|
|
</mapper>
|