From 64370f153b972d7d78185ba9349414caa40386a7 Mon Sep 17 00:00:00 2001 From: PSH Date: Sun, 25 Aug 2024 00:03:06 +0900 Subject: [PATCH] =?UTF-8?q?BusStat=20=EC=A1=B0=ED=9A=8C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../talkka/server/bus/dao/BusStatRepository.java | 15 ++++++--------- .../com/talkka/server/bus/dto/BusStatReqDto.java | 4 ++-- .../talkka/server/bus/service/BusStatService.java | 6 +++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/server/src/main/java/com/talkka/server/bus/dao/BusStatRepository.java b/server/src/main/java/com/talkka/server/bus/dao/BusStatRepository.java index 68b06c8d..ef10a70a 100644 --- a/server/src/main/java/com/talkka/server/bus/dao/BusStatRepository.java +++ b/server/src/main/java/com/talkka/server/bus/dao/BusStatRepository.java @@ -4,19 +4,16 @@ import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @Repository public interface BusStatRepository extends JpaRepository { List findByBeforeTimeBetween(LocalDateTime startTime, LocalDateTime endTime); - - @Query("SELECT b FROM bus_stat b WHERE b.apiRouteId = :apiRouteId AND b.apiStationId = :apiStationId AND b.beforeTime BETWEEN :startTime AND :endTime") - List findByApiRouteIdAndApiStationIdAndBeforeTimeBetween( - @Param("apiRouteId") String apiRouteId, - @Param("apiStationId") String apiStationId, - @Param("startTime") LocalDateTime startTime, - @Param("endTime") LocalDateTime endTime + + List findByRouteIdAndStationIdAndBeforeTimeBetween( + Long routeId, + Long stationId, + LocalDateTime startTime, + LocalDateTime endTime ); } diff --git a/server/src/main/java/com/talkka/server/bus/dto/BusStatReqDto.java b/server/src/main/java/com/talkka/server/bus/dto/BusStatReqDto.java index ee2d9988..59c0291d 100644 --- a/server/src/main/java/com/talkka/server/bus/dto/BusStatReqDto.java +++ b/server/src/main/java/com/talkka/server/bus/dto/BusStatReqDto.java @@ -3,8 +3,8 @@ import java.time.LocalDateTime; public record BusStatReqDto( - String apiRouteId, - String apiStationId, + Long routeId, + Long stationId, LocalDateTime startDateTime, LocalDateTime endDateTime ) { diff --git a/server/src/main/java/com/talkka/server/bus/service/BusStatService.java b/server/src/main/java/com/talkka/server/bus/service/BusStatService.java index 3f0fb939..85ff8935 100644 --- a/server/src/main/java/com/talkka/server/bus/service/BusStatService.java +++ b/server/src/main/java/com/talkka/server/bus/service/BusStatService.java @@ -33,9 +33,9 @@ public class BusStatService { private final BusStatRepository busStatRepository; public List getBusStat(BusStatReqDto busStatReqDto) { - return busStatRepository.findByApiRouteIdAndApiStationIdAndBeforeTimeBetween( - busStatReqDto.apiRouteId(), - busStatReqDto.apiStationId(), + return busStatRepository.findByRouteIdAndStationIdAndBeforeTimeBetween( + busStatReqDto.routeId(), + busStatReqDto.stationId(), busStatReqDto.startDateTime(), busStatReqDto.endDateTime() ).stream()