From 8e6b5d59da65ad74c4c0ee34ee9e9d6a7aec8697 Mon Sep 17 00:00:00 2001 From: Hankyeol Choi Date: Thu, 18 Jan 2024 17:03:17 +0900 Subject: [PATCH] =?UTF-8?q?=EC=8B=9C=EA=B0=84=ED=91=9C=20api=20=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=B6=94=EA=B0=80=20(#210)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/handler/TimetableLectureHandler.kt | 8 +- .../main/kotlin/router/docs/TimetableDocs.kt | 261 +++++++++++++++++- 2 files changed, 262 insertions(+), 7 deletions(-) diff --git a/api/src/main/kotlin/handler/TimetableLectureHandler.kt b/api/src/main/kotlin/handler/TimetableLectureHandler.kt index 0091bee5..bd80d77f 100644 --- a/api/src/main/kotlin/handler/TimetableLectureHandler.kt +++ b/api/src/main/kotlin/handler/TimetableLectureHandler.kt @@ -23,7 +23,7 @@ class TimetableLectureHandler( val userId = req.userId val timetableId = req.pathVariable("timetableId") val customTimetable = req.awaitBody() - val isForced = customTimetable.isForced + val isForced = req.parseQueryParam("isForced") ?: customTimetable.isForced timetableLectureService.addCustomTimetableLecture( userId = userId, @@ -37,7 +37,7 @@ class TimetableLectureHandler( val userId = req.userId val timetableId = req.pathVariable("timetableId") val lectureId = req.pathVariable("lectureId") - val isForced = req.awaitBodyOrNull()?.isForced ?: false + val isForced = req.parseQueryParam("isForced") ?: req.awaitBodyOrNull()?.isForced ?: false timetableLectureService.addLecture( userId = userId, @@ -51,7 +51,7 @@ class TimetableLectureHandler( val userId = req.userId val timetableId = req.pathVariable("timetableId") val timetableLectureId = req.pathVariable("timetableLectureId") - val isForced = req.awaitBodyOrNull()?.isForced ?: false + val isForced = req.parseQueryParam("isForced") ?: req.awaitBodyOrNull()?.isForced ?: false timetableLectureService.resetTimetableLecture( userId = userId, @@ -66,7 +66,7 @@ class TimetableLectureHandler( val timetableId = req.pathVariable("timetableId") val timetableLectureId = req.pathVariable("timetableLectureId") val modifyRequestDto = req.awaitBody() - val isForced = modifyRequestDto.isForced + val isForced = req.parseQueryParam("isForced") ?: modifyRequestDto.isForced timetableLectureService.modifyTimetableLecture( userId = userId, diff --git a/api/src/main/kotlin/router/docs/TimetableDocs.kt b/api/src/main/kotlin/router/docs/TimetableDocs.kt index 9b6687df..5388ba8f 100644 --- a/api/src/main/kotlin/router/docs/TimetableDocs.kt +++ b/api/src/main/kotlin/router/docs/TimetableDocs.kt @@ -1,8 +1,18 @@ package com.wafflestudio.snu4t.router.docs +import com.wafflestudio.snu4t.timetables.dto.TimetableLegacyDto +import com.wafflestudio.snu4t.timetables.dto.request.CustomTimetableLectureAddLegacyRequestDto +import com.wafflestudio.snu4t.timetables.dto.request.TimetableAddRequestDto +import com.wafflestudio.snu4t.timetables.dto.request.TimetableLectureModifyLegacyRequestDto +import com.wafflestudio.snu4t.timetables.dto.request.TimetableModifyRequestDto +import com.wafflestudio.snu4t.timetables.dto.request.TimetableModifyThemeRequestDto import io.swagger.v3.oas.annotations.Operation +import io.swagger.v3.oas.annotations.Parameter +import io.swagger.v3.oas.annotations.enums.ParameterIn +import io.swagger.v3.oas.annotations.media.ArraySchema import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.media.Schema +import io.swagger.v3.oas.annotations.parameters.RequestBody import io.swagger.v3.oas.annotations.responses.ApiResponse import org.springdoc.core.annotations.RouterOperation import org.springdoc.core.annotations.RouterOperations @@ -15,14 +25,259 @@ import timetables.dto.TimetableBriefDto path = "/v1/tables", method = [RequestMethod.GET], produces = [MediaType.APPLICATION_JSON_VALUE], operation = Operation( operationId = "getBrief", - responses = [ApiResponse(responseCode = "200", content = [Content(schema = Schema(implementation = TimetableBriefDto::class))])] + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(array = ArraySchema(schema = Schema(implementation = TimetableBriefDto::class)))] + ) + ] ), ), RouterOperation( - path = "/v1/tables/{id}/primary", method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE], + path = "/v1/tables/recent", + method = [RequestMethod.GET], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "getMostRecentlyUpdatedTimetables", + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(schema = Schema(implementation = TimetableLegacyDto::class))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{year}/{semester}", + method = [RequestMethod.GET], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "getTimetablesBySemester", + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(array = ArraySchema(schema = Schema(implementation = TimetableLegacyDto::class)))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables", + method = [RequestMethod.POST], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "addTimetable", + requestBody = RequestBody(content = [Content(schema = Schema(implementation = TimetableAddRequestDto::class))]), + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(array = ArraySchema(schema = Schema(implementation = TimetableBriefDto::class)))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}", + method = [RequestMethod.GET], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "getTimetable", + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(schema = Schema(implementation = TimetableLegacyDto::class))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}", + method = [RequestMethod.PUT], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "modifyTimetable", + requestBody = RequestBody(content = [Content(schema = Schema(implementation = TimetableModifyRequestDto::class))]), + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(array = ArraySchema(schema = Schema(implementation = TimetableBriefDto::class)))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}", + method = [RequestMethod.DELETE], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "deleteTimetable", + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(array = ArraySchema(schema = Schema(implementation = TimetableBriefDto::class)))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}/copy", + method = [RequestMethod.POST], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "copyTimetable", + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(array = ArraySchema(schema = Schema(implementation = TimetableBriefDto::class)))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}/theme", + method = [RequestMethod.PUT], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "modifyTimetableTheme", + requestBody = RequestBody(content = [Content(schema = Schema(implementation = TimetableModifyThemeRequestDto::class))]), + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(schema = Schema(implementation = TimetableLegacyDto::class))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}/primary", + method = [RequestMethod.POST], + produces = [MediaType.APPLICATION_JSON_VALUE], operation = Operation( operationId = "setPrimary", - responses = [ApiResponse(responseCode = "200", content = [Content(schema = Schema(implementation = Unit::class))])] + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(schema = Schema(implementation = Unit::class))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}/primary", + method = [RequestMethod.DELETE], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "unSetPrimary", + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(schema = Schema(implementation = Unit::class))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}/lecture", + method = [RequestMethod.POST], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "addCustomLecture", + parameters = [ + Parameter( + `in` = ParameterIn.QUERY, + name = "isForced", + required = false, + description = "시간 겹치는 강의 강제로 삭제 후 실행" + ), + ], + requestBody = RequestBody(content = [Content(schema = Schema(implementation = CustomTimetableLectureAddLegacyRequestDto::class))]), + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(schema = Schema(implementation = TimetableLegacyDto::class))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}/lecture/{lectureId}", + method = [RequestMethod.POST], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "addLecture", + parameters = [ + Parameter( + `in` = ParameterIn.QUERY, + name = "isForced", + required = false, + description = "시간 겹치는 강의 강제로 삭제 후 실행" + ), + ], + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(schema = Schema(implementation = TimetableLegacyDto::class))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}/lecture/{timetableLectureId}/reset", + method = [RequestMethod.PUT], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "resetTimetableLecture", + parameters = [ + Parameter( + `in` = ParameterIn.QUERY, + name = "isForced", + required = false, + description = "시간 겹치는 강의 강제로 삭제 후 실행" + ), + ], + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(schema = Schema(implementation = TimetableLegacyDto::class))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}/lecture/{timetableLectureId}", + method = [RequestMethod.PUT], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "modifyTimetableLecture", + parameters = [ + Parameter( + `in` = ParameterIn.QUERY, + name = "isForced", + required = false, + description = "시간 겹치는 강의 강제로 삭제 후 실행" + ), + ], + requestBody = RequestBody(content = [Content(schema = Schema(implementation = TimetableLectureModifyLegacyRequestDto::class))]), + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(schema = Schema(implementation = TimetableLegacyDto::class))] + ) + ] + ), + ), + RouterOperation( + path = "/v1/tables/{timetableId}/lecture/{timetableLectureId}", + method = [RequestMethod.DELETE], + produces = [MediaType.APPLICATION_JSON_VALUE], + operation = Operation( + operationId = "deleteTimetableLecture", + responses = [ + ApiResponse( + responseCode = "200", + content = [Content(schema = Schema(implementation = TimetableLegacyDto::class))] + ) + ] ), ), )