File tree 2 files changed +18
-1
lines changed
src/main/kotlin/org/gitanimals/quiz/app
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,7 @@ class CreateQuizFacade(
142
142
}
143
143
144
144
companion object {
145
- private const val CREATE_QUIZ_PRICE = 5_000L
145
+ const val CREATE_QUIZ_PRICE = 5_000L
146
146
private const val CREATE_QUIZ_SIMILARITY_CHECK_MESSAGE =
147
147
" Your quiz has been successfully created, but a similar quiz has been found and is under review. The awarded points may be revoked."
148
148
private const val CREATE_QUIZ_SUCCESS_MESSAGE = " Success to create quiz."
Original file line number Diff line number Diff line change 1
1
package org.gitanimals.quiz.app
2
2
3
+ import org.gitanimals.core.IdGenerator
4
+ import org.gitanimals.quiz.app.CreateQuizFacade.Companion.CREATE_QUIZ_PRICE
3
5
import org.gitanimals.quiz.domain.not_approved.NotApprovedQuizService
4
6
import org.slf4j.LoggerFactory
5
7
import org.springframework.beans.factory.annotation.Value
6
8
import org.springframework.stereotype.Service
7
9
8
10
@Service
9
11
class DenyQuizFacade (
12
+ private val identityApi : IdentityApi ,
10
13
private val notApprovedQuizService : NotApprovedQuizService ,
11
14
@Value(" \$ {quiz.approve.token}" ) private val approveToken : String ,
12
15
) {
@@ -20,6 +23,20 @@ class DenyQuizFacade(
20
23
message
21
24
}
22
25
26
+ val notApprovedQuiz = runCatching {
27
+ notApprovedQuizService.getById(notApprovedQuizId)
28
+ }.getOrElse { return }
29
+
23
30
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
+ }
24
41
}
25
42
}
You can’t perform that action at this time.
0 commit comments