فهرست منبع

用户合集增加关注合集

fangqing 5 ماه پیش
والد
کامیت
88fee6b6d4

+ 7 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/vo/CommunityCollectionVo.java

@@ -79,4 +79,11 @@ public class CommunityCollectionVo implements Serializable {
     @ApiModelProperty("创建时间")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
+
+    /**
+     * 是否关注
+     */
+    @ApiModelProperty("创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Boolean isFollow;
 }

+ 40 - 2
ruoyi-generator/src/main/resources/mapper/community/CommunityCollectionMapper.xml

@@ -15,7 +15,8 @@
         a.create_by,
         a.update_by,
         a.create_time,
-        a.update_time
+        a.update_time,
+        '0'  as isFollow
         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
@@ -33,7 +34,44 @@
         a.create_by,
         a.update_by,
         a.create_time,
-        a.update_time;
+        a.update_time
+
+        union all
+
+        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,
+        '1'  as isFollow
+        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_user d ON d.collection_id = a.id
+        WHERE d.user_id =  #{userId} AND  d.id  is not 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
+
+
     </select>