Skip to content

Commit

Permalink
[refact] : #83 DataSource 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
SsongSik committed May 8, 2023
1 parent 6515f31 commit 0a4af6f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.myongsik.myongsikandroid.data.datasource.restaurant

import com.myongsik.myongsikandroid.domain.model.restaurant.InsertRestaurantEntity

interface RestaurantDataSource {

suspend fun insertRestaurant(insertRestaurantEntity: InsertRestaurantEntity)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.myongsik.myongsikandroid.data.datasource.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 RestaurantDataSourceImpl @Inject constructor(
private val loveDb : RestaurantDatabase
) : RestaurantDataSource {

override suspend fun insertRestaurant(insertRestaurantEntity: InsertRestaurantEntity) {
loveDb.restaurantDao().insertGoodFood(insertRestaurantEntity.toInsertFoodData())
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package com.myongsik.myongsikandroid.data.repository.restaurant

import com.myongsik.myongsikandroid.data.datasource.restaurant.RestaurantDataSource
import com.myongsik.myongsikandroid.data.db.RestaurantDatabase
import com.myongsik.myongsikandroid.data.model.kakao.toInsertFoodData
import com.myongsik.myongsikandroid.domain.model.restaurant.InsertRestaurantEntity
import com.myongsik.myongsikandroid.domain.repository.restaurant.RestaurantRepository
import javax.inject.Inject

class RestaurantRepositoryImpl @Inject constructor(
private val loveDb : RestaurantDatabase
private val restaurantDataSource: RestaurantDataSource
) : RestaurantRepository {

override suspend fun insertRestaurant(insertRestaurantEntity: InsertRestaurantEntity) {
loveDb.restaurantDao().insertGoodFood(insertRestaurantEntity.toInsertFoodData())
restaurantDataSource.insertRestaurant(insertRestaurantEntity)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.myongsik.myongsikandroid.di

import com.myongsik.myongsikandroid.data.datasource.restaurant.RestaurantDataSource
import com.myongsik.myongsikandroid.data.datasource.restaurant.RestaurantDataSourceImpl
import com.myongsik.myongsikandroid.data.repository.food.FoodRepository
import com.myongsik.myongsikandroid.data.repository.food.FoodRepositoryImpl
import com.myongsik.myongsikandroid.domain.repository.restaurant.RestaurantRepository
Expand All @@ -18,6 +20,7 @@ import javax.inject.Singleton
@InstallIn(SingletonComponent::class)
abstract class RepositoryModule {

//Repository
@Singleton
@Binds
abstract fun bindFoodRepository(
Expand All @@ -38,7 +41,14 @@ abstract class RepositoryModule {

@Singleton
@Binds
abstract fun bindLoveRepository(
abstract fun bindRestaurantRepository(
restaurantRepositoryImpl: RestaurantRepositoryImpl
): RestaurantRepository

//DataSource
@Singleton
@Binds
abstract fun bindRestaurantDataSource(
restaurantDataSource: RestaurantDataSourceImpl
): RestaurantDataSource
}

0 comments on commit 0a4af6f

Please sign in to comment.