Skip to content

Commit

Permalink
fix: 코멘트는 한 번만 남길 수 있도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
kimday0326 committed Jun 6, 2024
1 parent b8ea4c3 commit 30b4e19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ public void createComment(PullRequestCommentCreateRequest request, Long reviewer
if (file.getWriterId().equals(reviewerId)) {
throw new CustomException(HttpStatus.BAD_REQUEST, "본인이 작성한 파일에 대한 pull-request는 승인할 수 없습니다.");
}

if (pullRequestCommentRepository.existsByPullRequestIdAndReviewerId(pullRequestId, reviewerId)) {
throw new CustomException(HttpStatus.BAD_REQUEST, "이미 리뷰를 완료했습니다.");
}
PullRequestComment pullRequestComment = new PullRequestComment(
request.getComment(),
request.getIsApproved(),
reviewerId,
pullRequest.getId()
);

pullRequestCommentRepository.save(pullRequestComment);

List<PullRequestComment> comments = pullRequestCommentRepository.findAllByPullRequestId(pullRequest.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

@Repository
public interface PullRequestCommentRepository extends JpaRepository<PullRequestComment, Long> {
boolean existsByPullRequestIdAndReviewerId(Long pullRequestId, Long reviewerId);

List<PullRequestComment> findAllByPullRequestId(Long pullRequestId);
}

0 comments on commit 30b4e19

Please sign in to comment.