Prechádzať zdrojové kódy

新增个人喜欢/收藏接口

fangqing 5 mesiacov pred
rodič
commit
4f1aa6b057

+ 40 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityArticleController.java

@@ -1045,4 +1045,44 @@ public class CommunityArticleController extends BaseController {
         return AjaxResult.success(communityUserPromptVo);
     }
 
+    @ApiOperation("个人喜欢文章")
+    @GetMapping("/userLike")
+    public AjaxResult userLike() {
+        int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
+        int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
+        int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 0);
+
+        TableDataInfo rspData = null;
+        CommunityArticle communityArticle  = new CommunityArticle();
+        List<CommunityArticleVo> communityArticleVos = null;
+        try {
+            communityArticleVos = communityArticleService.selectUserLike(pageNum, pageSize, searchType);
+
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+            throw new ProjectException();
+        }
+        return  AjaxResult.success(communityArticleVos);
+    }
+
+    @ApiOperation("个人收藏文章")
+    @GetMapping("/userCollect")
+    public AjaxResult userCollect() {
+        int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
+        int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
+        int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 0);
+
+        TableDataInfo rspData = null;
+        CommunityArticle communityArticle  = new CommunityArticle();
+        List<CommunityArticleVo> communityArticleVos = null;
+        try {
+            communityArticleVos = communityArticleService.selectUserCollect(pageNum, pageSize, searchType);
+
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+            throw new ProjectException();
+        }
+        return  AjaxResult.success(communityArticleVos);
+    }
+
 }

+ 9 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleCollectMapper.java

@@ -0,0 +1,9 @@
+package com.ruoyi.generator.mapper.community;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.generator.domain.Community.CommunityArticleCollect;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface CommunityArticleCollectMapper extends BaseMapper<CommunityArticleCollect> {
+}

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

@@ -111,6 +111,10 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
 
     @Autowired
     private CommunityUserPromptMapper communityUserPromptMapper;
+
+    @Autowired
+    private CommunityArticleCollectMapper communityArticleCollectMapper;
+
     /**
      * 查询文章列表
      *
@@ -879,6 +883,38 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
         return communityUserPromptVos;
     }
 
+    @Override
+    public List<CommunityArticleVo> selectUserLike(int pageNum, int pageSize, int searchType) {
+        Long userId = SecurityUtils.getUserId();
+        // 查询自己的通知列表
+        List<CommunityLike> communityUserLike
+                = communityLikeMapper
+                .selectList(new QueryWrapper<CommunityLike>().eq("user_id", userId));
+        List<Long> articleIds = communityUserLike.stream().map(item -> item.getArticleId()).collect(Collectors.toList());
+        TableDataInfo rspData = new TableDataInfo();
+        CommunityArticle communityArticle = new CommunityArticle();
+        communityArticle.setArticleIds(articleIds);
+        List<CommunityArticleVo> communityArticleVos = communityArticleService.selectCommunityArticleList(rspData, communityArticle, pageNum, pageSize, searchType);
+        return communityArticleVos;
+    }
+
+    @Override
+    public List<CommunityArticleVo> selectUserCollect(int pageNum, int pageSize, int searchType) {
+        Long userId = SecurityUtils.getUserId();
+        // 查询自己的通知列表
+        List<CommunityArticleCollect> communityArticleCollects
+                = communityArticleCollectMapper
+                .selectList(new QueryWrapper<CommunityArticleCollect>().eq("user_id", userId));
+
+
+        List<Long> articleIds = communityArticleCollects.stream().map(item -> item.getArticleId()).collect(Collectors.toList());
+        TableDataInfo rspData = new TableDataInfo();
+        CommunityArticle communityArticle = new CommunityArticle();
+        communityArticle.setArticleIds(articleIds);
+        List<CommunityArticleVo> communityArticleVos = communityArticleService.selectCommunityArticleList(rspData, communityArticle, pageNum, pageSize, searchType);
+        return communityArticleVos;
+    }
+
     /**
      * 判断是否是视频文件
      *

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

@@ -181,4 +181,28 @@ public interface ICommunityArticleService extends IService<CommunityArticle> {
      * @return
      */
     List<CommunityUserPromptVo> selectCommunityUserPrompt(Long userId);
+
+    /**
+     *
+     * 查询个人喜欢文章
+     *
+     * @param pageNum
+     * @param pageSize
+     * @param searchType
+     * @return
+     */
+    List<CommunityArticleVo> selectUserLike(int pageNum, int pageSize, int searchType);
+
+
+    /**
+     *
+     * 查询个人收藏文章
+     *
+     * @param pageNum
+     * @param pageSize
+     * @param searchType
+     * @return
+     */
+    List<CommunityArticleVo> selectUserCollect(int pageNum, int pageSize, int searchType);
+
 }