Skip to content

Commit

Permalink
feat: Halloween pet을 지급할 수 있도록 수정한다
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb committed Oct 20, 2024
1 parent 473f842 commit 583d0cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class UserService(

@Retryable(retryFor = [ObjectOptimisticLockingFailureException::class], maxAttempts = 100)
@Transactional
fun giveBonusPersona(name: String, persona: String) {
fun givePersonaByCoupon(name: String, persona: String) {
requireIdempotency("$name:bonus")

val user = getUserByName(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ class UsedCouponSagaHandlers(
@SagaCommitListener(event = CouponUsed::class)
fun handleCouponUsedCommitEvent(sagaCommitEvent: SagaCommitEvent) {
val couponUsed = sagaCommitEvent.decodeEvent(CouponUsed::class)
if (couponUsed.code != "NEW_USER_BONUS_PET") {
if ((couponUsed.code in acceptableCouponCodes).not()) {
return
}
sagaCommitEvent.setNextEvent(couponUsed)

userService.giveBonusPersona(couponUsed.username, couponUsed.dynamic)
userService.givePersonaByCoupon(couponUsed.username, couponUsed.dynamic)
}

private companion object {
private val acceptableCouponCodes = listOf("NEW_USER_BONUS_PET", "HALLOWEEN_2024", "HALLOWEEN_2024_STAR_BONUS")
}
}

0 comments on commit 583d0cf

Please sign in to comment.