Skip to content

Commit

Permalink
[feat/review_api]: Merge Error 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
kez-lab committed Feb 4, 2024
1 parent 9651d1e commit ac87aca
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.everymeal.data.model.restaruant

import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.GetUnivRestaurantEntity
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import com.everymeal.domain.model.restaurant.Restaurant
import kotlinx.serialization.Serializable

@Serializable
Expand Down Expand Up @@ -52,7 +51,7 @@ data class Sort(
val unsorted: Boolean,
)

fun RestaurantResponse.toEntity(): Restaurant {
fun RestaurantResponse.toRestaurant(): Restaurant {
return Restaurant(
idx = this.idx,
name = this.name,
Expand All @@ -68,8 +67,9 @@ fun RestaurantResponse.toEntity(): Restaurant {
)
}

fun GetUnivRestaurantResponse.toEntity(): GetUnivRestaurantEntity {

fun GetUnivRestaurantResponse.toGetUnivRestaurantEntity(): GetUnivRestaurantEntity {
return GetUnivRestaurantEntity(
data = this.content.map { it.toEntity() }
data = this.content.map { it.toRestaurant() }
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package com.everymeal.data.repository.restaurant
import androidx.paging.PagingData
import androidx.paging.map
import com.everymeal.data.datasource.restaurant.RestaurantDataSource
import com.everymeal.data.model.restaruant.toEntity
import com.everymeal.data.model.restaruant.toGetUnivRestaurantEntity
import com.everymeal.data.model.restaruant.toRestaurant
import com.everymeal.domain.model.restaurant.GetUnivRestaurantEntity
import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.repository.restaurant.RestaurantRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import androidx.paging.map
import com.everymeal.data.model.restaruant.toEntity
import com.everymeal.domain.model.restaurant.GetUnivRestaurantEntity
import javax.inject.Inject

class RestaurantRepositoryImpl @Inject constructor(
Expand All @@ -24,12 +23,12 @@ class RestaurantRepositoryImpl @Inject constructor(
): Flow<PagingData<Restaurant>> {
return restaurantDataSource.getUnivRestaurant(campusIdx, order, group, grade)
.map { pagingData ->
pagingData.map { it.toEntity() }
pagingData.map { it.toRestaurant() }
}
}

override suspend fun getRestaurantDetail(index: Int): Result<Restaurant> {
return restaurantDataSource.getRestaurantDetail(index).map { it.toEntity() }
return restaurantDataSource.getRestaurantDetail(index).map { it.toRestaurant() }
}

override suspend fun getHomeRestaurant(
Expand All @@ -38,6 +37,7 @@ class RestaurantRepositoryImpl @Inject constructor(
group: String?,
grade: String?
): Result<GetUnivRestaurantEntity> {
return restaurantDataSource.getHomeRestaurant(campusIdx, order, group, grade).map { it.toEntity() }
return restaurantDataSource.getHomeRestaurant(campusIdx, order, group, grade)
.map { it.toGetUnivRestaurantEntity() }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.everymeal.domain.model.restaurant

data class GetUnivRestaurantEntity(
val data: List<Restaurant>
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ interface RestaurantRepository {
suspend fun getRestaurantDetail(
index: Int
): Result<Restaurant>
) : Result<RestaurantDataEntity>

suspend fun getHomeRestaurant(
campusIdx: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.everymeal.presentation.ui.home

import com.everymeal.domain.model.restaurant.GetUnivRestaurantEntity
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.presentation.base.LoadState
import com.everymeal.presentation.base.ViewEvent
import com.everymeal.presentation.base.ViewSideEffect
Expand All @@ -12,7 +11,7 @@ class HomeContract {
val uiState: LoadState = LoadState.LOADING,
val detailListScreenType: DetailListScreenType = DetailListScreenType.RECOMMEND,
val bottomSheetState: Boolean = false,
val restaurantData: List<RestaurantDataEntity> = emptyList()
val restaurantData: List<Restaurant> = emptyList()
) : ViewState

sealed class HomeEvent : ViewEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ fun DetailRestaurantScreen(
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun DetailRestaurantImage(
restaurantInfo : RestaurantDataEntity
restaurantInfo : Restaurant
) {
val images = restaurantInfo.images ?: listOf()

Expand Down Expand Up @@ -538,7 +538,7 @@ fun DetailRestaurantTabInfo(

@Composable
fun DetailRestaurantTabImage(
restaurantInfo : RestaurantDataEntity
restaurantInfo : Restaurant
) {
Column {
restaurantInfo.images?.let { images ->
Expand Down

0 comments on commit ac87aca

Please sign in to comment.