Ver código fonte

增加根据文章ID搜索评论接口

fangqing 5 meses atrás
pai
commit
f2dd12d750

+ 17 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityCommentController.java

@@ -13,6 +13,7 @@ import com.ruoyi.generator.domain.Community.CommunityArticle;
 import com.ruoyi.generator.domain.Community.CommunityArticleComment;
 import com.ruoyi.generator.domain.Community.CommunityCommentLike;
 import com.ruoyi.generator.domain.Community.CommunityCommentReply;
+import com.ruoyi.generator.mapper.community.CommunityArticleCommentMapper;
 import com.ruoyi.generator.mapper.community.CommunityArticleMapper;
 import com.ruoyi.generator.mapper.community.CommunityCommentLikeMapper;
 import com.ruoyi.generator.service.ICommunityArticleCommentService;
@@ -68,6 +69,10 @@ public class CommunityCommentController extends BaseController {
 
     @Autowired
     private CommunityArticleMapper communityArticleMapper;
+
+    @Autowired
+    private CommunityArticleCommentMapper communityArticleCommentMapper;
+
     /**
      * 获取文章评论
      */
@@ -314,5 +319,17 @@ public class CommunityCommentController extends BaseController {
     }
 
 
+    @ApiOperation("查询评论")
+    @GetMapping("/queryComment")
+    @Transactional
+    //@Anonymous
+    public AjaxResult queryComment(Long articleId,String comment) {
+        if (Objects.isNull(articleId)) {
+            return AjaxResult.error("参数异常!");
+        }
+        List<CommunityArticleComment> communityArticleComments = communityArticleCommentMapper.queryComment(articleId, comment);
+
+        return AjaxResult.success(communityArticleComments);
+    }
 
 }

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

@@ -48,7 +48,7 @@ public interface CommunityArticleCommentMapper extends BaseMapper<CommunityArtic
     Integer queryCommentReplyLikeCountPerson (@Param("likeSum")  int likeSum);
 
 
-
+    List<CommunityArticleComment>  queryComment  (@Param("articleId")  Long articleId,@Param("comment")  String comment);
 
 
 }

+ 22 - 0
ruoyi-generator/src/main/resources/mapper/community/CommunityArticleCommentMapper.xml

@@ -171,4 +171,26 @@
         ) BB
 
     </select>
+    <select id="queryComment" resultType="com.ruoyi.generator.domain.Community.CommunityArticleComment">
+            SELECT A.id,#{articleId} as articleId,A.content,A.user_id,A.image_url,A.create_time,A.create_by,A.update_time,A.update_by,A.address
+            FROM (
+                     SELECT id,image_url,user_id,create_time,create_by,update_time,update_by,content,address
+                     FROM community_article_comment
+                     WHERE article_id =   #{articleId}
+                       AND (is_delete != 1 OR is_delete IS NULL)
+                     UNION ALL
+                     SELECT id,image_url,user_id,create_time,create_by,update_time,update_by,content,address
+                     FROM community_comment_reply
+                     WHERE comment_id IN (
+                         SELECT id
+                         FROM community_article_comment
+                         WHERE article_id =   #{articleId}
+                           AND (is_delete != 1 OR is_delete IS NULL)
+                     )
+                       AND (is_delete != 1 OR is_delete IS NULL)
+                 ) AS A
+            WHERE A.content LIKE CONCAT('%', #{comment}, '%');
+    </select>
+
+
 </mapper>