@@ -7,6 +7,8 @@ import com.wafflestudio.snutt.clientconfig.service.ClientConfigService
77import com.wafflestudio.snutt.common.dto.OkResponse
88import com.wafflestudio.snutt.common.storage.StorageService
99import com.wafflestudio.snutt.common.storage.StorageSource
10+ import com.wafflestudio.snutt.diary.dto.request.DiaryAddQuestionRequestDto
11+ import com.wafflestudio.snutt.diary.service.DiaryService
1012import com.wafflestudio.snutt.middleware.SnuttRestAdminApiMiddleware
1113import com.wafflestudio.snutt.notification.service.NotificationAdminService
1214import com.wafflestudio.snutt.popup.dto.PopupResponse
@@ -24,6 +26,7 @@ class AdminHandler(
2426 private val configService : ClientConfigService ,
2527 private val storageService : StorageService ,
2628 private val popupService : PopupService ,
29+ private val diaryService : DiaryService ,
2730 snuttRestAdminApiMiddleware : SnuttRestAdminApiMiddleware ,
2831) : ServiceHandler(snuttRestAdminApiMiddleware) {
2932 suspend fun insertNotification (req : ServerRequest ) =
@@ -90,4 +93,46 @@ class AdminHandler(
9093
9194 popupService.deletePopup(popupId)
9295 }
96+
97+ suspend fun getDiaryQuestions (req : ServerRequest ) =
98+ handle(req) {
99+ diaryService.getActiveQuestions()
100+ }
101+
102+ suspend fun insertDiaryQuestion (req : ServerRequest ) =
103+ handle(req) {
104+ val body = req.awaitBody<DiaryAddQuestionRequestDto >()
105+
106+ diaryService.addQuestion(body)
107+ OkResponse ()
108+ }
109+
110+ suspend fun removeDiaryQuestion (req : ServerRequest ) =
111+ handle(req) {
112+ val questionId = req.pathVariable(" id" )
113+
114+ diaryService.removeQuestion(questionId)
115+ OkResponse ()
116+ }
117+
118+ suspend fun getAllDiaryActivities (req : ServerRequest ) =
119+ handle(req) {
120+ diaryService.getAllActivities()
121+ }
122+
123+ suspend fun insertDiaryActivity (req : ServerRequest ) =
124+ handle(req) {
125+ val name = req.parseRequiredQueryParam<String >(" name" )
126+
127+ diaryService.addOrEnableActivity(name)
128+ OkResponse ()
129+ }
130+
131+ suspend fun removeDiaryActivity (req : ServerRequest ) =
132+ handle(req) {
133+ val name = req.parseRequiredQueryParam<String >(" name" )
134+
135+ diaryService.disableActivity(name)
136+ OkResponse ()
137+ }
93138}
0 commit comments