From 583d0cf48476049d551401e352dd669f3f787a89 Mon Sep 17 00:00:00 2001 From: devxb Date: Sun, 20 Oct 2024 12:33:09 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Halloween=20pet=EC=9D=84=20=EC=A7=80?= =?UTF-8?q?=EA=B8=89=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/org/gitanimals/render/domain/UserService.kt | 2 +- .../org/gitanimals/render/saga/UsedCouponSagaHandlers.kt | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt index 5b69185..444f3a9 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt @@ -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) diff --git a/src/main/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlers.kt b/src/main/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlers.kt index 3f3e407..c62027e 100644 --- a/src/main/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlers.kt +++ b/src/main/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlers.kt @@ -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") } }