From 445dbc3c00d85f3646722ebdbfb33b59aba6c404 Mon Sep 17 00:00:00 2001 From: Suhyeon <70002218+onpyeong@users.noreply.github.com> Date: Tue, 15 Aug 2023 14:40:35 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=A7=88=EA=B0=90=EC=9E=84?= =?UTF-8?q?=EB=B0=95=20=EB=B6=81=ED=86=A0=ED=81=AC=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81=20(#87)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 416530e6cb57a517da123dc01bf93187de5df15e) --- .../infrastructure/BooktalkRepository.java | 2 ++ .../sophy/sophy/service/BooktalkService.java | 20 ++----------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java index b25870c..4bbdde5 100644 --- a/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java +++ b/src/main/java/org/sophy/sophy/infrastructure/BooktalkRepository.java @@ -30,4 +30,6 @@ default Booktalk getBooktalkById(Long booktalkId) { + " join m.operatorProperty o" + " where m.email = :email") List getWatingBooktalks(@Param("email") String email); + + List findAllByBooktalkStatusOrderByEndDate(BooktalkStatus booktalkStatus); } diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java index 09c30dc..8df1442 100644 --- a/src/main/java/org/sophy/sophy/service/BooktalkService.java +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -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; @@ -122,22 +120,8 @@ public void postBooktalkParticipation( // 마감임박 북토크 조회 public List getBooktalkDeadlineUpcoming() { - List placeList = placeRepository.findAll(); - - List 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()); } //지역으로 북토크 조회