diff --git a/src/main/java/com/aptner/v3/board/comment/CommentService.java b/src/main/java/com/aptner/v3/board/comment/CommentService.java index aeb1bd1..d75ca36 100644 --- a/src/main/java/com/aptner/v3/board/comment/CommentService.java +++ b/src/main/java/com/aptner/v3/board/comment/CommentService.java @@ -18,6 +18,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.Collections; import java.util.Map; import java.util.stream.Collectors; @@ -105,7 +106,8 @@ public Page getPostWithComment(MemberDto memberDto, long postId, Pag Page commentsPage = commentRepository.findAllByPostIdAndParentCommentIdIsNull(postId, pageable); // reaction - Map mapCommentIdAndReactionType = commentReactionRepository.findByUserIdAndDtype(memberDto.getId(), "CommentReaction") + Map mapCommentIdAndReactionType = commentReactionRepository.findByUserIdAndDtypeAndTargetId(memberDto.getId(), "CommentReaction", postId) + .orElse(Collections.emptyList()) .stream() .collect(Collectors.toMap(CommentReaction::getTargetId, CommentReaction::getReactionType)); diff --git a/src/main/java/com/aptner/v3/board/common/reaction/ReactionRepository.java b/src/main/java/com/aptner/v3/board/common/reaction/ReactionRepository.java index 093a7f0..bd51d51 100644 --- a/src/main/java/com/aptner/v3/board/common/reaction/ReactionRepository.java +++ b/src/main/java/com/aptner/v3/board/common/reaction/ReactionRepository.java @@ -11,5 +11,5 @@ public interface ReactionRepository extends JpaRepository findByUserIdAndTargetIdAndDtype(long userId, long targetId, String postReaction); // post get - List findByUserIdAndDtype(long memberId, String commentReaction); + Optional> findByUserIdAndDtypeAndTargetId(long memberId, String commentReaction, long targetId); }