Skip to content

Commit 7d26037

Browse files
authored
Merge branch 'develop' into 67-feature-background-alarm
2 parents 269842a + 639f11f commit 7d26037

File tree

61 files changed

+1060
-320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1060
-320
lines changed

โ€Ždata/src/main/java/com/stop/data/model/nowlocation/BusInfoRepositoryItem.kt

Lines changed: 0 additions & 23 deletions
This file was deleted.

โ€Ždata/src/main/java/com/stop/data/remote/ResultCall.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ internal class ResultCall<T : Any>(private val call: Call<T>) : Call<NetworkResu
4747
this@ResultCall,
4848
Response.success(NetworkResult.Success(responseBody))
4949
)
50-
} else {
51-
callback.onResponse(
52-
this@ResultCall,
53-
Response.success(
54-
NetworkResult.Failure(
55-
response.code(),
56-
response.errorBody()?.string()
57-
)
50+
return
51+
}
52+
callback.onResponse(
53+
this@ResultCall,
54+
Response.success(
55+
NetworkResult.Failure(
56+
response.code(),
57+
response.errorBody()?.string()
5858
)
5959
)
60-
}
60+
)
6161
}
6262

6363
override fun onFailure(call: Call<T>, t: Throwable) {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.stop.data.remote.model.nowlocation.bus
22

33
import com.squareup.moshi.Json
4+
import com.stop.domain.model.nowlocation.BusCurrentInformation
45

56
data class BusBody(
67
@Json(name = "itemList")
7-
val busInfo: List<BusInfo>
8+
val busCurrentInformation: List<BusCurrentInformation>
89
)

โ€Ždata/src/main/java/com/stop/data/remote/model/nowlocation/bus/BusInfo.kt

Lines changed: 0 additions & 30 deletions
This file was deleted.

โ€Ždata/src/main/java/com/stop/data/remote/model/nowlocation/subway/SubwayTrainNowLocationResponse.kt

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,9 @@ package com.stop.data.remote.model.nowlocation.subway
22

33
import com.squareup.moshi.Json
44
import com.squareup.moshi.JsonClass
5-
import com.stop.data.model.nowlocation.SubwayTrainRealTimePositionRepositoryItem
65

76
@JsonClass(generateAdapter = true)
87
data class SubwayTrainNowLocationResponse(
98
@Json(name = "realtimePositionList")
109
val realtimePositions: List<TrainLocationInfo>
11-
) {
12-
fun toRepositoryModel(trainNumber: String): SubwayTrainRealTimePositionRepositoryItem {
13-
return realtimePositions.first { it.trainNumber == trainNumber }.run {
14-
SubwayTrainRealTimePositionRepositoryItem(
15-
subwayId = subwayId,
16-
subwayName = stationName,
17-
stationId = stationId,
18-
stationName = stationName + STATION,
19-
trainNumber = this.trainNumber,
20-
trainStatus = trainStatus
21-
)
22-
}
23-
}
24-
25-
companion object {
26-
private const val STATION = "์—ญ"
27-
}
28-
}
10+
)

โ€Ždata/src/main/java/com/stop/data/remote/model/nowlocation/subway/TrainLocationInfo.kt

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package com.stop.data.remote.model.nowlocation.subway
22

33
import com.squareup.moshi.Json
44
import com.squareup.moshi.JsonClass
5+
import com.stop.domain.model.ApiChangedException
6+
import com.stop.domain.model.nowlocation.TrainLocationInfoDomain
7+
import com.stop.domain.model.route.seoul.subway.TransportDirectionType
58

