Skip to content

Commit

Permalink
#3 fix: comment, answer 조회 시 날짜 기준 재설정
Browse files Browse the repository at this point in the history
  • Loading branch information
JoongHyun-Kim committed Sep 24, 2023
1 parent 7b37d78 commit b65a6bd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@Repository
public interface AnswerRepository extends JpaRepository<Answer, Long> {
List<Answer> findAllByPostOrderByLastModifiedDateDesc(Post post);
List<Answer> findAllByPostOrderByCreatedDateDesc(Post post);
Long countByAnswerer_UserIdxAndStatusEquals(Long userIdx, String status);
Page<Answer> findByAnswerer_UserIdxAndPost_IsJuicyTrueAndStatusEquals(Long userIdx, String status, Pageable pageable);
Page<Answer> findByAnswerer_UserIdxAndPost_IsJuicyFalseAndStatusEquals(Long userIdx, String status, Pageable pageable);
Expand Down
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> findAllByPostAndStatusEqualsOrderByLastModifiedDateDesc(Post post, String status);
List<Comment> findAllByPostAndStatusEqualsOrderByCreatedDateDesc(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 @@ -79,7 +79,7 @@ private List<String> getCardList(Post post) {

cardList.add(post.getTitle());
cardList.add(post.getContent());
List<Answer> answers = answerRepository.findAllByPostOrderByLastModifiedDateDesc(post); // 답변 등록 날짜 순 조회
List<Answer> answers = answerRepository.findAllByPostOrderByCreatedDateDesc(post); // 답변 등록 날짜 순 조회
for (Answer answer : answers) {
cardList.add(answer.getContent());
}
Expand Down 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.findAllByPostAndStatusEqualsOrderByLastModifiedDateDesc(post, ACTIVE); // 최신순
List<Comment> comments = commentRepository.findAllByPostAndStatusEqualsOrderByCreatedDateDesc(post, ACTIVE); // 최신순

for (Comment comment : comments) {
GetPostRes.CommentDto commentDto = new GetPostRes.CommentDto(
Expand Down

0 comments on commit b65a6bd

Please sign in to comment.