File tree 2 files changed +26
-4
lines changed
src/main/kotlin/org/gitanimals/quiz
2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change
1
+ package org.gitanimals.quiz.controller
2
+
3
+ import org.gitanimals.quiz.domain.context.QuizSolveContextRepository
4
+ import org.springframework.beans.factory.annotation.Value
5
+ import org.springframework.web.bind.annotation.DeleteMapping
6
+ import org.springframework.web.bind.annotation.RequestHeader
7
+ import org.springframework.web.bind.annotation.RestController
8
+
9
+ @RestController
10
+ class QuizQaController (
11
+ private val quizSolveContextRepository : QuizSolveContextRepository ,
12
+ @Value(" \$ {test.secret}" ) private val testSecret : String ,
13
+ ) {
14
+
15
+ @DeleteMapping(" /quizs/qa/context" )
16
+ fun deleteQuizContext (
17
+ @RequestHeader(" Test-Secret" ) testSecret : String
18
+ ) {
19
+ require(testSecret == this .testSecret) { " Not matched testSecret" }
20
+
21
+ quizSolveContextRepository.deleteAll()
22
+ }
23
+ }
Original file line number Diff line number Diff line change @@ -13,16 +13,15 @@ class QuizSolveContextService(
13
13
private val quizSolveContextRepository : QuizSolveContextRepository ,
14
14
) {
15
15
16
- // @Transactional
16
+ @Transactional
17
17
fun createQuizSolveContext (
18
18
userId : Long ,
19
19
category : Category ,
20
20
quizs : List <Quiz >,
21
21
): QuizSolveContext {
22
22
val now = LocalDate .ofInstant(instant(), ZoneId .of(" UTC" ))
23
23
quizSolveContextRepository.findQuizSolveContextByUserIdAndSolvedAt(userId, now)?.let {
24
- quizSolveContextRepository.deleteAll() // 전체삭제 QA끝나고 지운다.
25
- // throw IllegalArgumentException("Already solve daily quiz.")
24
+ throw IllegalArgumentException (" Already solve daily quiz." )
26
25
}
27
26
28
27
val quizSolveContext = QuizSolveContext .of(
@@ -58,7 +57,7 @@ class QuizSolveContextService(
58
57
}
59
58
60
59
@Transactional(readOnly = true )
61
- fun findTodaySolvedContext (userId : Long ): QuizSolveContext ? {
60
+ fun findTodaySolvedContext (userId : Long ): QuizSolveContext ? {
62
61
val now = LocalDate .ofInstant(instant(), ZoneId .of(" UTC" ))
63
62
64
63
return quizSolveContextRepository.findQuizSolveContextByUserIdAndSolvedAt(userId, now)
You can’t perform that action at this time.
0 commit comments