Skip to content

Commit

Permalink
Merge pull request #40 from EWHA-THON-E-BUS/develop
Browse files Browse the repository at this point in the history
[배포] post 리스트 조회 시 최신순으로 정렬
  • Loading branch information
Soyeon-Cha authored Mar 18, 2024
2 parents 0fc6f39 + a4908f3 commit d1c5ceb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public MainPageResDto getMainPage(){
}
}

List<Post> allSuggestion = postRepository.findAllByIsSuggestionOrderByCreatedDate(true);
List<Post> allSuggestion = postRepository.findAllByIsSuggestionOrderByCreatedDateDesc(true);
List<MainPostResDto> suggestionList = new ArrayList<>();
if (!(allSuggestion.isEmpty())){
if (allSuggestion.size()<3){
Expand All @@ -64,7 +64,7 @@ public MainPageResDto getMainPage(){
}
}

List<Post> allAppreciation = postRepository.findAllByIsSuggestionOrderByCreatedDate(false);
List<Post> allAppreciation = postRepository.findAllByIsSuggestionOrderByCreatedDateDesc(false);
List<MainPostResDto> appreciationList = new ArrayList<>();
if (!(allAppreciation.isEmpty())){
if(allAppreciation.size()<3){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@
import EBus.EBusback.domain.post.entity.Post;

public interface PostRepository extends JpaRepository<Post, Long> {

List<Post> findAllByIsSuggestion(Boolean isSuggestion);
List<Post> findAllByIsSuggestionOrderByCreatedDate(Boolean isSuggestion);
List<Post> findAllByIsSuggestionOrderByCreatedDateDesc(Boolean isSuggestion);
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public PostMemberDto findPostMemberInfo(Post post, Member member) {
// isSuggestion: true -> 건의해요 리스트 조회
// isSuggestion: false -> 고마워요 리스트 조회
public List<PostOutlineResponseDto> findPostList(Boolean isSuggestion) {
List<Post> postList = postRepository.findAllByIsSuggestion(isSuggestion);
List<Post> postList = postRepository.findAllByIsSuggestionOrderByCreatedDateDesc(isSuggestion);
return postList.stream()
.map(post -> new PostOutlineResponseDto(post, heartService.getHeartCount(post)))
.collect(Collectors.toList());
Expand Down

0 comments on commit d1c5ceb

Please sign in to comment.