From b5a046ed3459270902f73a8104fedf1330798db8 Mon Sep 17 00:00:00 2001 From: jangyeeunee Date: Fri, 20 Feb 2026 15:27:23 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20hotfix=20=EB=A6=AC=ED=8F=AC=ED=8A=B8=20?= =?UTF-8?q?=ED=95=98=EB=82=98=20=EC=84=A0=ED=83=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/JourneyQueryServiceImpl.java | 13 +++++++---- .../RoutineReportJpaRepository.java | 22 +++++++++++-------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/loopon/journey/application/JourneyQueryServiceImpl.java b/src/main/java/com/loopon/journey/application/JourneyQueryServiceImpl.java index e16e36d0..85f8aa23 100644 --- a/src/main/java/com/loopon/journey/application/JourneyQueryServiceImpl.java +++ b/src/main/java/com/loopon/journey/application/JourneyQueryServiceImpl.java @@ -17,6 +17,7 @@ import com.loopon.user.domain.User; import com.loopon.user.infrastructure.UserJpaRepository; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.stereotype.Service; @@ -292,13 +293,17 @@ public JourneyResponse.DailyJourneyReportDto getDailyJourneyReport( .orElseThrow(() -> new BusinessException(ErrorCode.JOURNEY_FEEDBACK_NOT_FOUND)); // RoutineReport 조회 - Optional routineReport = - routineReportRepository.findByUserAndJourneyAndDate( + List routineReports = + routineReportRepository.findFirstByUserAndJourneyAndDate( userId, journeyId, - date + date, + PageRequest.of(0,1) ); + Optional first = routineReports.stream().findFirst(); + String recordContent = first.map(RoutineReport::getContent).orElse(null); + return new JourneyResponse.DailyJourneyReportDto( journeyId, journey.getGoal(), @@ -310,7 +315,7 @@ public JourneyResponse.DailyJourneyReportDto getDailyJourneyReport( completedCount, - routineReport.map(RoutineReport::getContent), + Optional.ofNullable(recordContent), routineDtos ); diff --git a/src/main/java/com/loopon/routine/infrastructure/RoutineReportJpaRepository.java b/src/main/java/com/loopon/routine/infrastructure/RoutineReportJpaRepository.java index 5242dd7c..1157bcc2 100644 --- a/src/main/java/com/loopon/routine/infrastructure/RoutineReportJpaRepository.java +++ b/src/main/java/com/loopon/routine/infrastructure/RoutineReportJpaRepository.java @@ -1,24 +1,28 @@ package com.loopon.routine.infrastructure; import com.loopon.routine.domain.RoutineReport; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import java.time.LocalDate; -import java.util.Optional; +import java.util.List; + public interface RoutineReportJpaRepository extends JpaRepository { @Query(""" - SELECT rr - FROM RoutineReport rr - WHERE rr.user.id = :userId - AND rr.journey.id = :journeyId - AND DATE(rr.createdAt) = :date - """) - Optional findByUserAndJourneyAndDate( + SELECT rr + FROM RoutineReport rr + WHERE rr.user.id = :userId + AND rr.journey.id = :journeyId + AND DATE(rr.createdAt) = :date + ORDER BY rr.id ASC +""") + List findFirstByUserAndJourneyAndDate( @Param("userId") Long userId, @Param("journeyId") Long journeyId, - @Param("date") LocalDate date + @Param("date") LocalDate date, + Pageable pageable ); }