From e48c28b568e7b1caf9013724d86c039773c28494 Mon Sep 17 00:00:00 2001 From: sso0om Date: Tue, 14 Oct 2025 16:14:11 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Refactor:=20reservation=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20orderBy=20pageable=EC=97=90=EC=84=9C=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ReservationRepository.java | 2 -- .../service/ReservationService.java | 7 ++++++- .../service/ReservationServiceTest.java | 20 +++++++++---------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/back/src/main/java/com/back/domain/mentoring/reservation/repository/ReservationRepository.java b/back/src/main/java/com/back/domain/mentoring/reservation/repository/ReservationRepository.java index d2507b80..e0cf6a84 100644 --- a/back/src/main/java/com/back/domain/mentoring/reservation/repository/ReservationRepository.java +++ b/back/src/main/java/com/back/domain/mentoring/reservation/repository/ReservationRepository.java @@ -33,7 +33,6 @@ Optional findByIdAndMember( SELECT r FROM Reservation r WHERE r.mentor.member.id = :memberId - ORDER BY r.mentorSlot.startDateTime DESC """) Page findAllByMentorMember( @Param("memberId") Long memberId, @@ -44,7 +43,6 @@ Page findAllByMentorMember( SELECT r FROM Reservation r WHERE r.mentee.member = :member - ORDER BY r.mentorSlot.startDateTime DESC """) Page findAllByMenteeMember( @Param("member") Member member, diff --git a/back/src/main/java/com/back/domain/mentoring/reservation/service/ReservationService.java b/back/src/main/java/com/back/domain/mentoring/reservation/service/ReservationService.java index 1a2772b9..b7bc508f 100644 --- a/back/src/main/java/com/back/domain/mentoring/reservation/service/ReservationService.java +++ b/back/src/main/java/com/back/domain/mentoring/reservation/service/ReservationService.java @@ -23,6 +23,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -39,7 +40,11 @@ public class ReservationService { @Transactional(readOnly = true) public Page getReservations(Member member, int page, int size) { - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of( + page, + size, + Sort.by(Sort.Direction.DESC, "mentorSlot.startDateTime") + ); Page reservations; diff --git a/back/src/test/java/com/back/domain/mentoring/reservation/service/ReservationServiceTest.java b/back/src/test/java/com/back/domain/mentoring/reservation/service/ReservationServiceTest.java index bfa2820e..f9ce0d23 100644 --- a/back/src/test/java/com/back/domain/mentoring/reservation/service/ReservationServiceTest.java +++ b/back/src/test/java/com/back/domain/mentoring/reservation/service/ReservationServiceTest.java @@ -33,10 +33,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.*; import org.springframework.test.util.ReflectionTestUtils; import java.time.LocalDateTime; @@ -96,16 +93,16 @@ void getReservations() { // given int page = 1; int size = 5; - Pageable pageable = PageRequest.of(page, size); - Page reservationPage = new PageImpl<>( List.of(reservation), - pageable, + PageRequest.of(page, size), 10 ); - when(reservationRepository.findAllByMentorMember(mentor.getMember().getId(), pageable)) - .thenReturn(reservationPage); + when(reservationRepository.findAllByMentorMember( + eq(mentor.getMember().getId()), + any(Pageable.class) + )).thenReturn(reservationPage); // when Page result = reservationService.getReservations( @@ -119,7 +116,10 @@ void getReservations() { assertThat(result.getSize()).isEqualTo(5); assertThat(result.getTotalElements()).isEqualTo(10); assertThat(result.getTotalPages()).isEqualTo(2); - verify(reservationRepository).findAllByMentorMember(mentor.getMember().getId(), pageable); + verify(reservationRepository).findAllByMentorMember( + eq(mentor.getMember().getId()), + any(Pageable.class) + ); } } From da7a14182957f83727ad5049e53ab3442887d02b Mon Sep 17 00:00:00 2001 From: sso0om Date: Tue, 14 Oct 2025 16:34:37 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Refactor:=20review=20=EB=AA=A9=EB=A1=9D=20o?= =?UTF-8?q?rderBy=20pageable=EC=97=90=EC=84=9C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentoring/mentoring/repository/ReviewRepository.java | 1 - .../domain/mentoring/mentoring/service/ReviewService.java | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/back/src/main/java/com/back/domain/mentoring/mentoring/repository/ReviewRepository.java b/back/src/main/java/com/back/domain/mentoring/mentoring/repository/ReviewRepository.java index 938462de..92642124 100644 --- a/back/src/main/java/com/back/domain/mentoring/mentoring/repository/ReviewRepository.java +++ b/back/src/main/java/com/back/domain/mentoring/mentoring/repository/ReviewRepository.java @@ -34,7 +34,6 @@ Double calculateMentoringAverageRating( SELECT r FROM Review r WHERE r.reservation.mentoring.id = :mentoringId - ORDER BY r.createDate DESC """) Page findAllByMentoringId( @Param("mentoringId") Long mentoringId, diff --git a/back/src/main/java/com/back/domain/mentoring/mentoring/service/ReviewService.java b/back/src/main/java/com/back/domain/mentoring/mentoring/service/ReviewService.java index 2b079a73..78e2040a 100644 --- a/back/src/main/java/com/back/domain/mentoring/mentoring/service/ReviewService.java +++ b/back/src/main/java/com/back/domain/mentoring/mentoring/service/ReviewService.java @@ -14,6 +14,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -26,7 +27,11 @@ public class ReviewService { @Transactional(readOnly = true) public Page getReviews(Long mentoringId, int page, int size) { - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of( + page, + size, + Sort.by(Sort.Direction.DESC, "createDate") + ); return reviewRepository.findAllByMentoringId(mentoringId, pageable) .map(ReviewResponse::from); From 05a4668bb67b65b0a276910564599e833039d44e Mon Sep 17 00:00:00 2001 From: sso0om Date: Tue, 14 Oct 2025 17:24:50 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Refactor:=20=EC=8B=9C=EA=B0=84=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/mentoring/slot/service/MentorSlotService.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/back/src/main/java/com/back/domain/mentoring/slot/service/MentorSlotService.java b/back/src/main/java/com/back/domain/mentoring/slot/service/MentorSlotService.java index c9b496e4..666917b9 100644 --- a/back/src/main/java/com/back/domain/mentoring/slot/service/MentorSlotService.java +++ b/back/src/main/java/com/back/domain/mentoring/slot/service/MentorSlotService.java @@ -157,15 +157,13 @@ private LocalDate findNextOrSameDayOfWeek(LocalDate startDate, DayOfWeek targetD * 매 시간 30분에 지난 슬롯 만기 처리 * - AVAILABLE -> EXPIRED */ - @Scheduled(cron = "0 */30 * * * *") + @Scheduled(cron = "0 */30 * * * *", zone = "Asia/Seoul") @Transactional public void expirePassedSlots() { LocalDateTime now = LocalDateTime.now(); - int updateCount = mentorSlotRepository.expirePassedSlots(now); - if (updateCount > 0) { - log.info("만료된 슬롯 {}개 업데이트 완료 at {}", updateCount, now); - } + + log.info("만료된 슬롯 {}개 업데이트 완료 at {}", updateCount, now); }