Skip to content

Commit

Permalink
refactor: 마감임박 북토크 조회 리팩토링 (#87)
Browse files Browse the repository at this point in the history
(cherry picked from commit 416530e)
  • Loading branch information
onpyeong authored and dong2ast committed Aug 15, 2023
1 parent 513906c commit 445dbc3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ default Booktalk getBooktalkById(Long booktalkId) {
+ " join m.operatorProperty o"
+ " where m.email = :email")
List<Booktalk> getWatingBooktalks(@Param("email") String email);

List<Booktalk> findAllByBooktalkStatusOrderByEndDate(BooktalkStatus booktalkStatus);
}
20 changes: 2 additions & 18 deletions src/main/java/org/sophy/sophy/service/BooktalkService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.sophy.sophy.service;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -122,22 +120,8 @@ public void postBooktalkParticipation(

// 마감임박 북토크 조회
public List<BooktalkDeadlineUpcomingDto> getBooktalkDeadlineUpcoming() {
List<Place> placeList = placeRepository.findAll();

List<BooktalkDeadlineUpcomingDto> booktalkList = new ArrayList<>();
placeList.forEach(place -> place.getBooktalkList().forEach(booktalk -> {
// 모집중인 북토크만 추가
if (booktalk.getBooktalkStatus() == BooktalkStatus.RECRUITING) {
booktalkList.add(BooktalkDeadlineUpcomingDto.of(booktalk));
}
}
));

// 마감 임박순으로 정렬
booktalkList.sort(Comparator.comparing(BooktalkDeadlineUpcomingDto::getEndDate));

return booktalkList;

return booktalkRepository.findAllByBooktalkStatusOrderByEndDate(BooktalkStatus.RECRUITING)
.stream().map(BooktalkDeadlineUpcomingDto::of).collect(Collectors.toList());
}

//지역으로 북토크 조회
Expand Down

0 comments on commit 445dbc3

Please sign in to comment.