Skip to content

Commit

Permalink
Issues #287 feat: Gifticon, Brand Repository di 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
audxo112 committed Feb 8, 2023
1 parent 287c09b commit 1982eac
Show file tree
Hide file tree
Showing 13 changed files with 351 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ import dagger.hilt.components.SingletonComponent
internal abstract class DataModule {

@Binds
abstract fun bindsDatabaseRepository(
abstract fun bindsBrandDatabaseRepository(
repository: BrandDatabaseRepositoryImpl
): BrandDatabaseRepository

@Binds
abstract fun bindsGifticonEditRepository(
abstract fun bindsGifticonEditDatabaseRepository(
repository: GifticonEditDatabaseRepositoryImpl
): GifticonEditDatabaseRepository

@Binds
abstract fun bindsGifticonSearchRepository(
abstract fun bindsGifticonSearchDatabaseRepository(
repository: GifticonSearchDatabaseRepositoryImpl
): GifticonSearchDatabaseRepository

@Binds
abstract fun bindsGifticonUsageHistoryRepository(
abstract fun bindsGifticonUsageHistoryDatabaseRepository(
repository: GifticonUsageHistoryDatabaseRepositoryImpl
): GifticonUsageHistoryDatabaseRepository
}
40 changes: 40 additions & 0 deletions data/data/src/main/java/com/lighthouse/di/DataModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.lighthouse.di

import com.lighthouse.domain.repository.BrandRepository
import com.lighthouse.domain.repository.GifticonEditRepository
import com.lighthouse.domain.repository.GifticonSearchRepository
import com.lighthouse.domain.repository.GifticonUsageHistoryRepository
import com.lighthouse.repository.brand.BrandRepositoryImpl
import com.lighthouse.repository.gifticon.GifticonEditRepositoryImpl
import com.lighthouse.repository.gifticon.GifticonSearchRepositoryImpl
import com.lighthouse.repository.gifticon.GifticonUsageHistoryRepositoryImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent

@Suppress("unused")
@Module
@InstallIn(SingletonComponent::class)
internal abstract class DataModule {

@Binds
abstract fun bindsBrandRepository(
repository: BrandRepositoryImpl
): BrandRepository

@Binds
abstract fun bindsGifticonEditRepository(
repository: GifticonEditRepositoryImpl
): GifticonEditRepository

@Binds
abstract fun bindsGifticonSearchRepository(
repository: GifticonSearchRepositoryImpl
): GifticonSearchRepository

@Binds
abstract fun bindsGifticonUsageHistoryRepository(
repository: GifticonUsageHistoryRepositoryImpl
): GifticonUsageHistoryRepository
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.lighthouse.repository.brand

import com.lighthouse.beep.model.brand.BrandPlaceInfo
import com.lighthouse.beep.model.location.Dms
import com.lighthouse.domain.repository.BrandRepository
import javax.inject.Inject

internal class BrandRepositoryImpl @Inject constructor(
private val brandRemoteRepository: BrandRemoteRepository,
private val brandDatabaseRepository: BrandDatabaseRepository
) : BrandRepository {

override suspend fun getBrandPlaceInfo(
brandName: String,
x: Dms,
y: Dms,
size: Int
): Result<List<BrandPlaceInfo>> {
var result = brandDatabaseRepository.getBrands(x, y, brandName)
if (result.isFailure) {
result = brandRemoteRepository.getBrandPlaceInfo(brandName, x, y, size)
val list = result.getOrNull()
if (list != null) {
brandDatabaseRepository.insertBrands(list, x, y, brandName)
}
}
return result
}

override suspend fun removeExpirationBrands(): Result<Unit> {
return brandDatabaseRepository.removeExpirationBrands()
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
package com.lighthouse.repository.gifticon

class GifticonEditRepositoryImpl
import com.lighthouse.beep.model.gifticon.GifticonWithCrop
import com.lighthouse.domain.repository.GifticonEditRepository
import javax.inject.Inject

internal class GifticonEditRepositoryImpl @Inject constructor(
private val gifticonEditDatabaseRepository: GifticonEditDatabaseRepository
) : GifticonEditRepository {

override suspend fun insertGifticons(gifticonWithCropList: List<GifticonWithCrop>): Result<Unit> {
TODO("Not yet implemented")
}

override suspend fun updateGifticon(gifticonWithCrop: GifticonWithCrop): Result<Unit> {
TODO("Not yet implemented")
}

override suspend fun deleteGifticon(
userId: String,
gifticonId: String
): Result<Unit> {
TODO("Not yet implemented")
}

override suspend fun moveUserIdGifticon(
oldUserId: String,
newUserId: String
): Result<Unit> {
TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,79 @@
package com.lighthouse.repository.gifticon

class GifticonSearchRepositoryImpl
import com.lighthouse.beep.model.brand.BrandWithGifticonCount
import com.lighthouse.beep.model.etc.SortBy
import com.lighthouse.beep.model.gifticon.Gifticon
import com.lighthouse.beep.model.gifticon.GifticonWithCrop
import com.lighthouse.domain.repository.GifticonSearchRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

internal class GifticonSearchRepositoryImpl @Inject constructor(
private val gifticonSearchDatabaseRepository: GifticonSearchDatabaseRepository
) : GifticonSearchRepository {

override fun getGifticon(
userId: String,
gifticonId: String
): Result<Flow<Gifticon>> {
TODO("Not yet implemented")
}

override fun getAllGifticons(
userId: String,
isUsed: Boolean,
filterExpired: Boolean,
sortBy: SortBy
): Result<Flow<List<Gifticon>>> {
TODO("Not yet implemented")
}

override fun getFilteredGifticons(
userId: String,
isUsed: Boolean,
filterBrand: Set<String>,
filterExpired: Boolean,
sortBy: SortBy
): Result<Flow<List<Gifticon>>> {
TODO("Not yet implemented")
}

override fun getGifticonByBrand(
userId: String,
isUsed: Boolean,
brand: String,
filterExpired: Boolean
): Result<Flow<List<Gifticon>>> {
TODO("Not yet implemented")
}

override fun getAllBrands(
userId: String,
isUsed: Boolean,
filterExpired: Boolean
): Result<Flow<List<BrandWithGifticonCount>>> {
TODO("Not yet implemented")
}

override suspend fun getGifticonCrop(
userId: String,
gifticonId: String
): Result<GifticonWithCrop> {
TODO("Not yet implemented")
}

override fun hasGifticon(
userId: String,
isUsed: Boolean,
filterExpired: Boolean
): Result<Flow<Boolean>> {
TODO("Not yet implemented")
}

override suspend fun hasGifticonBrand(
userId: String,
brand: String
): Result<Boolean> {
TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
package com.lighthouse.repository.gifticon

class GifticonUsageHistoryRepositoryImpl
import com.lighthouse.beep.model.user.UsageHistory
import com.lighthouse.domain.repository.GifticonUsageHistoryRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

internal class GifticonUsageHistoryRepositoryImpl @Inject constructor(
private val gifticonUsageHistoryDatabaseRepository: GifticonUsageHistoryDatabaseRepository
) : GifticonUsageHistoryRepository {

override suspend fun useGifticon(
userId: String,
gifticonId: String,
usageHistory: UsageHistory
): Result<Unit> {
TODO("Not yet implemented")
}

override suspend fun useCashCardGifticon(
userId: String,
gifticonId: String,
amount: Int,
usageHistory: UsageHistory
): Result<Unit> {
TODO("Not yet implemented")
}

override suspend fun revertUsedGifticon(
userId: String,
gifticonId: String
): Result<Unit> {
TODO("Not yet implemented")
}

override fun getUsageHistory(
userId: String,
gifticonId: String
): Result<Flow<List<UsageHistory>>> {
TODO("Not yet implemented")
}

override suspend fun insertUsageHistory(
gifticonId: String,
usageHistory: UsageHistory
): Result<Unit> {
TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.lighthouse.domain.repository

import com.lighthouse.beep.model.gifticon.GifticonWithCrop

interface GifticonEditRepository {

suspend fun insertGifticons(
gifticonWithCropList: List<GifticonWithCrop>
): Result<Unit>

suspend fun updateGifticon(
gifticonWithCrop: GifticonWithCrop
): Result<Unit>

suspend fun deleteGifticon(
userId: String,
gifticonId: String
): Result<Unit>

suspend fun moveUserIdGifticon(
oldUserId: String,
newUserId: String
): Result<Unit>
}

This file was deleted.

Loading

0 comments on commit 1982eac

Please sign in to comment.