Skip to content

Commit 4380ea5

Browse files
authored
release: 1.2.3 (#133)
2 parents d69bdc6 + ba99902 commit 4380ea5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/main/kotlin/org/gitanimals/quiz/app/CreateQuizFacade.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class CreateQuizFacade(
142142
}
143143

144144
companion object {
145-
private const val CREATE_QUIZ_PRICE = 5_000L
145+
const val CREATE_QUIZ_PRICE = 5_000L
146146
private const val CREATE_QUIZ_SIMILARITY_CHECK_MESSAGE =
147147
"Your quiz has been successfully created, but a similar quiz has been found and is under review. The awarded points may be revoked."
148148
private const val CREATE_QUIZ_SUCCESS_MESSAGE = "Success to create quiz."

src/main/kotlin/org/gitanimals/quiz/app/DenyQuizFacade.kt

+17
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package org.gitanimals.quiz.app
22

3+
import org.gitanimals.core.IdGenerator
4+
import org.gitanimals.quiz.app.CreateQuizFacade.Companion.CREATE_QUIZ_PRICE
35
import org.gitanimals.quiz.domain.not_approved.NotApprovedQuizService
46
import org.slf4j.LoggerFactory
57
import org.springframework.beans.factory.annotation.Value
68
import org.springframework.stereotype.Service
79

810
@Service
911
class DenyQuizFacade(
12+
private val identityApi: IdentityApi,
1013
private val notApprovedQuizService: NotApprovedQuizService,
1114
@Value("\${quiz.approve.token}") private val approveToken: String,
1215
) {
@@ -20,6 +23,20 @@ class DenyQuizFacade(
2023
message
2124
}
2225

26+
val notApprovedQuiz = runCatching {
27+
notApprovedQuizService.getById(notApprovedQuizId)
28+
}.getOrElse { return }
29+
2330
notApprovedQuizService.deleteQuizById(notApprovedQuizId)
31+
32+
runCatching {
33+
identityApi.decreaseUserPointsById(
34+
userId = notApprovedQuiz.userId,
35+
point = CREATE_QUIZ_PRICE,
36+
idempotencyKey = IdGenerator.generate().toString(),
37+
)
38+
}.getOrElse {
39+
logger.error("[DenyQuizFacade] Cannot decrease point. userId: \"${notApprovedQuiz.userId}\", point: \"$CREATE_QUIZ_PRICE\"")
40+
}
2441
}
2542
}

0 commit comments

Comments
 (0)