Skip to content

Commit

Permalink
[feat/review_api]: Data class Name 변경 롤백
Browse files Browse the repository at this point in the history
  • Loading branch information
kez-lab committed Feb 4, 2024
1 parent ac87aca commit 8569431
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.everymeal.data.model.restaruant

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

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

fun RestaurantResponse.toRestaurant(): Restaurant {
return Restaurant(
fun RestaurantResponse.toRestaurant(): RestaurantDataEntity {
return RestaurantDataEntity(
idx = this.idx,
name = this.name,
address = this.address,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.everymeal.data.model.restaruant

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

Expand Down Expand Up @@ -103,10 +103,10 @@ data class SearchRestaurantResponse(
}


fun SearchRestaurantResponse.toRestaurants(): List<Restaurant> {
fun SearchRestaurantResponse.toRestaurants(): List<RestaurantDataEntity> {
return this.data?.content?.mapNotNull { content ->
content?.let {
Restaurant(
RestaurantDataEntity(
idx = it.idx ?: 0,
name = it.name.orEmpty(),
address = it.address.orEmpty(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.everymeal.data.datasource.restaurant.RestaurantDataSource
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.model.restaurant.RestaurantDataEntity
import com.everymeal.domain.repository.restaurant.RestaurantRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
Expand All @@ -20,14 +20,14 @@ class RestaurantRepositoryImpl @Inject constructor(
order: String,
group: String?,
grade: String?
): Flow<PagingData<Restaurant>> {
): Flow<PagingData<RestaurantDataEntity>> {
return restaurantDataSource.getUnivRestaurant(campusIdx, order, group, grade)
.map { pagingData ->
pagingData.map { it.toRestaurant() }
}
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package com.everymeal.data.repository.search

import com.everymeal.data.model.restaruant.toRestaurants
import com.everymeal.data.service.search.SearchService
import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import com.everymeal.domain.repository.search.SearchRepository
import javax.inject.Inject

class DefaultSearchRepository @Inject constructor(
private val searchService: SearchService,
) : SearchRepository {
override suspend fun search(keyword: String): Result<List<Restaurant>> {
override suspend fun search(keyword: String): Result<List<RestaurantDataEntity>> {
return runCatching {
searchService.search(keyword).toRestaurants()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.everymeal.domain.model.restaurant

data class GetUnivRestaurantEntity(
val data: List<Restaurant>
val data: List<RestaurantDataEntity>
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.everymeal.domain.model.restaurant

data class Restaurant(
data class RestaurantDataEntity(
val idx: Int,
val name: String,
val address: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.everymeal.domain.repository.restaurant

import androidx.paging.PagingData
import com.everymeal.domain.model.restaurant.GetUnivRestaurantEntity
import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import kotlinx.coroutines.flow.Flow

interface RestaurantRepository {
Expand All @@ -12,11 +12,11 @@ interface RestaurantRepository {
order: String,
group: String? = null,
grade: String? = null,
): Flow<PagingData<Restaurant>>
): Flow<PagingData<RestaurantDataEntity>>

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,7 @@
package com.everymeal.domain.repository.search

import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.RestaurantDataEntity

interface SearchRepository {
suspend fun search(keyword: String): Result<List<Restaurant>>
suspend fun search(keyword: String): Result<List<RestaurantDataEntity>>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.everymeal.domain.usecase.restaurant

import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import com.everymeal.domain.repository.restaurant.RestaurantRepository
import javax.inject.Inject

Expand All @@ -9,7 +9,7 @@ class GetDetailRestaurantUseCase @Inject constructor(
) {
suspend operator fun invoke(
restaurantIdx: Int,
): Result<Restaurant> {
): Result<RestaurantDataEntity> {
return restaurantRepository.getRestaurantDetail(restaurantIdx)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.everymeal.domain.usecase.restaurant

import androidx.paging.PagingData
import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import com.everymeal.domain.repository.restaurant.RestaurantRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
Expand All @@ -14,7 +14,7 @@ class GetUnivRestaurantUseCase @Inject constructor(
order: String,
group: String?,
grade: String?
) : Flow<PagingData<Restaurant>> {
) : Flow<PagingData<RestaurantDataEntity>> {
return restaurantRepository.getUnivRestaurant(campusIdx, order, group, grade)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand All @@ -31,7 +30,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import com.everymeal.presentation.R
import com.everymeal.presentation.ui.theme.EveryMeal_AndroidTheme
import com.everymeal.presentation.ui.theme.Gray300
Expand All @@ -41,7 +40,7 @@ import com.everymeal.presentation.ui.theme.Gray700

@Composable
fun EveryMealRestaurantItem(
restaurant: Restaurant,
restaurant: RestaurantDataEntity,
onLoveClick: () -> Unit = {},
onDetailClick: (Int) -> Unit = {},
) {
Expand Down Expand Up @@ -69,7 +68,7 @@ fun EveryMealRestaurantItem(
@Composable
fun RestaurantTitle(
modifier: Modifier = Modifier,
restaurant: Restaurant,
restaurant: RestaurantDataEntity,
onLoveClick: () -> Unit,
) {
Row(
Expand Down Expand Up @@ -101,7 +100,7 @@ fun RestaurantTitle(

@Composable
fun RestaurantLoveCount(
restaurant: Restaurant,
restaurant: RestaurantDataEntity,
onLoveClick: () -> Unit,
) {
Column(
Expand All @@ -128,7 +127,7 @@ fun RestaurantLoveCount(
}

@Composable
fun RestaurantRating(restaurant: Restaurant) {
fun RestaurantRating(restaurant: RestaurantDataEntity) {
Row(
modifier = Modifier
.width(100.dp),
Expand Down Expand Up @@ -157,7 +156,7 @@ fun RestaurantRating(restaurant: Restaurant) {
}

@Composable
fun RestaurantImage(restaurant: Restaurant) {
fun RestaurantImage(restaurant: RestaurantDataEntity) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(6.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import com.everymeal.presentation.R
import com.everymeal.presentation.components.EveryMealCategoryRatingBottomSheetDialog
import com.everymeal.presentation.components.EveryMealDetailReportBottomSheetDialog
import com.everymeal.presentation.components.EveryMealReportBottomSheetDialog
import com.everymeal.presentation.components.EveryMealRestaurantItem
import com.everymeal.presentation.components.EveryMealSortCategoryBottomSheetDialog
import com.everymeal.presentation.ui.save.SaveTopBar
import com.everymeal.presentation.ui.signup.UnivSelectContract
import com.everymeal.presentation.ui.theme.Grey2
import com.everymeal.presentation.ui.theme.Grey7
import com.everymeal.presentation.ui.theme.Main100
Expand All @@ -53,7 +52,7 @@ fun DetailListScreen(
) {
val detailListViewState by detailListViewModel.viewState.collectAsState()

val pagingRestaurantList: LazyPagingItems<Restaurant> =
val pagingRestaurantList: LazyPagingItems<RestaurantDataEntity> =
detailListViewModel.restaurantItems.collectAsLazyPagingItems()

LaunchedEffect(Unit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package com.everymeal.presentation.ui.detail
import androidx.lifecycle.viewModelScope
import androidx.paging.PagingData
import androidx.paging.cachedIn
import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import com.everymeal.domain.usecase.local.GetUniversityIndexUseCase
import com.everymeal.domain.usecase.restaurant.GetUnivRestaurantUseCase
import com.everymeal.presentation.base.BaseViewModel
import com.everymeal.presentation.ui.detail.DetailContract.DetailEvent
import com.everymeal.presentation.ui.detail.DetailContract.DetailState
import com.everymeal.presentation.ui.detail.DetailContract.DetailEffect
import com.everymeal.presentation.ui.signup.UnivSelectContract
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
Expand All @@ -26,8 +25,8 @@ class DetailListViewModel @Inject constructor(
): BaseViewModel<DetailState, DetailEffect, DetailEvent>(
DetailState()
) {
private val _restaurantItems : MutableStateFlow<PagingData<Restaurant>> = MutableStateFlow(value = PagingData.empty())
val restaurantItems : StateFlow<PagingData<Restaurant>> = _restaurantItems.asStateFlow()
private val _restaurantItems : MutableStateFlow<PagingData<RestaurantDataEntity>> = MutableStateFlow(value = PagingData.empty())
val restaurantItems : StateFlow<PagingData<RestaurantDataEntity>> = _restaurantItems.asStateFlow()

override fun handleEvents(event: DetailEvent) {
when (event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.everymeal.presentation.ui.home

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

sealed class HomeEvent : ViewEvent {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.everymeal.presentation.ui.restaurant

import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import com.everymeal.presentation.base.LoadState
import com.everymeal.presentation.base.ViewEvent
import com.everymeal.presentation.base.ViewSideEffect
Expand All @@ -12,7 +12,7 @@ data class DetailRestaurantState(
val selectedTabIndex: Int = 0,
val isFabClicked: Boolean = false,
val getDetailRestaurantState: LoadState = LoadState.LOADING,
val restaurantInfo: Restaurant = Restaurant(
val restaurantInfo: RestaurantDataEntity = RestaurantDataEntity(
idx = 0,
name = "",
address = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,15 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import coil.compose.AsyncImage
import coil.compose.rememberImagePainter
import com.everymeal.presentation.R
import com.everymeal.presentation.base.LoadState
import com.everymeal.presentation.components.EveryMealDialog
Expand Down Expand Up @@ -252,7 +250,7 @@ fun DetailRestaurantScreen(
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun DetailRestaurantImage(
restaurantInfo : Restaurant
restaurantInfo : RestaurantDataEntity
) {
val images = restaurantInfo.images ?: listOf()

Expand Down Expand Up @@ -296,7 +294,7 @@ fun DetailRestaurantImage(

@Composable
fun DetailRestaurantMainInfo(
restaurantInfo: Restaurant
restaurantInfo: RestaurantDataEntity
) {
Column(
modifier = Modifier
Expand Down Expand Up @@ -409,7 +407,7 @@ fun DetailRestaurantMainInfo(
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun DetailRestaurantTabLayout(
restaurantInfo: Restaurant,
restaurantInfo: RestaurantDataEntity,
viewModel: DetailRestaurantViewModel
) {
val viewState by viewModel.viewState.collectAsState()
Expand Down Expand Up @@ -476,7 +474,7 @@ fun DetailRestaurantTabLayout(

@Composable
fun DetailRestaurantTabInfo(
restaurantInfo: Restaurant,
restaurantInfo: RestaurantDataEntity,
modifier: Modifier = Modifier,
) {
Column(
Expand Down Expand Up @@ -538,7 +536,7 @@ fun DetailRestaurantTabInfo(

@Composable
fun DetailRestaurantTabImage(
restaurantInfo : Restaurant
restaurantInfo : RestaurantDataEntity
) {
Column {
restaurantInfo.images?.let { images ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.everymeal.presentation.ui.restaurant

import androidx.lifecycle.viewModelScope
import com.everymeal.domain.model.restaurant.Restaurant
import com.everymeal.domain.model.restaurant.RestaurantDataEntity
import com.everymeal.domain.usecase.restaurant.GetDetailRestaurantUseCase
import com.everymeal.presentation.base.BaseViewModel
import com.everymeal.presentation.base.LoadState
Expand Down Expand Up @@ -56,7 +56,7 @@ class DetailRestaurantViewModel @Inject constructor(
private fun reflectUpdateState(
selectedTabIndex: Int = viewState.value.selectedTabIndex,
isFabClicked: Boolean = viewState.value.isFabClicked,
restaurantInfo: Restaurant = viewState.value.restaurantInfo,
restaurantInfo: RestaurantDataEntity = viewState.value.restaurantInfo,
getDetailRestaurantState: LoadState = viewState.value.getDetailRestaurantState,
networkErrorDialog: Boolean = viewState.value.networkErrorDialog
) {
Expand Down
Loading

0 comments on commit 8569431

Please sign in to comment.