Skip to content

Commit

Permalink
#4 fix: 쥬시 완료, 쥬시 대기 목록 정렬 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Haeun-Y committed Sep 25, 2023
1 parent eb06fb3 commit 21780d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/ewhatever/qna/user/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public Page<GetSinyAnswerResponse> getMyAnswers(String token, String status, int
checkSinyRole(user.getRole());
List<Sort.Order> sorts = new ArrayList<>();
if(status.equals("completed")) {//쥬시 완료
sorts.add(Sort.Order.desc("post_LastModifiedDate"));
sorts.add(Sort.Order.desc("post_JuicyDate"));
Pageable pageable = PageRequest.of(Math.max(requestPageNum-1, 0), 10, Sort.by(sorts));
return answerRepository.findByAnswerer_UserIdxAndPost_IsJuicyTrueAndStatusEquals(user.getUserIdx(), "active", pageable).map(answer ->
GetSinyAnswerResponse.fromAnswer(answer, 3L, true));
}
else {//쥬시 대기
sorts.add(Sort.Order.desc("createdDate"));
sorts.add(Sort.Order.asc("createdDate"));
Pageable pageable = PageRequest.of(Math.max(requestPageNum-1, 0), 10, Sort.by(sorts));
return answerRepository.findByAnswerer_UserIdxAndPost_IsJuicyFalseAndStatusEquals(user.getUserIdx(), "active", pageable).map(answer ->
GetSinyAnswerResponse.fromAnswer(answer, answerRepository.countByPost_PostIdxAndStatusEquals(answer.getPost().getPostIdx(), "active"), false));
Expand All @@ -78,13 +78,13 @@ public Page<GetJunyQuestionResponse> getMyQuestions(String token, String status,
checkJunyRole(user.getRole());
List<Sort.Order> sorts = new ArrayList<>();
if(status.equals("completed")) {//쥬시 완료
sorts.add(Sort.Order.desc("lastModifiedDate"));
sorts.add(Sort.Order.desc("juicyDate"));
Pageable pageable = PageRequest.of(Math.max(requestPageNum-1, 0), 10, Sort.by(sorts));
return postRepository.findByQuestioner_UserIdxAndIsJuicyTrueAndStatusEquals(user.getUserIdx(),"active", pageable).map(post ->
GetJunyQuestionResponse.fromPost(post, 3L, true));
}
else {//쥬시 대기
sorts.add(Sort.Order.desc("createdDate"));
sorts.add(Sort.Order.asc("createdDate"));
Pageable pageable = PageRequest.of(Math.max(requestPageNum-1, 0), 10, Sort.by(sorts));
return postRepository.findByQuestioner_UserIdxAndIsJuicyFalseAndStatusEquals(user.getUserIdx(), "active", pageable).map(post ->
GetJunyQuestionResponse.fromPost(post, answerRepository.countByPost_PostIdxAndStatusEquals(post.getPostIdx(), "active"), false));
Expand Down

0 comments on commit 21780d1

Please sign in to comment.