Skip to content

Commit

Permalink
[refact] : #107 카멜케이스, 함수명 PR반영
Browse files Browse the repository at this point in the history
  • Loading branch information
SsongSik committed May 8, 2023
1 parent 208a789 commit 1149de7
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -39,6 +39,6 @@ abstract class RepositoryModule {
@Singleton
@Binds
abstract fun bindLoveRepository(
loveRepositoryImpl: LoveRepositoryImpl
): LoveRepository
restaurantRepositoryImpl: RestaurantRepositoryImpl
): RestaurantRepository
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
)

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.myongsik.myongsikandroid.domain.usecase.restaurant

interface LoveCase {

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 1149de7

Please sign in to comment.