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

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