-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor : Repository가 2개 이상 필요할 시 UseCase로 감싸기
- Loading branch information
1 parent
699dae9
commit 4579d78
Showing
11 changed files
with
132 additions
and
53 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
core/domain/src/main/kotlin/store/newsbriefing/app/core/domain/DeleteMemberUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package store.newsbriefing.app.core.domain | ||
|
||
import kotlinx.coroutines.flow.first | ||
import store.newsbriefing.app.core.data.repository.MemberRepository | ||
import store.newsbriefing.app.core.data.repository.MemberTokenRepository | ||
import javax.inject.Inject | ||
|
||
class DeleteMemberUseCase @Inject constructor( | ||
private val memberRepository: MemberRepository, | ||
private val memberTokenRepository: MemberTokenRepository | ||
) { | ||
suspend operator fun invoke() { | ||
val memberId = memberTokenRepository.getMemberToken().first().memberId | ||
memberRepository.deleteMember(memberId) | ||
memberTokenRepository.clearMemberToken() | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
core/domain/src/main/kotlin/store/newsbriefing/app/core/domain/SetScrapUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package store.newsbriefing.app.core.domain | ||
|
||
import kotlinx.coroutines.flow.first | ||
import store.newsbriefing.app.core.data.repository.MemberTokenRepository | ||
import store.newsbriefing.app.core.data.repository.ScrapRepository | ||
import javax.inject.Inject | ||
|
||
class SetScrapUseCase @Inject constructor( | ||
private val scrapRepository: ScrapRepository, | ||
private val memberTokenRepository: MemberTokenRepository | ||
) { | ||
suspend operator fun invoke(articleId: Long) { | ||
val userId = memberTokenRepository.getMemberToken().first().memberId | ||
scrapRepository.setScrap(userId, articleId) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
core/domain/src/main/kotlin/store/newsbriefing/app/core/domain/UnScrapUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package store.newsbriefing.app.core.domain | ||
|
||
import kotlinx.coroutines.flow.first | ||
import store.newsbriefing.app.core.data.repository.MemberTokenRepository | ||
import store.newsbriefing.app.core.data.repository.ScrapRepository | ||
import javax.inject.Inject | ||
|
||
class UnScrapUseCase @Inject constructor( | ||
private val scrapRepository: ScrapRepository, | ||
private val memberTokenRepository: MemberTokenRepository | ||
) { | ||
suspend operator fun invoke(articleId: Long) { | ||
val userId = memberTokenRepository.getMemberToken().first().memberId | ||
scrapRepository.unScrap(userId, articleId) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters