帖子重复以及首页不展示话题

上级 ce3aafb2
......@@ -214,6 +214,7 @@
INNER JOIN forum_resource fr ON fr.dynamic_id = fd.id
WHERE
fd.check_status = 1
and forum_dynamic_gambit.gambit_id not in (1001,1002)
<if test="userAccountId!=null">
and fd.user_account_id=#{userAccountId}
</if>
......@@ -414,7 +415,11 @@
</if>
</select>
<select id="dynamicList" resultType="com.mmc.csf.release.entity.forum.ForumDynamicDO">
select fd.id,
WITH ranked_data AS (
SELECT
fd.id,
version,
fd.user_account_id,
description,
......@@ -425,13 +430,14 @@
comments_count,
fd.create_time,
fd.id AS dynamicId,
transpond
from forum_dynamic fd
left join forum_dynamic_gambit on forum_dynamic_gambit.dynamic_id = fd.id
where is_deleted = 0
and root_path is null
and fd.check_status = 1
and gambit_id not in (1001,1002)
transpond,
ROW_NUMBER() OVER (PARTITION BY fd.id ORDER BY fd.create_time DESC) AS rn
FROM forum_dynamic fd
LEFT JOIN forum_dynamic_gambit ON forum_dynamic_gambit.dynamic_id = fd.id
WHERE is_deleted = 0
AND root_path IS NULL
AND fd.check_status = 1
AND gambit_id NOT IN (1001,1002)
<if test="id!=null" >
and id=#{id}
</if>
......@@ -441,14 +447,11 @@
<if test="description!=null and description!='' ">
and description like concat('%',#{description},'%')
</if>
<choose>
<when test="needSort != null">
order by likes_count desc
</when>
<otherwise>
)
SELECT *
FROM ranked_data
WHERE rn = 1
order by create_time desc
</otherwise>
</choose>
LIMIT #{itemIndex}, #{pageSize}
</select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论