Skip to content

Commit a4058c7

Browse files
committed
refactor: now location에 order 추가하기
1 parent 04f701b commit a4058c7

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

data/src/main/java/com/stop/data/remote/source/nowlocation/NowLocationRemoteDataSource.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ import com.stop.data.model.nowlocation.BusInfoRepositoryItem
44

55
interface NowLocationRemoteDataSource {
66

7-
suspend fun getBusNowLocation(busRouteId: String): BusInfoRepositoryItem
8-
7+
suspend fun getBusNowLocation(busRouteId: String, order: Int): BusInfoRepositoryItem
98
}

data/src/main/java/com/stop/data/remote/source/nowlocation/NowLocationRemoteDataSourceImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ internal class NowLocationRemoteDataSourceImpl @Inject constructor(
99
private val wsBusApiService: WsBusApiService
1010
) : NowLocationRemoteDataSource {
1111

12-
override suspend fun getBusNowLocation(busRouteId: String): BusInfoRepositoryItem {
12+
override suspend fun getBusNowLocation(busRouteId: String, order: Int): BusInfoRepositoryItem {
1313
with(wsBusApiService.getBusNowLocation(busRouteId = busRouteId)) {
1414
return when (this) {
15-
is NetworkResult.Success -> this.data.busBody.busInfo.first().toRepositoryModel()
15+
is NetworkResult.Success -> this.data.busBody.busInfo[order].toRepositoryModel()
1616
is NetworkResult.Failure -> throw IllegalArgumentException(this.message)
1717
is NetworkResult.NetworkError -> throw this.exception
1818
is NetworkResult.Unexpected -> throw this.exception

data/src/main/java/com/stop/data/repository/NowLocationRepositoryImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class NowLocationRepositoryImpl @Inject constructor(
99
private val nowLocationRemoteDataSource: NowLocationRemoteDataSource
1010
) : NowLocationRepository{
1111

12-
override suspend fun getBusNowLocation(busRouteId: String): BusInfoUseCaseItem {
13-
return nowLocationRemoteDataSource.getBusNowLocation(busRouteId).toUseCaseModel()
12+
override suspend fun getBusNowLocation(busRouteId: String, order: Int): BusInfoUseCaseItem {
13+
return nowLocationRemoteDataSource.getBusNowLocation(busRouteId, order).toUseCaseModel()
1414
}
1515

1616
}

domain/src/main/java/com/stop/domain/repository/NowLocationRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import com.stop.domain.model.nowlocation.BusInfoUseCaseItem
44

55
interface NowLocationRepository {
66

7-
suspend fun getBusNowLocation(busRouteId: String): BusInfoUseCaseItem
7+
suspend fun getBusNowLocation(busRouteId: String, order: Int): BusInfoUseCaseItem
88

99
}

domain/src/main/java/com/stop/domain/usecase/nowlocation/GetBusNowLocationUseCaseImpl.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ class GetBusNowLocationUseCaseImpl @Inject constructor(
99
) : GetBusNowLocationUseCase {
1010

1111
override suspend fun getBusNowLocation(busRouteId: String): BusInfoUseCaseItem {
12-
return nowLocationRepository.getBusNowLocation(busRouteId)
12+
return nowLocationRepository.getBusNowLocation(busRouteId, TEST_ORDER)
13+
}
14+
15+
companion object {
16+
private const val TEST_ORDER = 1
1317
}
1418

1519
}

0 commit comments

Comments
 (0)