Skip to content

Commit

Permalink
[merge] 댓글 전체 조회 시 response에 댓글 Id값 추가
Browse files Browse the repository at this point in the history
[fix] 댓글 전체 조회 시 response에 댓글 Id값 추가
  • Loading branch information
lreowy authored Sep 12, 2024
2 parents 3a370c2 + fa6b781 commit 8c95d90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
@Builder
public record CommentGetResponse(

Long commentId,

boolean isOwner,

String commenterImageUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class CommentQueryService {
private final GuestRepository guestRepository;

public List<CommentGetResponse> getCommentListByNotice(Long noticeId) {
List<Comment> commentList = commentRepository.findCommentsByNoticeId(noticeId);
Notice notice = noticeRepository.findNoticeByIdOrThrow(noticeId);
List<Comment> commentList = commentRepository.findCommentsByNoticeId(notice.getId());
return commentList.stream().map(comment -> {
boolean isOwner = checkOwner(comment.getCommenter().getId(), noticeId);
return buildCommentGetResponse(comment, checkOwner(comment.getCommenter().getId(), noticeId),
Expand All @@ -38,6 +39,7 @@ public List<CommentGetResponse> getCommentListByNotice(Long noticeId) {

private CommentGetResponse buildCommentGetResponse(Comment comment, boolean isOwner, CommenterInfo commenterInfo) {
return CommentGetResponse.builder()
.commentId(comment.getId())
.isOwner(isOwner)
.commenterImageUrl(commenterInfo.getProfileImageUrl())
.commenterNickname(commenterInfo.getProfileNickname())
Expand Down

0 comments on commit 8c95d90

Please sign in to comment.