File tree Expand file tree Collapse file tree
src/main/kotlin/org/gitanimals/quiz/app Expand file tree Collapse file tree Original file line number Diff line number Diff 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."
Original file line number Diff line number Diff line change 11package org.gitanimals.quiz.app
22
3+ import org.gitanimals.core.IdGenerator
4+ import org.gitanimals.quiz.app.CreateQuizFacade.Companion.CREATE_QUIZ_PRICE
35import org.gitanimals.quiz.domain.not_approved.NotApprovedQuizService
46import org.slf4j.LoggerFactory
57import org.springframework.beans.factory.annotation.Value
68import org.springframework.stereotype.Service
79
810@Service
911class 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}
You can’t perform that action at this time.
0 commit comments