-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #509 from BCSDLab/fix/campus
[Fix] 캠퍼스팀 요구사항 반영
- Loading branch information
Showing
15 changed files
with
128 additions
and
126 deletions.
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
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
7 changes: 7 additions & 0 deletions
7
data/src/main/java/in/koreatech/koin/data/response/user/ABTestTokenResponse.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,7 @@ | ||
package `in`.koreatech.koin.data.response.user | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class ABTestTokenResponse( | ||
@SerializedName("accessHistoryId") val accessHistoryId: String | ||
) |
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
25 changes: 13 additions & 12 deletions
25
domain/src/main/java/in/koreatech/koin/domain/usecase/user/ABTestUseCase.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 |
---|---|---|
@@ -1,24 +1,25 @@ | ||
package `in`.koreatech.koin.domain.usecase.user | ||
|
||
import `in`.koreatech.koin.domain.error.user.UserErrorHandler | ||
import `in`.koreatech.koin.domain.model.error.ErrorHandler | ||
import `in`.koreatech.koin.domain.repository.TokenRepository | ||
import `in`.koreatech.koin.domain.repository.UserRepository | ||
import kotlinx.coroutines.sync.Mutex | ||
import kotlinx.coroutines.sync.withLock | ||
import javax.inject.Inject | ||
|
||
class ABTestUseCase @Inject constructor( | ||
private val userRepository: UserRepository, | ||
private val tokenRepository: TokenRepository, | ||
private val userErrorHandler: UserErrorHandler | ||
private val tokenRepository: TokenRepository | ||
) { | ||
suspend operator fun invoke(title: String): Pair<String?, ErrorHandler?> { | ||
return try { | ||
val accessHistory = userRepository.postABTestAssign(title) | ||
val accessHistoryId = accessHistory.accessHistoryId | ||
tokenRepository.saveAccessHistoryId(accessHistoryId) | ||
accessHistory.variableName to null | ||
} catch (t: Throwable) { | ||
null to userErrorHandler.handleVerifyUserPasswordError(t) | ||
private val mutex = Mutex() | ||
|
||
suspend operator fun invoke(title: String): Result<String> { | ||
return runCatching { | ||
mutex.withLock { | ||
if (tokenRepository.getAccessHistoryId() == null) { | ||
userRepository.updateABTestToken() | ||
} | ||
} | ||
userRepository.postABTestAssign(title).variableName | ||
} | ||
} | ||
} |
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
Oops, something went wrong.