69
@JsonClass(generateAdapter = true)
710
data class TrainLocationInfo(
@@ -11,9 +14,35 @@ data class TrainLocationInfo(
1114
@Json(name = "statnId")
1215
val stationId: String,
1316
@Json(name = "statnNm")
14-
val stationName: String,
17+
val currentStationName: String,
1518
@Json(name = "trainNo")
1619
val trainNumber: String,
1720
@Json(name = "trainSttus")
18-
val trainStatus: String // 0:์ง„์ž… 1:๋„์ฐฉ, 0,1์™ธ ๋‚˜๋จธ์ง€๋Š”:์ถœ๋ฐœ
19-
)
21+
val trainStatus: String, // 0:์ง„์ž… 1:๋„์ฐฉ, 0,1์™ธ ๋‚˜๋จธ์ง€๋Š”:์ถœ๋ฐœ
22+
@Json(name = "statnTnm")
23+
val destinationStationName: String,
24+
@Json(name = "updnLine")
25+
val subwayDirection: String,
26+
@Json(name = "lstcarAt")
27+
val isLastTrain: String, // (1:๋ง‰์ฐจ, 0:์•„๋‹˜)
28+
) {
29+
fun toDomain() = TrainLocationInfoDomain(
30+
subwayId = subwayId,
31+
subwayName = subwayName,
32+
stationId = stationId,
33+
currentStationName = currentStationName,
34+
trainNumber = trainNumber,
35+
trainStatus = trainStatus,
36+
destinationStationName = destinationStationName,
37+
subwayDirection = when (subwayDirection) {
38+
"1" -> TransportDirectionType.INNER
39+
"0" -> TransportDirectionType.OUTER
40+
else -> throw ApiChangedException()
41+
},
42+
isLastTrain = when (isLastTrain) {
43+
"1" -> true
44+
"0" -> false
45+
else -> throw ApiChangedException()
46+
},
47+
)
48+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.stop.data.remote.source.nowlocation
22

3-
import com.stop.data.model.nowlocation.BusInfoRepositoryItem
4-
import com.stop.data.model.nowlocation.SubwayTrainRealTimePositionRepositoryItem
3+
import com.stop.domain.model.nowlocation.BusCurrentInformation
4+
import com.stop.data.remote.model.nowlocation.subway.TrainLocationInfo
55

66
interface NowLocationRemoteDataSource {
77

8-
suspend fun getBusNowLocation(busRouteId: String, order: Int): BusInfoRepositoryItem
8+
suspend fun getBusNowLocation(busRouteId: String): List<BusCurrentInformation>
99

10-
suspend fun getSubwayTrainNowStation(trainNumber: String, subwayNumber: Int): SubwayTrainRealTimePositionRepositoryItem
10+
suspend fun getSubwayTrainNowStation(subwayNumber: Int): List<TrainLocationInfo>
1111
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.stop.data.remote.source.nowlocation
22

3-
import com.stop.data.model.nowlocation.BusInfoRepositoryItem
4-
import com.stop.data.model.nowlocation.SubwayTrainRealTimePositionRepositoryItem
53
import com.stop.data.remote.model.NetworkResult
4+
import com.stop.domain.model.nowlocation.BusCurrentInformation
5+
import com.stop.data.remote.model.nowlocation.subway.TrainLocationInfo
66
import com.stop.data.remote.network.SwOpenApiSeoulService
77
import com.stop.data.remote.network.WsBusApiService
88
import javax.inject.Inject
@@ -12,21 +12,21 @@ internal class NowLocationRemoteDataSourceImpl @Inject constructor(
1212
private val swOpenApiSeoulService: SwOpenApiSeoulService
1313
) : NowLocationRemoteDataSource {
1414

15-
override suspend fun getBusNowLocation(busRouteId: String, order: Int): BusInfoRepositoryItem {
15+
override suspend fun getBusNowLocation(busRouteId: String): List<BusCurrentInformation> {
1616
with(wsBusApiService.getBusNowLocation(busRouteId = busRouteId)) {
1717
return when (this) {
18-
is NetworkResult.Success -> data.busBody.busInfo[order].toRepositoryModel()
18+
is NetworkResult.Success -> data.busBody.busCurrentInformation
1919
is NetworkResult.Failure -> throw IllegalArgumentException(message)
2020
is NetworkResult.NetworkError -> throw exception
2121
is NetworkResult.Unexpected -> throw exception
2222
}
2323
}
2424
}
2525

26-
override suspend fun getSubwayTrainNowStation(trainNumber: String, subwayNumber: Int): SubwayTrainRealTimePositionRepositoryItem {
26+
override suspend fun getSubwayTrainNowStation(subwayNumber: Int): List<TrainLocationInfo> {
2727
with(swOpenApiSeoulService.getSubwayTrainNowStationInfo(stationName = subwayNumber.toString() + LINE)) {
2828
return when (this) {
29-
is NetworkResult.Success -> data.toRepositoryModel(trainNumber)
29+
is NetworkResult.Success -> data.realtimePositions
3030
is NetworkResult.Failure -> throw IllegalArgumentException(message)
3131
is NetworkResult.NetworkError -> throw exception
3232
is NetworkResult.Unexpected -> throw exception

โ€Ždata/src/main/java/com/stop/data/remote/source/route/RouteRemoteDataSource.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import com.stop.domain.model.route.seoul.bus.BusStationInfo
77
import com.stop.domain.model.route.seoul.bus.LastTimeInfo
88
import com.stop.domain.model.route.seoul.subway.Station
99
import com.stop.domain.model.route.seoul.subway.StationLastTime
10-
import com.stop.domain.model.route.seoul.subway.SubwayCircleType
10+
import com.stop.domain.model.route.seoul.subway.TransportDirectionType
1111
import com.stop.domain.model.route.seoul.subway.WeekType
1212
import com.stop.domain.model.route.tmap.RouteRequest
1313
import com.stop.domain.model.route.tmap.custom.Coordinate
@@ -23,7 +23,7 @@ internal interface RouteRemoteDataSource {
2323
suspend fun getSubwayStations(lineName: String): List<Station>
2424
suspend fun getSubwayStationLastTime(
2525
stationId: String,
26-
subwayCircleType: SubwayCircleType,
26+
transportDirectionType: TransportDirectionType,
2727
weekType: WeekType,
2828
): List<StationLastTime>
2929

โ€Ždata/src/main/java/com/stop/data/remote/source/route/RouteRemoteDataSourceImpl.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.stop.data.remote.source.route
22

3+
import com.squareup.moshi.JsonDataException
34
import com.stop.data.remote.model.NetworkResult
45
import com.stop.data.remote.network.ApisDataService
56
import com.stop.data.remote.network.OpenApiSeoulService
@@ -30,7 +31,11 @@ internal class RouteRemoteDataSourceImpl @Inject constructor(
3031
tMapApiService.getRoutes(routeRequest.toMap())
3132
) {
3233
return when (this) {
33-
is NetworkResult.Success -> eraseDuplicateLeg(this.data.metaData.plan.itineraries)
34+
is NetworkResult.Success -> {
35+
val itineraries = this.data.metaData?.plan?.itineraries
36+
?: throw JsonDataException(NO_ROUTE_RESULT)
37+
eraseDuplicateLeg(itineraries)
38+
}
3439
is NetworkResult.Failure -> throw IllegalArgumentException(this.message)
3540
is NetworkResult.NetworkError -> throw this.exception
3641
is NetworkResult.Unexpected -> throw this.exception
@@ -95,15 +100,19 @@ internal class RouteRemoteDataSourceImpl @Inject constructor(
95100

96101
override suspend fun getSubwayStationLastTime(
97102
stationId: String,
98-
subwayCircleType: SubwayCircleType,
103+
transportDirectionType: TransportDirectionType,
99104
weekType: WeekType,
100105
): List<StationLastTime> {
101106
with(
102107
openApiSeoulService.getSubwayLastTime(
103108
serviceName = "SearchLastTrainTimeByIDService",
104109
stationId = stationId,
105110
weekTag = weekType.divisionValue,
106-
inOutTag = subwayCircleType.divisionValue,
111+
inOutTag = when (transportDirectionType) {
112+
TransportDirectionType.INNER, TransportDirectionType.TO_END -> "1"
113+
TransportDirectionType.OUTER, TransportDirectionType.TO_FIRST -> "2"
114+
TransportDirectionType.UNKNOWN -> throw IllegalArgumentException()
115+
},
107116
)
108117
) {
109118
return when (this) {
@@ -242,5 +251,6 @@ internal class RouteRemoteDataSourceImpl @Inject constructor(
242251

243252
companion object {
244253
private const val NO_SUBWAY_STATION = "ํ•ด๋‹นํ•˜๋Š” ์ง€ํ•˜์ฒ ์—ญ์ด ์—†์Šต๋‹ˆ๋‹ค."
254+
private const val NO_ROUTE_RESULT = "๊ฒฝ๋กœ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."
245255
}
246256
}

0 commit comments

Comments
ย (0)