Skip to content

Commit

Permalink
#262 feat: CommentGetResponse dto에 추가된 필드값 넣도록 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
letskuku committed Oct 1, 2024
1 parent 21fb0f2 commit 05eb505
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class CommentServiceImpl implements CommentService {

private static final Boolean COMMENT_IS_NOT_LIKED = false;
private static final Boolean COMMENT_IS_NOT_WRITTEN = false;

private final PostService postService;
private final CounselorService counselorService;
Expand All @@ -41,7 +43,8 @@ public List<CommentGetResponse> getCounselorComments(Long postId, Long customerI
return comments.stream()
.map(comment -> CommentGetResponse.of(comment,
commentLikeRepository.existsByCommentAndCustomerAndIsActivatedIsTrue(
comment, customer)))
comment, customer),
comment.getCounselor().equals(customer.getCounselor())))
.toList();
}

Expand All @@ -58,12 +61,13 @@ public List<CommentGetResponse> getCustomerComments(Long postId, Long customerId
return comments.stream()
.map(comment -> CommentGetResponse.of(comment,
commentLikeRepository.existsByCommentAndCustomerAndIsActivatedIsTrue(
comment, customer)))
comment, customer), COMMENT_IS_NOT_WRITTEN))
.toList();
}

return comments.stream()
.map(comment -> CommentGetResponse.of(comment, COMMENT_IS_NOT_LIKED))
.map(comment -> CommentGetResponse.of(comment, COMMENT_IS_NOT_LIKED,
COMMENT_IS_NOT_WRITTEN))
.toList();
}

Expand Down Expand Up @@ -114,6 +118,7 @@ public Boolean getIsCommentOwner(Long postId, Long customerId) {
Post post = postService.getPostByPostId(postId);
Counselor counselor = counselorService.getCounselorByCustomerId(customerId);

return commentRepository.findByPostAndCounselorAndIsActivatedIsTrue(post, counselor) != null;
return commentRepository.findByPostAndCounselorAndIsActivatedIsTrue(post, counselor)
!= null;
}
}

0 comments on commit 05eb505

Please sign in to comment.