Skip to content

Commit 22a51e7

Browse files
committed
refactor : NearPlaceApiService 없애고, TMap으로 통일 & getNearPlaces() 함수 Query 기본 값 미리 넣어주기
1 parent 7b5575e commit 22a51e7

File tree

14 files changed

+39
-102
lines changed

14 files changed

+39
-102
lines changed

data/src/main/java/com/stop/data/di/ApiModule.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ internal object ApiModule {
4343
return retrofit.create(ApisDataService::class.java)
4444
}
4545

46-
@Provides
47-
@Singleton
48-
fun providePlaceApiService(@Named("Tmap") retrofit: Retrofit): NearPlaceApiService {
49-
return retrofit.create(NearPlaceApiService::class.java)
50-
}
51-
5246
@Provides
5347
@Singleton
5448
fun provideSwOpenApiSeoulService(@Named("SwOpenApiSeoul") retrofit: Retrofit): SwOpenApiSeoulService {

data/src/main/java/com/stop/data/remote/network/NearPlaceApiService.kt

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

data/src/main/java/com/stop/data/remote/network/TmapApiService.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.stop.data.remote.network
22

33
import com.stop.data.remote.model.NetworkResult
4+
import com.stop.data.remote.model.nearplace.NearPlaceResponse
45
import com.stop.domain.model.route.tmap.origin.ReverseGeocodingResponse
56
import com.stop.domain.model.route.tmap.origin.RouteResponse
67
import retrofit2.http.Body
@@ -24,12 +25,23 @@ internal interface TmapApiService {
2425
@Query("addressType") addressType: String = REVERSE_GEOCODING_ADDRESS_TYPE,
2526
) : NetworkResult<ReverseGeocodingResponse>
2627

28+
@GET(PLACE_SEARCH_URL)
29+
suspend fun getNearPlaces(
30+
@Query("version") version: Int = VERSION,
31+
@Query("searchKeyword") searchKeyword: String,
32+
@Query("centerLon") centerLon: Double,
33+
@Query("centerLat") centerLat: Double,
34+
): NetworkResult<NearPlaceResponse>
35+
2736
companion object {
2837
private const val TRANSPORT_URL = "transit/routes"
2938

3039
private const val REVERSE_GEOCODING_URL = "tmap/geo/reversegeocoding"
3140
private const val REVERSE_GEOCODING_VERSION = 1
3241
private const val REVERSE_GEOCODING_COORDINATION_TYPE = "WGS84GEO"
3342
private const val REVERSE_GEOCODING_ADDRESS_TYPE = "A02"
43+
44+
private const val PLACE_SEARCH_URL = "/tmap/pois"
45+
private const val VERSION = 1
3446
}
3547
}

data/src/main/java/com/stop/data/remote/source/nearplace/NearPlaceRemoteDataSource.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import com.stop.data.model.nearplace.Place
55
interface NearPlaceRemoteDataSource {
66

77
suspend fun getNearPlaces(
8-
version: Int,
98
searchKeyword: String,
109
centerLon: Double,
11-
centerLat: Double,
12-
appKey: String
10+
centerLat: Double
1311
): Result<List<Place>>
1412

1513
}

data/src/main/java/com/stop/data/remote/source/nearplace/NearPlaceRemoteDataSourceImpl.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,22 @@ package com.stop.data.remote.source.nearplace
22

33
import com.stop.data.model.nearplace.Place
44
import com.stop.data.remote.model.NetworkResult
5-
import com.stop.data.remote.network.NearPlaceApiService
5+
import com.stop.data.remote.network.TmapApiService
66
import javax.inject.Inject
77

