File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
src/main/kotlin/org/gitanimals/quiz Expand file tree Collapse file tree 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(
1313 private val quizSolveContextRepository : QuizSolveContextRepository ,
1414) {
1515
16- // @Transactional
16+ @Transactional
1717 fun createQuizSolveContext (
1818 userId : Long ,
1919 category : Category ,
2020 quizs : List <Quiz >,
2121 ): QuizSolveContext {
2222 val now = LocalDate .ofInstant(instant(), ZoneId .of(" UTC" ))
2323 quizSolveContextRepository.findQuizSolveContextByUserIdAndSolvedAt(userId, now)?.let {
24- quizSolveContextRepository.deleteAll() // 전체삭제 QA끝나고 지운다.
25- // throw IllegalArgumentException("Already solve daily quiz.")
24+ throw IllegalArgumentException (" Already solve daily quiz." )
2625 }
2726
2827 val quizSolveContext = QuizSolveContext .of(
@@ -58,7 +57,7 @@ class QuizSolveContextService(
5857 }
5958
6059 @Transactional(readOnly = true )
61- fun findTodaySolvedContext (userId : Long ): QuizSolveContext ? {
60+ fun findTodaySolvedContext (userId : Long ): QuizSolveContext ? {
6261 val now = LocalDate .ofInstant(instant(), ZoneId .of(" UTC" ))
6362
6463 return quizSolveContextRepository.findQuizSolveContextByUserIdAndSolvedAt(userId, now)
You can’t perform that action at this time.
0 commit comments