Skip to content

Commit

Permalink
#3 fix: 댓글 정렬 기준 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JoongHyun-Kim committed Sep 25, 2023
1 parent 60600e9 commit 5ef8891
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
public interface CommentRepository extends JpaRepository<Comment, Long> {
Long countByWriter_UserIdxAndStatusEquals(Long userIdx, String status);
Page<Comment> findByWriter_UserIdxAndStatusEquals(Long userIdx, String status, Pageable pageable);
List<Comment> findAllByPostAndStatusEqualsOrderByCreatedDateDesc(Post post, String status);
List<Comment> findAllByPostAndStatusEqualsOrderByCreatedDate(Post post, String status);
}
4 changes: 2 additions & 2 deletions src/main/java/com/ewhatever/qna/post/service/PostService.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private Boolean isScrap(User user, Post post) {
// 댓글 list 조회
private List<GetPostRes.CommentDto> getCommentList(Post post, User user) {
List<GetPostRes.CommentDto> commentList = new ArrayList<>();
List<Comment> comments = commentRepository.findAllByPostAndStatusEqualsOrderByCreatedDateDesc(post, ACTIVE); // 최신순
List<Comment> comments = commentRepository.findAllByPostAndStatusEqualsOrderByCreatedDate(post, ACTIVE); // 오래된 순

for (Comment comment : comments) {
GetPostRes.CommentDto commentDto = new GetPostRes.CommentDto(
Expand All @@ -197,7 +197,7 @@ private List<GetPostRes.CommentDto> getCommentList(Post post, User user) {

// 댓글 작성자 여부
private Boolean isWriter(User user, Comment comment) {
return comment.getWriter().equals(user);
return comment.getWriter().equals(user); // TODO: 이거 왜 이렇게 비교하지
}

// 댓글 작성자
Expand Down

0 comments on commit 5ef8891

Please sign in to comment.