From 5d2b99715754c6ed257c91e818c49108f9ff7aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=95=9C=EA=B4=80=ED=9D=AC?= Date: Sat, 27 Jul 2024 19:11:20 +0900 Subject: [PATCH] =?UTF-8?q?=EB=82=B4=20=EC=9E=AC=ED=99=9C=20=EC=9A=B4?= =?UTF-8?q?=EB=8F=99=20=EA=B8=B0=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20API?= =?UTF-8?q?=EC=97=90=EC=84=9C=20startDate=20=EC=9D=B4=EC=A0=84=EC=9D=98=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=EA=B0=80=20=EC=97=86=EC=9D=84=20?= =?UTF-8?q?=EB=95=8C=20=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20404=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95=20(#16)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/persistence/repository/RecordJpaRepository.java | 3 ++- .../domain/persistence/repository/RecordRepositoryImpl.java | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/stempo/api/domain/persistence/repository/RecordJpaRepository.java b/src/main/java/com/stempo/api/domain/persistence/repository/RecordJpaRepository.java index f2ea028c..d9366279 100644 --- a/src/main/java/com/stempo/api/domain/persistence/repository/RecordJpaRepository.java +++ b/src/main/java/com/stempo/api/domain/persistence/repository/RecordJpaRepository.java @@ -7,6 +7,7 @@ import java.time.LocalDateTime; import java.util.List; +import java.util.Optional; public interface RecordJpaRepository extends JpaRepository { @@ -24,7 +25,7 @@ List findByDateBetween( "WHERE r.createdAt < :startDateTime " + "ORDER BY r.createdAt DESC " + "LIMIT 1") - RecordEntity findLatestBeforeStartDate( + Optional findLatestBeforeStartDate( @Param("startDateTime") LocalDateTime startDateTime ); } diff --git a/src/main/java/com/stempo/api/domain/persistence/repository/RecordRepositoryImpl.java b/src/main/java/com/stempo/api/domain/persistence/repository/RecordRepositoryImpl.java index badde763..dc4249ea 100644 --- a/src/main/java/com/stempo/api/domain/persistence/repository/RecordRepositoryImpl.java +++ b/src/main/java/com/stempo/api/domain/persistence/repository/RecordRepositoryImpl.java @@ -9,6 +9,7 @@ import java.time.LocalDateTime; import java.util.List; +import java.util.Optional; @Repository @RequiredArgsConstructor @@ -34,7 +35,8 @@ public List findByDateBetween(LocalDateTime startDateTime, LocalDateTime @Override public Record findLatestBeforeStartDate(LocalDateTime startDateTime) { - RecordEntity jpaEntity = repository.findLatestBeforeStartDate(startDateTime); - return mapper.toDomain(jpaEntity); + Optional jpaEntity = repository.findLatestBeforeStartDate(startDateTime); + return jpaEntity.map(mapper::toDomain) + .orElse(null); } }