diff --git a/src/main/java/org/runnect/server/health/repository/RecordHealthDataRepository.java b/src/main/java/org/runnect/server/health/repository/RecordHealthDataRepository.java index 72e37b5..afdc4a9 100644 --- a/src/main/java/org/runnect/server/health/repository/RecordHealthDataRepository.java +++ b/src/main/java/org/runnect/server/health/repository/RecordHealthDataRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.repository.query.Param; import java.time.LocalDateTime; +import java.util.List; import java.util.Optional; public interface RecordHealthDataRepository extends Repository { @@ -27,7 +28,7 @@ public interface RecordHealthDataRepository extends Repository= :startDate AND r.createdAt < :endDate") - Object[] getHealthSummary(@Param("userId") Long userId, - @Param("startDate") LocalDateTime startDate, - @Param("endDate") LocalDateTime endDate); + List getHealthSummary(@Param("userId") Long userId, + @Param("startDate") LocalDateTime startDate, + @Param("endDate") LocalDateTime endDate); } diff --git a/src/main/java/org/runnect/server/health/service/HealthService.java b/src/main/java/org/runnect/server/health/service/HealthService.java index d9c0c76..23f67be 100644 --- a/src/main/java/org/runnect/server/health/service/HealthService.java +++ b/src/main/java/org/runnect/server/health/service/HealthService.java @@ -153,7 +153,8 @@ public GetHealthSummaryResponseDto getHealthSummary(Long userId, String startDat LocalDateTime endDateTime = endDate.plusDays(1).atStartOfDay(); // 3. 통계 쿼리 실행 - Object[] result = recordHealthDataRepository.getHealthSummary(userId, startDateTime, endDateTime); + List results = recordHealthDataRepository.getHealthSummary(userId, startDateTime, endDateTime); + Object[] result = results.isEmpty() ? new Object[10] : results.get(0); Long totalRecords = result[0] != null ? ((Number) result[0]).longValue() : 0L; Long recordsWithHealth = result[1] != null ? ((Number) result[1]).longValue() : 0L;