Skip to content

Commit 07a1bbd

Browse files
authored
release: 1.8.9 (#204)
2 parents 68c4bc9 + 8959720 commit 07a1bbd

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/main/kotlin/org/gitanimals/quiz/controller/QuizQaController.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package org.gitanimals.quiz.controller
22

3+
import org.gitanimals.core.instant
4+
import org.gitanimals.quiz.domain.context.QuizSolveContext
35
import org.gitanimals.quiz.domain.context.QuizSolveContextRepository
46
import org.springframework.beans.factory.annotation.Value
57
import org.springframework.web.bind.annotation.DeleteMapping
68
import org.springframework.web.bind.annotation.RequestHeader
9+
import org.springframework.web.bind.annotation.RequestParam
710
import org.springframework.web.bind.annotation.RestController
11+
import java.time.LocalDate
12+
import java.time.ZoneId
813

914
@RestController
1015
class QuizQaController(
@@ -14,10 +19,16 @@ class QuizQaController(
1419

1520
@DeleteMapping("/quizs/qa/context")
1621
fun deleteQuizContext(
22+
@RequestParam("user-id") userId: Long,
1723
@RequestHeader("Test-Secret") testSecret: String
1824
) {
1925
require(testSecret == this.testSecret) { "Not matched testSecret" }
2026

21-
quizSolveContextRepository.deleteAll()
27+
val now = LocalDate.ofInstant(instant(), ZoneId.of("Asia/Seoul"))
28+
val quizSolveContext: QuizSolveContext? = quizSolveContextRepository.findQuizSolveContextByUserIdAndSolvedAt(userId, now)
29+
30+
quizSolveContext?.let {
31+
quizSolveContextRepository.deleteById(it.id)
32+
}
2233
}
2334
}

src/main/kotlin/org/gitanimals/quiz/domain/context/QuizSolveContext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class QuizSolveContext(
9696
}
9797

9898
fun stopSolve() {
99-
check(this.status == QuizSolveContextStatus.SUCCESS) {
99+
require(this.status == QuizSolveContextStatus.SUCCESS) {
100100
"Stop quiz is only available in \"SUCCESS\" status."
101101
}
102102

0 commit comments

Comments
 (0)