88
internal class NearPlaceRemoteDataSourceImpl @Inject constructor(
9-
private val nearPlaceApiService: NearPlaceApiService
9+
private val tmapApiService: TmapApiService
1010
) : NearPlaceRemoteDataSource {
1111

1212
override suspend fun getNearPlaces(
13-
version: Int,
1413
searchKeyword: String,
1514
centerLon: Double,
16-
centerLat: Double,
17-
appKey: String
15+
centerLat: Double
1816
): Result<List<Place>> {
19-
val result = nearPlaceApiService.getNearPlaces(
20-
version,
21-
searchKeyword,
22-
centerLon,
23-
centerLat,
24-
appKey
17+
val result = tmapApiService.getNearPlaces(
18+
searchKeyword = searchKeyword,
19+
centerLon = centerLon,
20+
centerLat = centerLat
2521
)
2622
return runCatching {
2723
when (result) {

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,14 @@ internal class NearPlaceRepositoryImpl @Inject constructor(
1111
) : NearPlaceRepository {
1212

1313
override suspend fun getNearPlaces(
14-
version: Int,
1514
searchKeyword: String,
1615
centerLon: Double,
17-
centerLat: Double,
18-
appKey: String
16+
centerLat: Double
1917
): List<Place> {
2018
return nearPlaceRemoteDataSource.getNearPlaces(
21-
version,
22-
searchKeyword,
23-
centerLon,
24-
centerLat,
25-
appKey
19+
searchKeyword = searchKeyword,
20+
centerLon = centerLon,
21+
centerLat = centerLat
2622
).onSuccess { places ->
2723
return places.map {
2824
it.toUseCaseModel()
@@ -33,18 +29,14 @@ internal class NearPlaceRepositoryImpl @Inject constructor(
3329
}
3430

3531
override suspend fun getNowStationLocationInfo(
36-
version: Int,
3732
searchKeyword: String,
3833
centerLon: Double,
39-
centerLat: Double,
40-
appKey: String
34+
centerLat: Double
4135
): NowStationLocationUseCaseItem {
4236
return nearPlaceRemoteDataSource.getNearPlaces(
43-
version,
44-
searchKeyword,
45-
centerLon,
46-
centerLat,
47-
appKey
37+
searchKeyword = searchKeyword,
38+
centerLon = centerLon,
39+
centerLat = centerLat
4840
).onSuccess { places ->
4941
return places.first().toNowStationLocationUseCaseModel()
5042
}.onFailure {

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@ import com.stop.domain.model.nowlocation.NowStationLocationUseCaseItem
66
interface NearPlaceRepository {
77

88
suspend fun getNearPlaces(
9-
version: Int,
109
searchKeyword: String,
1110
centerLon: Double,
12-
centerLat: Double,
13-
appKey: String
11+
centerLat: Double
1412
): List<Place>
1513

1614
suspend fun getNowStationLocationInfo(
17-
version: Int,
1815
searchKeyword: String,
1916
centerLon: Double,
20-
centerLat: Double,
21-
appKey: String
17+
centerLat: Double
2218
): NowStationLocationUseCaseItem
2319

2420
}

domain/src/main/java/com/stop/domain/usecase/nearplace/GetNearPlacesUseCase.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import com.stop.domain.model.nearplace.Place
55
interface GetNearPlacesUseCase {
66

77
suspend fun getNearPlaces(
8-
version: Int,
98
searchKeyword: String,
109
centerLon: Double,
11-
centerLat: Double,
12-
appKey: String
10+
centerLat: Double
1311
): List<Place>
1412

1513
}

domain/src/main/java/com/stop/domain/usecase/nearplace/GetNearPlacesUseCaseImpl.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@ internal class GetNearPlacesUseCaseImpl @Inject constructor(
99
) : GetNearPlacesUseCase {
1010

1111
override suspend fun getNearPlaces(
12-
version: Int,
1312
searchKeyword: String,
1413
centerLon: Double,
1514
centerLat: Double,
16-
appKey: String
1715
): List<Place> =
1816
nearPlaceRepository.getNearPlaces(
19-
version,
2017
searchKeyword,
2118
centerLon,
22-
centerLat,
23-
appKey
19+
centerLat
2420
)
2521

2622
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import com.stop.domain.model.nowlocation.NowStationLocationUseCaseItem
55
interface GetNowStationLocationUseCase {
66

77
suspend operator fun invoke(
8-
version: Int,
98
searchKeyword: String,
109
centerLon: Double,
11-
centerLat: Double,
12-
appKey: String
10+
centerLat: Double
1311
): NowStationLocationUseCaseItem
1412

1513
}

0 commit comments

Comments
 (0)