ソースを参照

文章获取新增默认,最新和最热

fangzhen 7 ヶ月 前
コミット
2caacaeee7

+ 2 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityArticleController.java

@@ -73,7 +73,8 @@ public class CommunityArticleController extends BaseController {
     public TableDataInfo communityList(CommunityArticle communityArticle) {
         int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
         int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
-        List<CommunityArticleVo> list = communityArticleService.selectCommunityArticleList(communityArticle, pageNum, pageSize);
+        int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 0);
+        List<CommunityArticleVo> list = communityArticleService.selectCommunityArticleList(communityArticle, pageNum, pageSize, searchType);
         return getDataTable(list);
     }
 

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

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

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

@@ -84,7 +84,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
      * @return 文章信息集合
      */
     @Override
-    public List<CommunityArticleVo> selectCommunityArticleList(CommunityArticle communityArticle, int pageNum, int pageSize) {
+    public List<CommunityArticleVo> selectCommunityArticleList(CommunityArticle communityArticle, int pageNum, int pageSize, int searchType) {
         //找出板块下的分类
         Long classId = communityArticle.getClassId();
         Long id = communityArticle.getId();
@@ -121,7 +121,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
 
         //根据分类查找文章
         int offset = (pageNum - 1) * pageSize;
-        communityArticleVos = communityArticleMapper.selectCommunityArticleList(communityArticle, circleIds, offset, pageSize);
+        communityArticleVos = communityArticleMapper.selectCommunityArticleList(communityArticle, circleIds, offset, pageSize, searchType);
         for (CommunityArticleVo articleVo : communityArticleVos) {
             List<Map<String, Object>> imageList = articleVo.getImageList();
             List<CommunityArticleImages> videoList = new ArrayList<>();

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

@@ -22,7 +22,7 @@ public interface ICommunityArticleService extends IService<CommunityArticle> {
      * @param communityArticle 文章信息
      * @return 文章信息集合
      */
-    List<CommunityArticleVo> selectCommunityArticleList(CommunityArticle communityArticle, int pageNum, int pageSize);
+    List<CommunityArticleVo> selectCommunityArticleList(CommunityArticle communityArticle, int pageNum, int pageSize, int searchType);
 
     /**
      * 发布文章

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

@@ -180,6 +180,13 @@
             </if>
         </where>
         group by a.id
+        <if test="searchType == 1">
+            order by a.create_time desc
+        </if>
+
+        <if test="searchType == 2">
+            order by a.page_views desc
+        </if>
         limit #{offset},#{limit}
     </select>