|
@@ -5,38 +5,34 @@
|
|
|
<mapper namespace="com.ruoyi.generator.mapper.community.CommunityCollectionMapper">
|
|
|
<select id="selectUserCollection" resultType="com.ruoyi.generator.vo.CommunityCollectionVo">
|
|
|
SELECT a.id,
|
|
|
- a.user_id,
|
|
|
- a.collection_name,
|
|
|
- a.collection_profile,
|
|
|
- a.images,
|
|
|
- a.is_delete,
|
|
|
- COUNT(b.article_id) AS articleCount, -- 计算文章数量
|
|
|
- SUM(c.page_views) AS pageViews, -- 计算页面浏览总数
|
|
|
- a.create_by,
|
|
|
- a.update_by,
|
|
|
- a.create_time,
|
|
|
- a.update_time
|
|
|
+ a.user_id,
|
|
|
+ a.collection_name,
|
|
|
+ a.collection_profile,
|
|
|
+ a.images,
|
|
|
+ a.is_delete,
|
|
|
+ COUNT(b.article_id) AS articleCount,
|
|
|
+ SUM(c.page_views) AS pageViews,
|
|
|
+ a.create_by,
|
|
|
+ a.update_by,
|
|
|
+ a.create_time,
|
|
|
+ a.update_time
|
|
|
FROM community_collection a
|
|
|
- LEFT JOIN
|
|
|
- community_collection_article b
|
|
|
- ON
|
|
|
- a.id = b.collection_id
|
|
|
- LEFT JOIN
|
|
|
- community_article c
|
|
|
- ON
|
|
|
- b.article_id = c.id
|
|
|
+ LEFT JOIN community_collection_article b ON a.id = b.collection_id
|
|
|
+ LEFT JOIN community_article c ON b.article_id = c.id
|
|
|
WHERE a.user_id = #{userId}
|
|
|
- AND (a.is_delete != '1' OR a.is_delete IS NULL)
|
|
|
+ AND (a.is_delete != '1' OR a.is_delete IS NULL)
|
|
|
+ <if test="articleId != null and articleId != ''">
|
|
|
+ AND b.article_id = #{articleId}
|
|
|
+ </if>
|
|
|
GROUP BY a.id,
|
|
|
- a.user_id,
|
|
|
- a.collection_name,
|
|
|
- a.collection_profile,
|
|
|
- a.images,
|
|
|
- a.is_delete,
|
|
|
- a.create_by,
|
|
|
- a.update_by,
|
|
|
- a.create_time,
|
|
|
- a.update_time;
|
|
|
-
|
|
|
+ a.user_id,
|
|
|
+ a.collection_name,
|
|
|
+ a.collection_profile,
|
|
|
+ a.images,
|
|
|
+ a.is_delete,
|
|
|
+ a.create_by,
|
|
|
+ a.update_by,
|
|
|
+ a.create_time,
|
|
|
+ a.update_time;
|
|
|
</select>
|
|
|
-</mapper>
|
|
|
+</mapper>
|