diff --git a/app/src/main/java/com/myongsik/myongsikandroid/data/model/kakao/Restaurant.kt b/app/src/main/java/com/myongsik/myongsikandroid/data/model/kakao/Restaurant.kt index d89548c2..ef167381 100644 --- a/app/src/main/java/com/myongsik/myongsikandroid/data/model/kakao/Restaurant.kt +++ b/app/src/main/java/com/myongsik/myongsikandroid/data/model/kakao/Restaurant.kt @@ -4,7 +4,7 @@ package com.myongsik.myongsikandroid.data.model.kakao import android.os.Parcelable import androidx.room.Entity import androidx.room.PrimaryKey -import com.myongsik.myongsikandroid.domain.model.love.InsertFoodEntity +import com.myongsik.myongsikandroid.domain.model.restaurant.InsertRestaurantEntity import com.squareup.moshi.Json import com.squareup.moshi.JsonClass import kotlinx.parcelize.Parcelize @@ -40,32 +40,32 @@ data class Restaurant( val y: String ) : Parcelable -fun InsertFoodEntity.toInsertFoodData() = Restaurant( - address_name = this.address_name, - category_group_code = this.category_group_code, - category_group_name = this.category_group_name, - category_name = this.category_name, +fun InsertRestaurantEntity.toInsertFoodData() = Restaurant( + address_name = this.addressName, + category_group_code = this.categoryGroupCode, + category_group_name = this.categoryGroupName, + category_name = this.categoryName, distance = this.distance, id = this.id, phone = this.phone, - place_name = this.place_name, - place_url = this.place_url, - road_address_name = this.road_address_name, + place_name = this.placeName, + place_url = this.placeUrl, + road_address_name = this.roadAddressName, x = this.x, y = this.y ) -fun Restaurant.toInsertFoodEntity() = InsertFoodEntity( - address_name = this.address_name, - category_group_code = this.category_group_code, - category_group_name = this.category_group_name, - category_name = this.category_name, +fun Restaurant.toInsertFoodEntity() = InsertRestaurantEntity( + addressName = this.address_name, + categoryGroupCode = this.category_group_code, + categoryGroupName = this.category_group_name, + categoryName = this.category_name, distance = this.distance, id = this.id, phone = this.phone, - place_name = this.place_name, - place_url = this.place_url, - road_address_name = this.road_address_name, + placeName = this.place_name, + placeUrl = this.place_url, + roadAddressName = this.road_address_name, x = this.x, y = this.y ) \ No newline at end of file diff --git a/app/src/main/java/com/myongsik/myongsikandroid/data/repository/love/LoveRepository.kt b/app/src/main/java/com/myongsik/myongsikandroid/data/repository/love/LoveRepository.kt deleted file mode 100644 index 1c6f3f7e..00000000 --- a/app/src/main/java/com/myongsik/myongsikandroid/data/repository/love/LoveRepository.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.myongsik.myongsikandroid.data.repository.love - -import com.myongsik.myongsikandroid.domain.model.love.InsertFoodEntity - -interface LoveRepository { - - suspend fun insertFood(insertFoodEntity: InsertFoodEntity) -} \ No newline at end of file diff --git a/app/src/main/java/com/myongsik/myongsikandroid/data/repository/love/LoveRepositoryImpl.kt b/app/src/main/java/com/myongsik/myongsikandroid/data/repository/love/LoveRepositoryImpl.kt deleted file mode 100644 index e2395c3a..00000000 --- a/app/src/main/java/com/myongsik/myongsikandroid/data/repository/love/LoveRepositoryImpl.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.myongsik.myongsikandroid.data.repository.love - -import com.myongsik.myongsikandroid.data.db.RestaurantDatabase -import com.myongsik.myongsikandroid.data.model.kakao.toInsertFoodData -import com.myongsik.myongsikandroid.domain.model.love.InsertFoodEntity -import javax.inject.Inject - -class LoveRepositoryImpl @Inject constructor( - private val loveDb : RestaurantDatabase -) : LoveRepository { - - override suspend fun insertFood(insertFoodEntity: InsertFoodEntity) { - loveDb.restaurantDao().insertGoodFood(insertFoodEntity.toInsertFoodData()) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/myongsik/myongsikandroid/data/repository/restaurant/RestaurantRepository.kt b/app/src/main/java/com/myongsik/myongsikandroid/data/repository/restaurant/RestaurantRepository.kt new file mode 100644 index 00000000..bf1acaa7 --- /dev/null +++ b/app/src/main/java/com/myongsik/myongsikandroid/data/repository/restaurant/RestaurantRepository.kt @@ -0,0 +1,8 @@ +package com.myongsik.myongsikandroid.data.repository.restaurant + +import com.myongsik.myongsikandroid.domain.model.restaurant.InsertRestaurantEntity + +interface RestaurantRepository { + + suspend fun insertRestaurant(insertRestaurantEntity: InsertRestaurantEntity) +} \ No newline at end of file diff --git a/app/src/main/java/com/myongsik/myongsikandroid/data/repository/restaurant/RestaurantRepositoryImpl.kt b/app/src/main/java/com/myongsik/myongsikandroid/data/repository/restaurant/RestaurantRepositoryImpl.kt new file mode 100644 index 00000000..805f8a74 --- /dev/null +++ b/app/src/main/java/com/myongsik/myongsikandroid/data/repository/restaurant/RestaurantRepositoryImpl.kt @@ -0,0 +1,15 @@ +package com.myongsik.myongsikandroid.data.repository.restaurant + +import com.myongsik.myongsikandroid.data.db.RestaurantDatabase +import com.myongsik.myongsikandroid.data.model.kakao.toInsertFoodData +import com.myongsik.myongsikandroid.domain.model.restaurant.InsertRestaurantEntity +import javax.inject.Inject + +class RestaurantRepositoryImpl @Inject constructor( + private val loveDb : RestaurantDatabase +) : RestaurantRepository { + + override suspend fun insertRestaurant(insertRestaurantEntity: InsertRestaurantEntity) { + loveDb.restaurantDao().insertGoodFood(insertRestaurantEntity.toInsertFoodData()) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/myongsik/myongsikandroid/di/RepositoryModule.kt b/app/src/main/java/com/myongsik/myongsikandroid/di/RepositoryModule.kt index 4ab70222..6e1414f2 100644 --- a/app/src/main/java/com/myongsik/myongsikandroid/di/RepositoryModule.kt +++ b/app/src/main/java/com/myongsik/myongsikandroid/di/RepositoryModule.kt @@ -2,8 +2,8 @@ package com.myongsik.myongsikandroid.di import com.myongsik.myongsikandroid.data.repository.food.FoodRepository import com.myongsik.myongsikandroid.data.repository.food.FoodRepositoryImpl -import com.myongsik.myongsikandroid.data.repository.love.LoveRepository -import com.myongsik.myongsikandroid.data.repository.love.LoveRepositoryImpl +import com.myongsik.myongsikandroid.data.repository.restaurant.RestaurantRepository +import com.myongsik.myongsikandroid.data.repository.restaurant.RestaurantRepositoryImpl import com.myongsik.myongsikandroid.data.repository.search.SearchFoodRepository import com.myongsik.myongsikandroid.data.repository.search.SearchFoodRepositoryImpl import com.myongsik.myongsikandroid.data.repository.user.UserRepository @@ -39,6 +39,6 @@ abstract class RepositoryModule { @Singleton @Binds abstract fun bindLoveRepository( - loveRepositoryImpl: LoveRepositoryImpl - ): LoveRepository + restaurantRepositoryImpl: RestaurantRepositoryImpl + ): RestaurantRepository } \ No newline at end of file diff --git a/app/src/main/java/com/myongsik/myongsikandroid/domain/model/love/InsertFoodEntity.kt b/app/src/main/java/com/myongsik/myongsikandroid/domain/model/love/InsertFoodEntity.kt deleted file mode 100644 index 874b9f99..00000000 --- a/app/src/main/java/com/myongsik/myongsikandroid/domain/model/love/InsertFoodEntity.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.myongsik.myongsikandroid.domain.model.love - -data class InsertFoodEntity( - val address_name: String, - val category_group_code: String, - val category_group_name: String, - val category_name: String, - val distance: String, - val id: String, - val phone: String, - val place_name: String, - val place_url: String, - val road_address_name: String, - val x: String, - val y: String -) - diff --git a/app/src/main/java/com/myongsik/myongsikandroid/domain/model/restaurant/InsertRestaurantEntity.kt b/app/src/main/java/com/myongsik/myongsikandroid/domain/model/restaurant/InsertRestaurantEntity.kt new file mode 100644 index 00000000..1f5f607f --- /dev/null +++ b/app/src/main/java/com/myongsik/myongsikandroid/domain/model/restaurant/InsertRestaurantEntity.kt @@ -0,0 +1,17 @@ +package com.myongsik.myongsikandroid.domain.model.restaurant + +data class InsertRestaurantEntity( + val addressName: String, + val categoryGroupCode: String, + val categoryGroupName: String, + val categoryName: String, + val distance: String, + val id: String, + val phone: String, + val placeName: String, + val placeUrl: String, + val roadAddressName: String, + val x: String, + val y: String +) + diff --git a/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/love/InsertFoodDataUseCase.kt b/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/love/InsertFoodDataUseCase.kt deleted file mode 100644 index 976e2f01..00000000 --- a/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/love/InsertFoodDataUseCase.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.myongsik.myongsikandroid.domain.usecase.love - -import com.myongsik.myongsikandroid.data.repository.love.LoveRepository -import com.myongsik.myongsikandroid.domain.model.love.InsertFoodEntity -import javax.inject.Inject - -class InsertFoodDataUseCase @Inject constructor( - private val loveRepository : LoveRepository -) : LoveCase { - - suspend operator fun invoke(insertFoodEntity: InsertFoodEntity) = - loveRepository.insertFood(insertFoodEntity) -} \ No newline at end of file diff --git a/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/love/LoveCase.kt b/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/love/LoveCase.kt deleted file mode 100644 index 51216085..00000000 --- a/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/love/LoveCase.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.myongsik.myongsikandroid.domain.usecase.love - -interface LoveCase { - -} \ No newline at end of file diff --git a/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/restaurant/InsertRestaurantDataUseCase.kt b/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/restaurant/InsertRestaurantDataUseCase.kt new file mode 100644 index 00000000..3eb4093c --- /dev/null +++ b/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/restaurant/InsertRestaurantDataUseCase.kt @@ -0,0 +1,13 @@ +package com.myongsik.myongsikandroid.domain.usecase.restaurant + +import com.myongsik.myongsikandroid.data.repository.restaurant.RestaurantRepository +import com.myongsik.myongsikandroid.domain.model.restaurant.InsertRestaurantEntity +import javax.inject.Inject + +class InsertRestaurantDataUseCase @Inject constructor( + private val restaurantRepository : RestaurantRepository +) : LoveCase { + + suspend operator fun invoke(insertRestaurantEntity: InsertRestaurantEntity) = + restaurantRepository.insertRestaurant(insertRestaurantEntity) +} \ No newline at end of file diff --git a/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/restaurant/LoveCase.kt b/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/restaurant/LoveCase.kt new file mode 100644 index 00000000..c8d3211a --- /dev/null +++ b/app/src/main/java/com/myongsik/myongsikandroid/domain/usecase/restaurant/LoveCase.kt @@ -0,0 +1,5 @@ +package com.myongsik.myongsikandroid.domain.usecase.restaurant + +interface LoveCase { + +} \ No newline at end of file diff --git a/app/src/main/java/com/myongsik/myongsikandroid/presentation/viewmodel/search/LoveViewModel.kt b/app/src/main/java/com/myongsik/myongsikandroid/presentation/viewmodel/search/LoveViewModel.kt index f5870ee7..4e4ab69a 100644 --- a/app/src/main/java/com/myongsik/myongsikandroid/presentation/viewmodel/search/LoveViewModel.kt +++ b/app/src/main/java/com/myongsik/myongsikandroid/presentation/viewmodel/search/LoveViewModel.kt @@ -11,7 +11,7 @@ import com.myongsik.myongsikandroid.data.model.food.ResponseScrap import com.myongsik.myongsikandroid.data.model.kakao.Restaurant import com.myongsik.myongsikandroid.data.model.kakao.toInsertFoodEntity import com.myongsik.myongsikandroid.data.repository.food.FoodRepository -import com.myongsik.myongsikandroid.domain.usecase.love.InsertFoodDataUseCase +import com.myongsik.myongsikandroid.domain.usecase.restaurant.InsertRestaurantDataUseCase import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow @@ -21,12 +21,12 @@ import javax.inject.Inject @HiltViewModel class LoveViewModel @Inject constructor( private val foodRepository: FoodRepository, - private val insertFoodDataUseCase: InsertFoodDataUseCase + private val insertRestaurantDataUseCase: InsertRestaurantDataUseCase ) : BaseViewModel() { //Room fun saveFoods(restaurant: Restaurant) = launch { - insertFoodDataUseCase(restaurant.toInsertFoodEntity()) + insertRestaurantDataUseCase(restaurant.toInsertFoodEntity()) } fun deleteFoods(restaurant: Restaurant) = launch {