Skip to content

Commit 1aba2bc

Browse files
committed
fix: 좋아요 조회 시 삭제된 게시글 제외
1 parent 6140f05 commit 1aba2bc

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/main/java/com/semosan/api/domain/community/like/service/PostLikeService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public boolean hasLiked(Long postId, Long userId) {
6868
}
6969

7070
private Post findPostOrThrow(Long postId) {
71-
return postRepository.findById(postId)
71+
return postRepository.findByIdAndDeletedFalse(postId)
7272
.orElseThrow(() -> new GeneralException(ErrorStatus.POST_NOT_FOUND));
7373
}
7474

src/main/java/com/semosan/api/domain/community/post/repository/PostRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
import com.semosan.api.domain.community.post.entity.Post;
44
import org.springframework.data.jpa.repository.JpaRepository;
55

6+
import java.util.Optional;
7+
68
public interface PostRepository extends JpaRepository<Post, Long> {
9+
Optional<Post> findByIdAndDeletedFalse(Long id);
710
}

0 commit comments

Comments
 (0)