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 b2c1ce7 commit dd09138
Show file tree
Hide file tree
Showing 18 changed files with 89 additions and 91 deletions.
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.Serializable

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

fun RestaurantResponse.toEntity(): Restaurant {
return Restaurant(
fun RestaurantResponse.toEntity(): 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 @@ -4,7 +4,7 @@ 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.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 @@ -18,14 +18,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.toEntity() }
}
}

override suspend fun getRestaurantDetail(index: Int): Result<Restaurant> {
override suspend fun getRestaurantDetail(index: Int): Result<RestaurantDataEntity> {
return restaurantDataSource.getRestaurantDetail(index).map { it.toEntity() }
}
}
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,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
@@ -1,7 +1,7 @@
package com.everymeal.domain.repository.restaurant

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

interface RestaurantRepository {
Expand All @@ -11,9 +11,9 @@ 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>
}
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 @@ -30,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 @@ -40,7 +40,7 @@ import com.everymeal.presentation.ui.theme.Gray700

@Composable
fun EveryMealRestaurantItem(
restaurant: Restaurant,
restaurantDataEntity: RestaurantDataEntity,
onLoveClick: () -> Unit = {},
onDetailClick: (Int) -> Unit = {},
) {
Expand All @@ -51,32 +51,32 @@ fun EveryMealRestaurantItem(
indication = null,
interactionSource = remember { MutableInteractionSource() },
) {
onDetailClick(restaurant.idx)
onDetailClick(restaurantDataEntity.idx)
}
.padding(horizontal = 20.dp)
.background(color = Color.White),
) {
RestaurantTitle(Modifier.fillMaxWidth(), restaurant) {
RestaurantTitle(Modifier.fillMaxWidth(), restaurantDataEntity) {
onLoveClick()
}
RestaurantRating(restaurant)
RestaurantRating(restaurantDataEntity)
Spacer(modifier = Modifier.padding(4.dp))
RestaurantImage(restaurant)
RestaurantImage(restaurantDataEntity)
}
}

@Composable
fun RestaurantTitle(
modifier: Modifier = Modifier,
restaurant: Restaurant,
restaurantDataEntity: RestaurantDataEntity,
onLoveClick: () -> Unit,
) {
Row(
modifier = modifier,
) {
Text(
modifier = Modifier.padding(top = 6.dp),
text = restaurant.name,
text = restaurantDataEntity.name,
color = Color.Black,
fontSize = 17.sp,
fontWeight = FontWeight.SemiBold,
Expand All @@ -88,18 +88,18 @@ fun RestaurantTitle(
.clip(RoundedCornerShape(4.dp))
.background(color = Gray300)
.padding(vertical = 3.dp, horizontal = 6.dp),
text = restaurant.categoryDetail,
text = restaurantDataEntity.categoryDetail,
color = Gray600,
fontSize = 12.sp,
)
Spacer(modifier = Modifier.weight(1f))
RestaurantLoveCount(restaurant, onLoveClick)
RestaurantLoveCount(restaurantDataEntity, onLoveClick)
}
}

@Composable
fun RestaurantLoveCount(
restaurant: Restaurant,
restaurantDataEntity: RestaurantDataEntity,
onLoveClick: () -> Unit,
) {
Column(
Expand All @@ -115,7 +115,7 @@ fun RestaurantLoveCount(
contentDescription = stringResource(R.string.icon_star),
)
Text(
text = "${restaurant.recommendedCount}",
text = "${restaurantDataEntity.recommendedCount}",
color = Gray500,
fontSize = 12.sp,
fontWeight = FontWeight.Medium,
Expand All @@ -124,7 +124,7 @@ fun RestaurantLoveCount(
}

@Composable
fun RestaurantRating(restaurant: Restaurant) {
fun RestaurantRating(restaurantDataEntity: RestaurantDataEntity) {
Row(
modifier = Modifier
.width(100.dp),
Expand All @@ -136,14 +136,14 @@ fun RestaurantRating(restaurant: Restaurant) {
)
Text(
modifier = Modifier.padding(start = 2.dp),
text = restaurant.grade.toString(),
text = restaurantDataEntity.grade.toString(),
color = Gray700,
fontSize = 12.sp,
fontWeight = FontWeight.Medium,
)
Text(
modifier = Modifier.padding(start = 2.dp),
text = "(${restaurant.reviewCount})",
text = "(${restaurantDataEntity.reviewCount})",
color = Gray700,
fontSize = 12.sp,
fontWeight = FontWeight.Medium,
Expand All @@ -153,15 +153,15 @@ fun RestaurantRating(restaurant: Restaurant) {
}

@Composable
fun RestaurantImage(restaurant: Restaurant) {
fun RestaurantImage(restaurantDataEntity: RestaurantDataEntity) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
) {
restaurant.images?.let {
restaurantDataEntity.images?.let {
when {
restaurant.images?.size == 3 -> {
restaurant.images?.forEachIndexed { index, image ->
restaurantDataEntity.images?.size == 3 -> {
restaurantDataEntity.images?.forEachIndexed { index, image ->
AsyncImage(
modifier = Modifier
.weight(1f)
Expand All @@ -176,8 +176,8 @@ fun RestaurantImage(restaurant: Restaurant) {
}
}

restaurant.images?.size == 2 -> {
restaurant.images?.forEachIndexed { index, image ->
restaurantDataEntity.images?.size == 2 -> {
restaurantDataEntity.images?.forEachIndexed { index, image ->
AsyncImage(
modifier = Modifier
.weight(1f)
Expand All @@ -193,13 +193,13 @@ fun RestaurantImage(restaurant: Restaurant) {
Spacer(modifier = Modifier.weight(1f))
}

restaurant.images?.size == 1 -> {
restaurantDataEntity.images?.size == 1 -> {
AsyncImage(
modifier = Modifier
.weight(1f)
.aspectRatio(1f)
.clip(RoundedCornerShape(8.dp)),
model = restaurant.images!![0],
model = restaurantDataEntity.images!![0],
contentDescription = null,
)
Spacer(
Expand All @@ -209,13 +209,13 @@ fun RestaurantImage(restaurant: Restaurant) {
)
}

restaurant.images?.size!! > 3 -> {
restaurantDataEntity.images?.size!! > 3 -> {
AsyncImage(
modifier = Modifier
.weight(1f)
.aspectRatio(1f)
.clip(RoundedCornerShape(8.dp)),
model = restaurant.images!![0],
model = restaurantDataEntity.images!![0],
contentDescription = null,
)
Spacer(modifier = Modifier.padding(end = 6.dp))
Expand All @@ -224,7 +224,7 @@ fun RestaurantImage(restaurant: Restaurant) {
.weight(1f)
.aspectRatio(1f)
.clip(RoundedCornerShape(8.dp)),
model = restaurant.images!![0],
model = restaurantDataEntity.images!![0],
contentDescription = null,
)
Spacer(modifier = Modifier.padding(end = 6.dp))
Expand All @@ -237,7 +237,7 @@ fun RestaurantImage(restaurant: Restaurant) {
modifier = Modifier
.aspectRatio(1f)
.fillMaxSize(),
model = restaurant.images!![0],
model = restaurantDataEntity.images!![0],
contentDescription = null,
)
Box(
Expand All @@ -248,7 +248,7 @@ fun RestaurantImage(restaurant: Restaurant) {
contentAlignment = Alignment.Center,
) {
Text(
text = "+${restaurant.reviewCount - 2}",
text = "+${restaurantDataEntity.reviewCount - 2}",
color = Color.White,
fontSize = 14.sp,
)
Expand Down
Loading

0 comments on commit dd09138

Please sign in to comment.