Skip to content

Commit

Permalink
BusStat 조회 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyaak committed Aug 24, 2024
1 parent a2d0031 commit 64370f1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<BusStatEntity, Long> {
List<BusStatEntity> 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<BusStatEntity> findByApiRouteIdAndApiStationIdAndBeforeTimeBetween(
@Param("apiRouteId") String apiRouteId,
@Param("apiStationId") String apiStationId,
@Param("startTime") LocalDateTime startTime,
@Param("endTime") LocalDateTime endTime

List<BusStatEntity> findByRouteIdAndStationIdAndBeforeTimeBetween(
Long routeId,
Long stationId,
LocalDateTime startTime,
LocalDateTime endTime
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.time.LocalDateTime;

public record BusStatReqDto(
String apiRouteId,
String apiStationId,
Long routeId,
Long stationId,
LocalDateTime startDateTime,
LocalDateTime endDateTime
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public class BusStatService {
private final BusStatRepository busStatRepository;

public List<BusStatRespDto> getBusStat(BusStatReqDto busStatReqDto) {
return busStatRepository.findByApiRouteIdAndApiStationIdAndBeforeTimeBetween(
busStatReqDto.apiRouteId(),
busStatReqDto.apiStationId(),
return busStatRepository.findByRouteIdAndStationIdAndBeforeTimeBetween(
busStatReqDto.routeId(),
busStatReqDto.stationId(),
busStatReqDto.startDateTime(),
busStatReqDto.endDateTime()
).stream()
Expand Down

0 comments on commit 64370f1

Please sign in to comment.