-
Notifications
You must be signed in to change notification settings - Fork 1
[REFACTOR/#151] Auth 모듈 통신 관련 UseCase 패턴으로 교체 #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4d9d95d
[FEAT/#151] 토큰교체 통신 UseCase 구현
Marchbreeze 676257a
[FIX/#151] UseCase 싱글톤 제거 및 Inject 활용
Marchbreeze 6a98bb3
[FEAT/#151] iamport 토큰 발급 통신 UseCase 구현
Marchbreeze ed08e89
[FEAT/#151] iamport 정보 획득 통신 UseCase 구현
Marchbreeze 4a2ccae
[FEAT/#151] 회원가입 통신 UseCase 구현
Marchbreeze 90cc5b2
[FEAT/#151] 토큰 재발급 UseCase 구현
Marchbreeze File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
app/src/main/java/co/orange/ddanzi/di/module/UseCaseModule.kt
This file contains hidden or 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,23 @@ | ||
package co.orange.ddanzi.di.module | ||
|
||
import co.orange.domain.repository.AuthRepository | ||
import co.orange.domain.repository.UserRepository | ||
import co.orange.domain.usecase.AuthChangeTokenUseCase | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
class UseCaseModule { | ||
@Singleton | ||
@Provides | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yello 때는 별 뜻없이 provide를 사용하긴 했는데 외부 라이브러리 주입이 아니라면 bind로 주입하는걸 추천합니댜, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 관련해서도 잔뜩 알아보고 오겠습니당 |
||
fun provideAuthChangeTokenUseCase( | ||
authRepository: AuthRepository, | ||
userRepository: UserRepository | ||
): AuthChangeTokenUseCase { | ||
return AuthChangeTokenUseCase(authRepository, userRepository) | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
30 changes: 30 additions & 0 deletions
30
domain/src/main/kotlin/co/orange/domain/usecase/AuthChangeTokenUseCase.kt
This file contains hidden or 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,30 @@ | ||
package co.orange.domain.usecase | ||
|
||
import co.orange.domain.entity.request.AuthRequestModel | ||
import co.orange.domain.repository.AuthRepository | ||
import co.orange.domain.repository.UserRepository | ||
|
||
class AuthChangeTokenUseCase( | ||
private val authRepository: AuthRepository, | ||
private val userRepository: UserRepository | ||
) { | ||
suspend operator fun invoke(accessToken: String, fcmToken: String) = runCatching { | ||
val authTokenModel = authRepository.postOauthDataToGetToken( | ||
AuthRequestModel( | ||
accessToken, | ||
KAKAO, | ||
userRepository.getDeviceToken(), | ||
ANDROID, | ||
fcmToken, | ||
), | ||
) | ||
userRepository.setTokens(authTokenModel.accesstoken, authTokenModel.refreshtoken) | ||
userRepository.setUserStatus(authTokenModel.status) | ||
return@runCatching authTokenModel.status | ||
} | ||
|
||
companion object { | ||
const val KAKAO = "KAKAO" | ||
const val ANDROID = "ANDROID" | ||
} | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UseCase를 특별하게 Singleton으로 만든 이유가 있을까?.?
UseCase는 보통 상태를 가지지 않는 단일 책임 비즈니스 로직이고
이미 repository 단에서 single톤이기에 특별한 이유가 없다면 사용 안해도 될거같슴다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오호 ... 하나의 기능 구현이라면 싱글톤이 아닌게 오히려 덜꼬일 것 같기는 하네요 !