瀏覽代碼

Merge remote-tracking branch 'origin/dev' into dev

fangzhen 2 月之前
父節點
當前提交
e403a9d616
共有 1 個文件被更改,包括 15 次插入64 次删除
  1. 15 64
      ruoyi-generator/src/main/resources/mapper/community/ArticleMapper.xml

+ 15 - 64
ruoyi-generator/src/main/resources/mapper/community/ArticleMapper.xml

@@ -350,86 +350,37 @@
              ) AS A
     </select>
 
-    <!-- 查询用戶ID下沒有加入集合的文章列表 -->
     <select id="selectUserNoCoArticles" resultMap="CommunityArticleVoResult">
         SELECT
         a.id as article_id,
         a.user_id as article_user_id,
         a.title as article_title,
-        a.is_comment as article_is_comment,
+        a.is_comment as article_is_comment,  -- 去重
         a.content as article_content,
         a.page_views as pageViews,
         a.create_by as article_create_by,
         a.create_time as article_create_time,
         a.update_by as article_update_by,
         a.update_time as article_update_time,
-        IFNULL(a.address, '未知') as address,
-        a.is_comment,
+        a.address as address,
         a.is_raffle,
-        a.is_download,
-        a.article_type,
-        COALESCE((
-        SELECT
-        JSON_ARRAYAGG(
-        CASE
-        WHEN b.id IS NOT NULL THEN
-        JSON_OBJECT(
-        'id', IFNULL(b.id,''),
-        'articleId', IFNULL(b.article_id,''),
-        'imageUrl', IFNULL(b.image_url,''),
-        'compressUrl', IFNULL(b.compress_url,''),
-        'createBy', IFNULL(b.create_by,''),
-        'createTime', IFNULL(DATE_FORMAT(b.create_time,'%Y-%m-%d %H:%i:%s'),''),
-        'updateBy', IFNULL(b.update_by,''),
-        'updateTime', IFNULL(DATE_FORMAT(b.update_time,'%Y-%m-%d %H:%i:%s'),'')
-        )
-        ELSE NULL
-        END
-        )
-        FROM
-        community_article_images b
-        WHERE
-        b.article_id = a.id
-        and (b.is_delete != 1 or b.is_delete is null)
-        ), '[]') AS images,
-        c.user_name as user_name,
-        c.nick_name as nick_name,
-        c.email as email,
-        c.avatar as avatar
-        # COALESCE((
-        # SELECT
-        # JSON_ARRAYAGG(
-        # CASE
-        # WHEN d.id IS NOT NULL THEN
-        # JSON_OBJECT(
-        # 'id', IFNULL(d.id,''),
-        # 'articleId', IFNULL(d.article_id,''),
-        # 'userId', IFNULL(d.user_id,''),
-        # 'content', IFNULL(d.content,''),
-        # 'createBy', IFNULL(d.create_by,''),
-        # 'createTime', IFNULL(DATE_FORMAT(d.create_time,'%Y-%m-%d %H:%i:%s'),''),
-        # 'updateBy', IFNULL(d.update_by,''),
-        # 'updateTime', IFNULL(DATE_FORMAT(d.update_time,'%Y-%m-%d %H:%i:%s'),'')
-        # )
-        # ELSE NULL
-        # END
-        # )
-        # FROM
-        # community_article_comment d
-        # WHERE
-        # d.article_id = a.id and d.is_delete != 1 order by d.create_time desc
-        # ), '[]') AS comments
-        from
-        community_article a
-        left join sys_user c on a.user_id = c.user_id
-        left join community_article_class e on e.article_id = a.id
-        left join community_article_tag f on f.article_id = a.id
+        COALESCE(
+        (SELECT JSON_ARRAYAGG(JSON_OBJECT('imageUrl', IFNULL(b.image_url,'')))
+        FROM community_article_images b
+        WHERE b.article_id = a.id
+        AND IFNULL(b.is_delete, 0) != 1),
+        '[]'
+        ) AS images,
+        a.is_download
+        FROM community_article a
         WHERE a.create_by = #{userId}
         AND NOT EXISTS (
         SELECT 1
         FROM community_collection_article c
-        WHERE c.article_id = a.id  AND (c.is_delete != 1 OR c.is_delete IS NULL)
-        ) AND (a.is_delete != 1 OR a.is_delete IS NULL)
+        WHERE c.article_id = a.id
+        AND IFNULL(c.is_delete, 0) != 1
+        )
+        AND IFNULL(a.is_delete, 0) != 1  -- 统一过滤条件
     </select>
 
 </mapper>