Skip to content

Commit 6eec923

Browse files
committed
feat : 데이터 클래스 통합
1 parent 104aaa1 commit 6eec923

25 files changed

+113
-117
lines changed

data/src/main/java/com/stop/data/local/model/RecentPlaceSearchEntity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.stop.data.local.model
22

33
import androidx.room.Entity
44
import androidx.room.PrimaryKey
5-
import com.stop.data.model.alarm.RecentPlaceSearchItem
5+
import com.stop.data.model.nearplace.PlaceRepositoryItem
66

77
@Entity
88
data class RecentPlaceSearchEntity(
@@ -15,7 +15,7 @@ data class RecentPlaceSearchEntity(
1515
val centerLon: Double
1616
) {
1717

18-
fun toRepositoryModel() = RecentPlaceSearchItem(
18+
fun toRepositoryModel() = PlaceRepositoryItem(
1919
name = name,
2020
radius = radius,
2121
fullAddressRoad = fullAddressRoad,

data/src/main/java/com/stop/data/local/source/alarm/RecentPlaceSearchLocalDataSource.kt

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

3-
import com.stop.data.model.alarm.RecentPlaceSearchItem
3+
import com.stop.data.model.nearplace.PlaceRepositoryItem
44
import kotlinx.coroutines.flow.Flow
55

66
interface RecentPlaceSearchLocalDataSource {
77

8-
suspend fun insertRecentPlaceSearch(recentPlaceSearchItem: RecentPlaceSearchItem)
8+
suspend fun insertRecentPlaceSearch(placeRepositoryItem: PlaceRepositoryItem)
99

10-
fun getAllRecentPlaceSearch(): Flow<List<RecentPlaceSearchItem>>
10+
fun getAllRecentPlaceSearch(): Flow<List<PlaceRepositoryItem>>
1111

1212
suspend fun deleteAllRecentPlaceSearch()
1313

data/src/main/java/com/stop/data/local/source/alarm/RecentPlaceSearchLocalDataSourceImpl.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.stop.data.local.source.alarm
22

33
import com.stop.data.local.database.dao.RecentPlaceSearchDao
4-
import com.stop.data.model.alarm.RecentPlaceSearchItem
4+
import com.stop.data.model.nearplace.PlaceRepositoryItem
55
import kotlinx.coroutines.flow.Flow
66
import kotlinx.coroutines.flow.map
77
import javax.inject.Inject
@@ -10,14 +10,14 @@ class RecentPlaceSearchLocalDataSourceImpl @Inject constructor(
1010
private val recentPlaceSearchDao: RecentPlaceSearchDao
1111
) : RecentPlaceSearchLocalDataSource {
1212

13-
override suspend fun insertRecentPlaceSearch(recentPlaceSearchItem: RecentPlaceSearchItem) {
14-
recentPlaceSearchDao.insertRecentPlaceSearchEntity(recentPlaceSearchItem.toDataSourceModel())
13+
override suspend fun insertRecentPlaceSearch(placeRepositoryItem: PlaceRepositoryItem) {
14+
recentPlaceSearchDao.insertRecentPlaceSearchEntity(placeRepositoryItem.toDataSourceModel())
1515
}
1616

17-
override fun getAllRecentPlaceSearch(): Flow<List<RecentPlaceSearchItem>> {
18-
return recentPlaceSearchDao.getAllRecentPlaceSearchEntity().map { recentPlaceSearchEntities ->
19-
recentPlaceSearchEntities.map { recentPlaceSearchEntity ->
20-
recentPlaceSearchEntity.toRepositoryModel()
17+
override fun getAllRecentPlaceSearch(): Flow<List<PlaceRepositoryItem>> {
18+
return recentPlaceSearchDao.getAllRecentPlaceSearchEntity().map { placeEntities ->
19+
placeEntities.map { placeEntity ->
20+
placeEntity.toRepositoryModel()
2121
}
2222
}
2323
}

data/src/main/java/com/stop/data/model/alarm/RecentPlaceSearchItem.kt

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

data/src/main/java/com/stop/data/model/nearplace/Place.kt renamed to data/src/main/java/com/stop/data/model/nearplace/PlaceRepositoryItem.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
package com.stop.data.model.nearplace
22

3-
import com.stop.domain.model.nearplace.Place
3+
import com.stop.data.local.model.RecentPlaceSearchEntity
4+
import com.stop.domain.model.nearplace.PlaceUseCaseItem
45
import com.stop.domain.model.nowlocation.NowStationLocationUseCaseItem
56

6-
data class Place(
7+
data class PlaceRepositoryItem(
78
val name: String,
89
val radius: String,
910
val fullAddressRoad: String,
1011
val centerLat: Double,
1112
val centerLon: Double
1213
) {
1314

14-
fun toUseCaseModel() = Place(
15+
fun toUseCaseModel() = PlaceUseCaseItem(
1516
name = name,
1617
radius = radius,
1718
fullAddressRoad = fullAddressRoad,
1819
centerLat = centerLat,
1920
centerLon = centerLon
2021
)
2122

23+
fun toDataSourceModel() = RecentPlaceSearchEntity(
24+
name = name,
25+
radius = radius,
26+
fullAddressRoad = fullAddressRoad,
27+
centerLat = centerLat,
28+
centerLon = centerLon,
29+
)
30+
2231
fun toNowStationLocationUseCaseModel() = NowStationLocationUseCaseItem(
2332
name = name,
2433
latitude = centerLat.toString(),

data/src/main/java/com/stop/data/remote/model/nearplace/Poi.kt

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

33
import com.squareup.moshi.JsonClass
4-
import com.stop.data.model.nearplace.Place
4+
import com.stop.data.model.nearplace.PlaceRepositoryItem
55

66
@JsonClass(generateAdapter = true)
77
data class Poi(
@@ -41,9 +41,9 @@ data class Poi(
4141
val zipCode: String
4242
) {
4343

44-
fun toRepositoryModel(): Place {
44+
fun toRepositoryModel(): PlaceRepositoryItem {
4545
val road = newAddressList.newAddress.firstOrNull()
46-
return Place(
46+
return PlaceRepositoryItem(
4747
name = name,
4848
radius = radius,
4949
fullAddressRoad = road?.fullAddressRoad ?: "",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.stop.data.remote.source.nearplace
22

3-
import com.stop.data.model.nearplace.Place
3+
import com.stop.data.model.nearplace.PlaceRepositoryItem
44

55
interface NearPlaceRemoteDataSource {
66

77
suspend fun getNearPlaces(
88
searchKeyword: String,
99
centerLon: Double,
1010
centerLat: Double
11-
): Result<List<Place>>
11+
): Result<List<PlaceRepositoryItem>>
1212

1313
}

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

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

3-
import com.stop.data.model.nearplace.Place
3+
import com.stop.data.model.nearplace.PlaceRepositoryItem
44
import com.stop.data.remote.model.NetworkResult
55
import com.stop.data.remote.network.TmapApiService
66
import javax.inject.Inject
@@ -13,7 +13,7 @@ internal class NearPlaceRemoteDataSourceImpl @Inject constructor(
1313
searchKeyword: String,
1414
centerLon: Double,
1515
centerLat: Double
16-
): Result<List<Place>> {
16+
): Result<List<PlaceRepositoryItem>> {
1717
val result = tmapApiService.getNearPlaces(
1818
searchKeyword = searchKeyword,
1919
centerLon = centerLon,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.stop.data.repository
22

33
import com.stop.data.remote.source.nearplace.NearPlaceRemoteDataSource
4-
import com.stop.domain.model.nearplace.Place
4+
import com.stop.domain.model.nearplace.PlaceUseCaseItem
55
import com.stop.domain.model.nowlocation.NowStationLocationUseCaseItem
66
import com.stop.domain.repository.NearPlaceRepository
77
import javax.inject.Inject
@@ -14,7 +14,7 @@ internal class NearPlaceRepositoryImpl @Inject constructor(
1414
searchKeyword: String,
1515
centerLon: Double,
1616
centerLat: Double
17-
): List<Place> {
17+
): List<PlaceUseCaseItem> {
1818
return nearPlaceRemoteDataSource.getNearPlaces(
1919
searchKeyword = searchKeyword,
2020
centerLon = centerLon,
@@ -25,7 +25,7 @@ internal class NearPlaceRepositoryImpl @Inject constructor(
2525
}
2626
}.onFailure {
2727
throw it
28-
}.getOrDefault(emptyList()) as List<Place>
28+
}.getOrDefault(emptyList()) as List<PlaceUseCaseItem>
2929
}
3030

3131
override suspend fun getNowStationLocationInfo(

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

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

33
import com.stop.data.local.source.alarm.RecentPlaceSearchLocalDataSource
4-
import com.stop.data.model.alarm.RecentPlaceSearchItem
5-
import com.stop.domain.model.nearplace.RecentPlaceSearch
4+
import com.stop.data.model.nearplace.PlaceRepositoryItem
5+
import com.stop.domain.model.nearplace.PlaceUseCaseItem
66
import com.stop.domain.repository.RecentPlaceSearchRepository
77
import kotlinx.coroutines.flow.Flow
88
import kotlinx.coroutines.flow.map
@@ -12,22 +12,22 @@ class RecentPlaceSearchRepositoryImpl @Inject constructor(
1212
private val recentPlaceSearchLocalDataSource: RecentPlaceSearchLocalDataSource
1313
) : RecentPlaceSearchRepository {
1414

15-
override suspend fun insertRecentPlaceSearch(recentPlaceSearch: RecentPlaceSearch) {
15+
override suspend fun insertRecentPlaceSearch(placeUseCaseItem: PlaceUseCaseItem) {
1616
recentPlaceSearchLocalDataSource.insertRecentPlaceSearch(
17-
RecentPlaceSearchItem(
18-
name = recentPlaceSearch.name,
19-
radius = recentPlaceSearch.radius,
20-
fullAddressRoad = recentPlaceSearch.fullAddressRoad,
21-
centerLat = recentPlaceSearch.centerLat,
22-
centerLon = recentPlaceSearch.centerLon,
17+
PlaceRepositoryItem(
18+
name = placeUseCaseItem.name,
19+
radius = placeUseCaseItem.radius,
20+
fullAddressRoad = placeUseCaseItem.fullAddressRoad,
21+
centerLat = placeUseCaseItem.centerLat,
22+
centerLon = placeUseCaseItem.centerLon,
2323
)
2424
)
2525
}
2626

27-
override fun getAllRecentPlaceSearch(): Flow<List<RecentPlaceSearch>> {
28-
return recentPlaceSearchLocalDataSource.getAllRecentPlaceSearch().map { recentPlaceSearchItems ->
29-
recentPlaceSearchItems.map { recentPlaceSearchItem ->
30-
recentPlaceSearchItem.toUseCaseModel()
27+
override fun getAllRecentPlaceSearch(): Flow<List<PlaceUseCaseItem>> {
28+
return recentPlaceSearchLocalDataSource.getAllRecentPlaceSearch().map { placeRepositoryItems ->
29+
placeRepositoryItems.map { placeRepositoryItem ->
30+
placeRepositoryItem.toUseCaseModel()
3131
}
3232
}
3333
}

0 commit comments

Comments
 (0)