Skip to content

Commit 654707e

Browse files
committed
refactor: 막차 시간 자정을 넘기면 24시간 더하기
1 parent 21f420f commit 654707e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

domain/src/main/java/com/stop/domain/usecase/route/GetLastTransportTimeUseCaseImpl.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ internal class GetLastTransportTimeUseCaseImpl @Inject constructor(
7878

7979

8080
// 고유 번호로 승차지의 막차 시간 모두 알아내기
81-
val dataWithLastTime: List<String> = transportIdRequests.map { transportIdRequest ->
81+
val dataWithLastTime: List<Int> = transportIdRequests.map { transportIdRequest ->
8282
when (transportIdRequest.transportMoveType) {
8383
TransportMoveType.BUS -> getBusLastTransportTime(transportIdRequest)
8484
TransportMoveType.SUBWAY -> getSubwayLastTransportTime(transportIdRequest)
@@ -90,20 +90,25 @@ internal class GetLastTransportTimeUseCaseImpl @Inject constructor(
9090
return null
9191
}
9292

93-
private fun getSubwayLastTransportTime(transportIdRequest: TransportIdRequest): String {
93+
private fun getSubwayLastTransportTime(transportIdRequest: TransportIdRequest): Int {
9494
TODO()
9595
}
9696

97-
private suspend fun getBusLastTransportTime(transportIdRequest: TransportIdRequest): String {
97+
private suspend fun getBusLastTransportTime(transportIdRequest: TransportIdRequest): Int {
9898
when (transportIdRequest.area) {
9999
Area.GYEONGGI -> {
100100
TODO()
101101
}
102102
Area.SEOUL -> {
103-
return routeRepository.getSeoulBusLastTime(
103+
val lastTime = routeRepository.getSeoulBusLastTime(
104104
transportIdRequest.stationId,
105105
transportIdRequest.lineId
106-
)
106+
).toInt()
107+
108+
if (lastTime < MID_NIGHT) {
109+
return lastTime + MID_NIGHT
110+
}
111+
return lastTime
107112
}
108113
Area.UN_SUPPORT_AREA -> {
109114
TODO()
@@ -274,5 +279,7 @@ internal class GetLastTransportTimeUseCaseImpl @Inject constructor(
274279

275280
private const val SUBWAY_LINE_ONE = 1
276281
private const val SUBWAY_LINE_EIGHT = 8
282+
283+
private const val MID_NIGHT = 240_000
277284
}
278285
}

0 commit comments

Comments
 (0)