Skip to content

Commit

Permalink
feat: scheme을 application.yml에서 과닐
Browse files Browse the repository at this point in the history
  • Loading branch information
jhhong0509 committed Sep 20, 2022
2 parents b8efcc7 + 1c32af0 commit 7ded911
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ import com.xquare.v1userservice.user.spi.JwtTokenGeneratorSpi
import com.xquare.v1userservice.user.spi.PasswordEncoderSpi
import com.xquare.v1userservice.user.spi.PasswordMatcherSpi
import com.xquare.v1userservice.user.spi.PointSpi
import com.xquare.v1userservice.user.spi.SaveUserBaseApplicationCompensator
import com.xquare.v1userservice.user.spi.SaveUserBaseApplicationProcessor
import com.xquare.v1userservice.user.spi.SaveUserBaseAuthorityCompensator
import com.xquare.v1userservice.user.spi.SaveUserBaseAuthorityProcessor
import com.xquare.v1userservice.user.spi.UserRepositorySpi
import com.xquare.v1userservice.user.verificationcode.VerificationCode
import com.xquare.v1userservice.user.verificationcode.exceptions.VerificationCodeNotFoundException
import com.xquare.v1userservice.user.verificationcode.spi.VerificationCodeSpi
import com.xquare.v1userservice.utils.processAndRevertSteps
import java.time.LocalDateTime
import java.util.UUID
import kotlinx.coroutines.coroutineScope
Expand All @@ -46,6 +47,8 @@ class UserApiImpl(
private val userRepositorySpi: UserRepositorySpi,
private val createUserInPendingStateCompensator: CreateUserInPendingStateCompensator,
private val saveUserBaseAuthorityCompensator: SaveUserBaseAuthorityCompensator,
private val saveUserBaseApplicationProcessor: SaveUserBaseApplicationProcessor,
private val saveUserBaseApplicationCompensator: SaveUserBaseApplicationCompensator,
private val jwtTokenGeneratorSpi: JwtTokenGeneratorSpi,
private val refreshTokenSpi: RefreshTokenSpi,
private val authorityListSpi: AuthorityListSpi,
Expand All @@ -60,20 +63,20 @@ class UserApiImpl(
val savedUser = createUserInPendingStateProcessor.processStep(domainUser)

coroutineScope {
processAndRevertSteps(
processStep = saveUserBaseAuthorityProcessor::processStep to arrayOf(savedUser.id),
revertSteps = listOf(
createUserInPendingStateCompensator::revertStep to arrayOf(savedUser.id)
)
)

processAndRevertSteps(
processStep = saveUserBaseAuthorityProcessor::processStep to arrayOf(savedUser.id),
revertSteps = listOf(
saveUserBaseAuthorityCompensator::revertStep to arrayOf(savedUser.id),
createUserInPendingStateCompensator::revertStep to arrayOf(savedUser.id)
)
)
runCatching {
saveUserBaseAuthorityProcessor.processStep(savedUser.id)
}.onFailure {
saveUserBaseAuthorityCompensator.revertStep(savedUser.id)
createUserInPendingStateCompensator.revertStep(savedUser.id)
}

runCatching {
saveUserBaseApplicationProcessor.processStep(savedUser.id)
}.onFailure {
saveUserBaseApplicationCompensator.revertStep(savedUser.id)
saveUserBaseAuthorityCompensator.revertStep(savedUser.id)
createUserInPendingStateCompensator.revertStep(savedUser.id)
}
}

updateUserCreatedStateStepProcessor.processStep(savedUser.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import java.util.UUID

@Spi
interface SaveUserBaseAuthorityProcessor {
suspend fun processStep(userId: UUID)
suspend fun processStep(userId: UUID): Result<Unit>
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class UserRouter {
GET("/id/{userId}", userHandler::getUserByIdHandler)
GET("/account-id/{accountId}", userHandler::getUserByAccountIdHandler)
GET("/tokens/fcm", userHandler::getUserDeviceTokensHandler)
GET("/points", userHandler::getUserPointHandler)
GET("/points/{userId}", userHandler::getUserPointHandler)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class SaveUserBaseApplicationSpiImpl(
) : SaveUserBaseApplicationProcessor, SaveUserBaseApplicationCompensator {
override suspend fun processStep(userId: UUID) {
val baseApplicationRequest = buildBaseApplicationRequest(userId)

sendPostApplicationDefaultValue(baseApplicationRequest)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ class SaveUserBaseAuthoritySpiImpl(
@Value("\${service.scheme}")
private val scheme: String
) : SaveUserBaseAuthorityProcessor, SaveUserBaseAuthorityCompensator {
override suspend fun processStep(userId: UUID) {
val request = SaveUserBaseAuthorityRequest(userId)
sendSaveUserBaseAuthorityRequest(request)
override suspend fun processStep(userId: UUID): Result<Unit> {
return try {
val request = SaveUserBaseAuthorityRequest(userId)
sendSaveUserBaseAuthorityRequest(request)
Result.success(Unit)
} catch (e: Exception) {
Result.failure(e)
}
}

private suspend fun sendSaveUserBaseAuthorityRequest(saveUserBaseAuthorityRequest: SaveUserBaseAuthorityRequest) {
Expand Down

0 comments on commit 7ded911

Please sign in to comment.