-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: 알송파트 유즈케이스 적용 #666
Open
songpink
wants to merge
16
commits into
chongdae
Choose a base branch
from
feature/663-alsong-usecase
base: chongdae
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: 알송파트 유즈케이스 적용 #666
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
94c4826
refactor: 로그인 기능 유즈케이스 구현
songpink c9d267d
refactor: 이미 로그인이 되어 있는 디바이스인지 확인하는 기능에 유즈케이스 적용
songpink 7c8d590
refactor: 네이밍 개선
songpink e56fc2b
style: 필요 없어진 코드 제거
songpink dc20a78
refactor: 공모글 작성 기능에 유즈케이스 적용
songpink 15778c4
refactor: 유즈케이스를 도메인 레이어로 이동
songpink 118b237
style: ktlint format 적용
songpink ad0ac12
refactor: 이미지 업로드 기능에 유즈케이스 적용
songpink bd25819
refactor: 이미지 업로드 기능에 유즈케이스 적용
songpink 8d3838e
refactor: 공모글 수정 기능에 유즈케이스 적용
songpink 9fcc0d1
refactor: 채팅방 목록 조회 기능에 유즈케이스 적용
songpink b47a756
test: 댓글방 목록을 불러오는 유즈케이스 테스트
songpink 0c6e0d4
test: 로그인 유즈케이스 테스트
songpink 10001da
test: 유즈케이스 적용으로 인한 공모글 작성 뷰모델 테스트 수정
songpink b288858
test: 유즈케이스 적용으로 인한 댓글방 목록 조회 뷰모델 테스트 수정
songpink caa01c2
style: ktlint format 적용
songpink 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
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
35 changes: 35 additions & 0 deletions
35
android/app/src/main/java/com/zzang/chongdae/di/annotations/UseCaseQualifier.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,35 @@ | ||
package com.zzang.chongdae.di.annotations | ||
|
||
import javax.inject.Qualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class CheckAlreadyLoggedInUseCaseQualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class PostLoginUseCaseQualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class PostOfferingUseCaseQualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class UploadImageFileUseCaseQualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class PostProductImageOgUseCaseQualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class FetchOfferingDetailUseCaseQualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class PostOfferingModifyUseCaseQualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class UpdateCommentRoomsUseCaseQualifier |
75 changes: 75 additions & 0 deletions
75
android/app/src/main/java/com/zzang/chongdae/di/module/UseCaseDependencyModule.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,75 @@ | ||
package com.zzang.chongdae.di.module | ||
|
||
import com.zzang.chongdae.di.annotations.CheckAlreadyLoggedInUseCaseQualifier | ||
import com.zzang.chongdae.di.annotations.FetchOfferingDetailUseCaseQualifier | ||
import com.zzang.chongdae.di.annotations.PostLoginUseCaseQualifier | ||
import com.zzang.chongdae.di.annotations.PostOfferingModifyUseCaseQualifier | ||
import com.zzang.chongdae.di.annotations.PostOfferingUseCaseQualifier | ||
import com.zzang.chongdae.di.annotations.PostProductImageOgUseCaseQualifier | ||
import com.zzang.chongdae.di.annotations.UpdateCommentRoomsUseCaseQualifier | ||
import com.zzang.chongdae.di.annotations.UploadImageFileUseCaseQualifier | ||
import com.zzang.chongdae.domain.usecase.comment.UpdateCommentRoomsUseCase | ||
import com.zzang.chongdae.domain.usecase.comment.UpdateCommentRoomsUseCaseImpl | ||
import com.zzang.chongdae.domain.usecase.login.CheckIfAlreadyLoggedInUseCase | ||
import com.zzang.chongdae.domain.usecase.login.CheckIfAlreadyLoggedInUseCaseImpl | ||
import com.zzang.chongdae.domain.usecase.login.PostLoginUseCase | ||
import com.zzang.chongdae.domain.usecase.login.PostLoginUseCaseImpl | ||
import com.zzang.chongdae.domain.usecase.offeringmodify.FetchOfferingDetailUseCase | ||
import com.zzang.chongdae.domain.usecase.offeringmodify.FetchOfferingDetailUseCaseImpl | ||
import com.zzang.chongdae.domain.usecase.offeringmodify.PostOfferingModifyUseCase | ||
import com.zzang.chongdae.domain.usecase.offeringmodify.PostOfferingModifyUseCaseImpl | ||
import com.zzang.chongdae.domain.usecase.write.PostOfferingUseCase | ||
import com.zzang.chongdae.domain.usecase.write.PostOfferingUseCaseImpl | ||
import com.zzang.chongdae.domain.usecase.write.PostProductImageOgUseCase | ||
import com.zzang.chongdae.domain.usecase.write.PostProductImageOgUseCaseImpl | ||
import com.zzang.chongdae.domain.usecase.write.UploadImageFileUseCase | ||
import com.zzang.chongdae.domain.usecase.write.UploadImageFileUseCaseImpl | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
abstract class UseCaseDependencyModule { | ||
@Binds | ||
@Singleton | ||
@CheckAlreadyLoggedInUseCaseQualifier | ||
abstract fun provideCheckIfAlreadyLoggedInUseCase(impl: CheckIfAlreadyLoggedInUseCaseImpl): CheckIfAlreadyLoggedInUseCase | ||
|
||
@Binds | ||
@Singleton | ||
@PostLoginUseCaseQualifier | ||
abstract fun providePostLoginUseCase(impl: PostLoginUseCaseImpl): PostLoginUseCase | ||
|
||
@Binds | ||
@Singleton | ||
@PostOfferingUseCaseQualifier | ||
abstract fun providePostOfferingUseCase(impl: PostOfferingUseCaseImpl): PostOfferingUseCase | ||
|
||
@Binds | ||
@Singleton | ||
@UploadImageFileUseCaseQualifier | ||
abstract fun provideUploadImageFileUseCase(impl: UploadImageFileUseCaseImpl): UploadImageFileUseCase | ||
|
||
@Binds | ||
@Singleton | ||
@PostProductImageOgUseCaseQualifier | ||
abstract fun providePostProductImageOgUseCase(impl: PostProductImageOgUseCaseImpl): PostProductImageOgUseCase | ||
|
||
@Binds | ||
@Singleton | ||
@FetchOfferingDetailUseCaseQualifier | ||
abstract fun provideFetchOfferingDetailUseCase(impl: FetchOfferingDetailUseCaseImpl): FetchOfferingDetailUseCase | ||
|
||
@Binds | ||
@Singleton | ||
@PostOfferingModifyUseCaseQualifier | ||
abstract fun providePostOfferingModifyUseCase(impl: PostOfferingModifyUseCaseImpl): PostOfferingModifyUseCase | ||
|
||
@Binds | ||
@Singleton | ||
@UpdateCommentRoomsUseCaseQualifier | ||
abstract fun provideUpdateCommentRoomsUseCase(impl: UpdateCommentRoomsUseCaseImpl): UpdateCommentRoomsUseCase | ||
} |
9 changes: 9 additions & 0 deletions
9
.../app/src/main/java/com/zzang/chongdae/domain/usecase/comment/UpdateCommentRoomsUseCase.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,9 @@ | ||
package com.zzang.chongdae.domain.usecase.comment | ||
|
||
import com.zzang.chongdae.common.handler.DataError | ||
import com.zzang.chongdae.common.handler.Result | ||
import com.zzang.chongdae.domain.model.CommentRoom | ||
|
||
interface UpdateCommentRoomsUseCase { | ||
suspend operator fun invoke(): Result<List<CommentRoom>, DataError.Network> | ||
} |
35 changes: 35 additions & 0 deletions
35
.../src/main/java/com/zzang/chongdae/domain/usecase/comment/UpdateCommentRoomsUseCaseImpl.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,35 @@ | ||
package com.zzang.chongdae.domain.usecase.comment | ||
|
||
import com.zzang.chongdae.auth.repository.AuthRepository | ||
import com.zzang.chongdae.common.handler.DataError | ||
import com.zzang.chongdae.common.handler.Result | ||
import com.zzang.chongdae.di.annotations.AuthRepositoryQualifier | ||
import com.zzang.chongdae.di.annotations.CommentRoomsRepositoryQualifier | ||
import com.zzang.chongdae.domain.model.CommentRoom | ||
import com.zzang.chongdae.domain.repository.CommentRoomsRepository | ||
import javax.inject.Inject | ||
|
||
class UpdateCommentRoomsUseCaseImpl | ||
@Inject | ||
constructor( | ||
@AuthRepositoryQualifier private val authRepository: AuthRepository, | ||
@CommentRoomsRepositoryQualifier private val commentRoomsRepository: CommentRoomsRepository, | ||
) : UpdateCommentRoomsUseCase { | ||
override suspend fun invoke(): Result<List<CommentRoom>, DataError.Network> { | ||
return when (val result = commentRoomsRepository.fetchCommentRooms()) { | ||
is Result.Success -> Result.Success(result.data) | ||
is Result.Error -> { | ||
when (result.error) { | ||
DataError.Network.UNAUTHORIZED -> { | ||
when (authRepository.saveRefresh()) { | ||
is Result.Success -> invoke() | ||
is Result.Error -> result | ||
} | ||
} | ||
|
||
else -> result | ||
} | ||
} | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...pp/src/main/java/com/zzang/chongdae/domain/usecase/login/CheckIfAlreadyLoggedInUseCase.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,5 @@ | ||
package com.zzang.chongdae.domain.usecase.login | ||
|
||
interface CheckIfAlreadyLoggedInUseCase { | ||
suspend operator fun invoke(): Boolean | ||
} |
16 changes: 16 additions & 0 deletions
16
...rc/main/java/com/zzang/chongdae/domain/usecase/login/CheckIfAlreadyLoggedInUseCaseImpl.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 com.zzang.chongdae.domain.usecase.login | ||
|
||
import com.zzang.chongdae.common.datastore.UserPreferencesDataStore | ||
import kotlinx.coroutines.flow.first | ||
import javax.inject.Inject | ||
|
||
class CheckIfAlreadyLoggedInUseCaseImpl | ||
@Inject | ||
constructor( | ||
private val userPreferencesDataStore: UserPreferencesDataStore, | ||
) : CheckIfAlreadyLoggedInUseCase { | ||
override suspend fun invoke(): Boolean { | ||
val accessToken = userPreferencesDataStore.accessTokenFlow.first() | ||
return accessToken != null | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
android/app/src/main/java/com/zzang/chongdae/domain/usecase/login/PostLoginUseCase.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,11 @@ | ||
package com.zzang.chongdae.domain.usecase.login | ||
|
||
import com.zzang.chongdae.common.handler.DataError | ||
import com.zzang.chongdae.common.handler.Result | ||
|
||
interface PostLoginUseCase { | ||
suspend operator fun invoke( | ||
accessToken: String, | ||
fcmToken: String, | ||
): Result<Unit, DataError.Network> | ||
} |
30 changes: 30 additions & 0 deletions
30
android/app/src/main/java/com/zzang/chongdae/domain/usecase/login/PostLoginUseCaseImpl.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,30 @@ | ||
package com.zzang.chongdae.domain.usecase.login | ||
|
||
import com.zzang.chongdae.auth.repository.AuthRepository | ||
import com.zzang.chongdae.common.datastore.UserPreferencesDataStore | ||
import com.zzang.chongdae.common.handler.DataError | ||
import com.zzang.chongdae.common.handler.Result | ||
import com.zzang.chongdae.di.annotations.AuthRepositoryQualifier | ||
import javax.inject.Inject | ||
|
||
class PostLoginUseCaseImpl | ||
@Inject | ||
constructor( | ||
@AuthRepositoryQualifier private val authRepository: AuthRepository, | ||
private val userPreferencesDataStore: UserPreferencesDataStore, | ||
) : PostLoginUseCase { | ||
override suspend fun invoke( | ||
accessToken: String, | ||
fcmToken: String, | ||
): Result<Unit, DataError.Network> { | ||
return when (val result = authRepository.postLogin(accessToken, fcmToken)) { | ||
is Result.Success -> { | ||
userPreferencesDataStore.saveMember(result.data.memberId, result.data.nickName) | ||
userPreferencesDataStore.saveFcmToken(fcmToken) | ||
Result.Success(Unit) | ||
} | ||
|
||
is Result.Error -> result | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
.../main/java/com/zzang/chongdae/domain/usecase/offeringmodify/FetchOfferingDetailUseCase.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,9 @@ | ||
package com.zzang.chongdae.domain.usecase.offeringmodify | ||
|
||
import com.zzang.chongdae.common.handler.DataError | ||
import com.zzang.chongdae.common.handler.Result | ||
import com.zzang.chongdae.domain.model.OfferingDetail | ||
|
||
interface FetchOfferingDetailUseCase { | ||
suspend operator fun invoke(offeringId: Long): Result<OfferingDetail, DataError.Network> | ||
} |
35 changes: 35 additions & 0 deletions
35
...n/java/com/zzang/chongdae/domain/usecase/offeringmodify/FetchOfferingDetailUseCaseImpl.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,35 @@ | ||
package com.zzang.chongdae.domain.usecase.offeringmodify | ||
|
||
import com.zzang.chongdae.auth.repository.AuthRepository | ||
import com.zzang.chongdae.common.handler.DataError | ||
import com.zzang.chongdae.common.handler.Result | ||
import com.zzang.chongdae.di.annotations.AuthRepositoryQualifier | ||
import com.zzang.chongdae.di.annotations.OfferingDetailRepositoryQualifier | ||
import com.zzang.chongdae.domain.model.OfferingDetail | ||
import com.zzang.chongdae.domain.repository.OfferingDetailRepository | ||
import javax.inject.Inject | ||
|
||
class FetchOfferingDetailUseCaseImpl | ||
@Inject | ||
constructor( | ||
@OfferingDetailRepositoryQualifier private val offeringDetailRepository: OfferingDetailRepository, | ||
@AuthRepositoryQualifier private val authRepository: AuthRepository, | ||
) : FetchOfferingDetailUseCase { | ||
override suspend fun invoke(offeringId: Long): Result<OfferingDetail, DataError.Network> { | ||
return when (val result = offeringDetailRepository.fetchOfferingDetail(offeringId)) { | ||
is Result.Success -> Result.Success(result.data) | ||
is Result.Error -> { | ||
when (result.error) { | ||
DataError.Network.UNAUTHORIZED -> { | ||
when (authRepository.saveRefresh()) { | ||
is Result.Success -> invoke(offeringId) | ||
is Result.Error -> result | ||
} | ||
} | ||
|
||
else -> result | ||
} | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...c/main/java/com/zzang/chongdae/domain/usecase/offeringmodify/PostOfferingModifyUseCase.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,12 @@ | ||
package com.zzang.chongdae.domain.usecase.offeringmodify | ||
|
||
import com.zzang.chongdae.common.handler.DataError | ||
import com.zzang.chongdae.common.handler.Result | ||
import com.zzang.chongdae.domain.model.OfferingModifyDomainRequest | ||
|
||
interface PostOfferingModifyUseCase { | ||
suspend operator fun invoke( | ||
offeringId: Long, | ||
offeringModifyDomainRequest: OfferingModifyDomainRequest, | ||
): Result<Unit, DataError.Network> | ||
} |
41 changes: 41 additions & 0 deletions
41
...in/java/com/zzang/chongdae/domain/usecase/offeringmodify/PostOfferingModifyUseCaseImpl.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,41 @@ | ||
package com.zzang.chongdae.domain.usecase.offeringmodify | ||
|
||
import com.zzang.chongdae.auth.repository.AuthRepository | ||
import com.zzang.chongdae.common.handler.DataError | ||
import com.zzang.chongdae.common.handler.Result | ||
import com.zzang.chongdae.di.annotations.AuthRepositoryQualifier | ||
import com.zzang.chongdae.di.annotations.OfferingRepositoryQualifier | ||
import com.zzang.chongdae.domain.model.OfferingModifyDomainRequest | ||
import com.zzang.chongdae.domain.repository.OfferingRepository | ||
import javax.inject.Inject | ||
|
||
class PostOfferingModifyUseCaseImpl | ||
@Inject | ||
constructor( | ||
@OfferingRepositoryQualifier private val offeringRepository: OfferingRepository, | ||
@AuthRepositoryQualifier private val authRepository: AuthRepository, | ||
) : PostOfferingModifyUseCase { | ||
override suspend fun invoke( | ||
offeringId: Long, | ||
offeringModifyDomainRequest: OfferingModifyDomainRequest, | ||
): Result<Unit, DataError.Network> { | ||
return when ( | ||
val result = | ||
offeringRepository.patchOffering(offeringId, offeringModifyDomainRequest) | ||
) { | ||
is Result.Success -> Result.Success(Unit) | ||
is Result.Error -> { | ||
when (result.error) { | ||
DataError.Network.UNAUTHORIZED -> { | ||
when (authRepository.saveRefresh()) { | ||
is Result.Success -> invoke(offeringId, offeringModifyDomainRequest) | ||
is Result.Error -> result | ||
} | ||
} | ||
|
||
else -> result | ||
} | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
android/app/src/main/java/com/zzang/chongdae/domain/usecase/write/PostOfferingUseCase.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,9 @@ | ||
package com.zzang.chongdae.domain.usecase.write | ||
|
||
import com.zzang.chongdae.common.handler.DataError | ||
import com.zzang.chongdae.common.handler.Result | ||
import com.zzang.chongdae.domain.model.OfferingWrite | ||
|
||
interface PostOfferingUseCase { | ||
suspend operator fun invoke(offeringWrite: OfferingWrite): Result<Unit, DataError.Network> | ||
} |
34 changes: 34 additions & 0 deletions
34
android/app/src/main/java/com/zzang/chongdae/domain/usecase/write/PostOfferingUseCaseImpl.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,34 @@ | ||
package com.zzang.chongdae.domain.usecase.write | ||
|
||
import com.zzang.chongdae.auth.repository.AuthRepository | ||
import com.zzang.chongdae.common.handler.DataError | ||
import com.zzang.chongdae.common.handler.Result | ||
import com.zzang.chongdae.di.annotations.AuthRepositoryQualifier | ||
import com.zzang.chongdae.di.annotations.OfferingRepositoryQualifier | ||
import com.zzang.chongdae.domain.model.OfferingWrite | ||
import com.zzang.chongdae.domain.repository.OfferingRepository | ||
import javax.inject.Inject | ||
|
||
class PostOfferingUseCaseImpl | ||
@Inject | ||
constructor( | ||
@OfferingRepositoryQualifier private val offeringRepository: OfferingRepository, | ||
@AuthRepositoryQualifier private val authRepository: AuthRepository, | ||
) : PostOfferingUseCase { | ||
override suspend fun invoke(offeringWrite: OfferingWrite): Result<Unit, DataError.Network> { | ||
return when (val result = offeringRepository.saveOffering(offeringWrite)) { | ||
is Result.Success -> Result.Success(Unit) | ||
is Result.Error -> { | ||
when (result.error) { | ||
DataError.Network.UNAUTHORIZED -> { | ||
when (authRepository.saveRefresh()) { | ||
is Result.Success -> invoke(offeringWrite) | ||
is Result.Error -> result | ||
} | ||
} | ||
else -> result | ||
} | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...id/app/src/main/java/com/zzang/chongdae/domain/usecase/write/PostProductImageOgUseCase.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,9 @@ | ||
package com.zzang.chongdae.domain.usecase.write | ||
|
||
import com.zzang.chongdae.common.handler.DataError | ||
import com.zzang.chongdae.common.handler.Result | ||
import com.zzang.chongdae.domain.model.ProductUrl | ||
|
||
interface PostProductImageOgUseCase { | ||
suspend operator fun invoke(productUrl: String): Result<ProductUrl, DataError.Network> | ||
} |
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 구현체가 1개 인것으로 하는데 굳이 Qualifier를 설정하는 이유가 궁금해요!!
제가 모르는 다른 이유가 있나요? 🧐
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.
일단은 구현체가 추가될 것에 대비해서 Qualifier를 설정 해두었습니다.
usecase를 추상화 하지 않아도 된다라는 피드백이라면, 목요일에 서기와도 얘기를 했던 부분인데요,
https://mashup-android.vercel.app/mashup-11th/heejin/useCase/useCase/
위 링크에서 usecase를 interface로 추상화 했길래, 저도 추상화 했습니다.
서기도 usecase를 추상화 할 필요까지는 없다는 의견을 주었는데요, 저도 대체적으로 동의하지만 저는 usecase를 처음 적용해 보는 것이기도 해서 위 블로그 내용을 최대한 따라하려고 노력했고, 또 확장성의 관점에서 usecase를 추상화 함으로써 비즈니스 로직이 바뀔 경우 구현체만 교체하는 방식으로 수정이 용이해지는 장점이 있다고 생각해서 이렇게 구현했습니다. 서기와 채채는 usecase를 추상화 하지 않고 구현해도 된다고 생각합니다!
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에 대한 구현체가 여러개가 된다는 가정이 필요없다는 의견이어서 이렇게 코멘트를 남겼습니다! 불필요한 복잡도가 늘어나는 것을 경계해야한다고 생각하기 때문에!! 하지만 알송의 코멘트를 통해서 알송의 생각을 알게되었숩니다 감사해요~