Эх сурвалжийг харах

查询文章接口优化(过滤拉黑用户)

fangqing 4 сар өмнө
parent
commit
8ae337de31

+ 2 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleMapper.java

@@ -34,7 +34,8 @@ public interface CommunityArticleMapper extends BaseMapper<CommunityArticle> {
                                                         @Param("classIds") List<Long> classIds,
                                                         @Param("classIds") List<Long> classIds,
                                                         @Param("offset") int offset,
                                                         @Param("offset") int offset,
                                                         @Param("limit") int limit,
                                                         @Param("limit") int limit,
-                                                        @Param("searchType") int searchType);
+                                                        @Param("searchType") int searchType,
+                                                        @Param("loginId") Long loginId);
 
 
     /**
     /**
      * 获取该用户是否收藏该文章
      * 获取该用户是否收藏该文章

+ 1 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleServiceImpl.java

@@ -163,7 +163,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
 
 
         //根据分类查找文章
         //根据分类查找文章
         int offset = (pageNum - 1) * pageSize;
         int offset = (pageNum - 1) * pageSize;
-        communityArticleVos = communityArticleMapper.selectCommunityArticleList(communityArticle, classIds, offset, pageSize, searchType);
+        communityArticleVos = communityArticleMapper.selectCommunityArticleList(communityArticle, classIds, offset, pageSize, searchType,userId);
 
 
         List<CommunityArticleVo> articleVos_copy = new ArrayList<>(communityArticleVos);
         List<CommunityArticleVo> articleVos_copy = new ArrayList<>(communityArticleVos);
         if (noCollection != null){
         if (noCollection != null){

+ 1 - 0
ruoyi-generator/src/main/resources/mapper/community/ArticleMapper.xml

@@ -209,6 +209,7 @@
                 AND IFNULL(a.is_Draft,0) = #{communityArticle.isDraft}
                 AND IFNULL(a.is_Draft,0) = #{communityArticle.isDraft}
             </if>
             </if>
             and (is_delete != 1 or is_delete is null)
             and (is_delete != 1 or is_delete is null)
+            and a.user_id not in (select distinct peer_id from community_user_block where user_id = #{loginId} and is_block = 1 )
         </where>
         </where>
         group by a.id,a.create_time
         group by a.id,a.create_time
         <if test="searchType == 1">
         <if test="searchType == 1">