From 3154abdf0caf9f522f8e7b332ed3bf680bfd0369 Mon Sep 17 00:00:00 2001 From: jinny Date: Thu, 25 Jul 2024 09:10:40 +0900 Subject: [PATCH] fix: exclude deleted (though exists in database) posts from retrieval --- .../java/org/poolc/api/post/repository/PostRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/poolc/api/post/repository/PostRepository.java b/src/main/java/org/poolc/api/post/repository/PostRepository.java index 3a541f8d..6e2cd502 100644 --- a/src/main/java/org/poolc/api/post/repository/PostRepository.java +++ b/src/main/java/org/poolc/api/post/repository/PostRepository.java @@ -14,10 +14,13 @@ @Repository public interface PostRepository extends JpaRepository, PagingAndSortingRepository, JpaSpecificationExecutor { + @Query("select p from Post p where p.member=:member and p.isDeleted=false") Page findByMember(Member member, Pageable pageable); @Query("select p from Post p where p.boardType=:boardType and p.isDeleted=false") Page findByBoardType(@Param("boardType") BoardType boardType, Pageable pageable); + + @Query("select p from Post p where (p.title like %:title% or p.body like %:body%) and p.isDeleted = false") Page findByTitleContainingOrBodyContaining(String title, String body, Pageable pageable); }