File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
src/main/kotlin/org/gitanimals/quiz Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 11package org.gitanimals.quiz.controller
22
3+ import org.gitanimals.core.instant
4+ import org.gitanimals.quiz.domain.context.QuizSolveContext
35import org.gitanimals.quiz.domain.context.QuizSolveContextRepository
46import org.springframework.beans.factory.annotation.Value
57import org.springframework.web.bind.annotation.DeleteMapping
68import org.springframework.web.bind.annotation.RequestHeader
9+ import org.springframework.web.bind.annotation.RequestParam
710import org.springframework.web.bind.annotation.RestController
11+ import java.time.LocalDate
12+ import java.time.ZoneId
813
914@RestController
1015class 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}
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments