Skip to content

Commit

Permalink
시간표 api 문서 추가 (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hank-Choi authored Jan 18, 2024
1 parent 44c380a commit 8e6b5d5
Show file tree
Hide file tree
Showing 2 changed files with 262 additions and 7 deletions.
8 changes: 4 additions & 4 deletions api/src/main/kotlin/handler/TimetableLectureHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TimetableLectureHandler(
val userId = req.userId
val timetableId = req.pathVariable("timetableId")
val customTimetable = req.awaitBody<CustomTimetableLectureAddLegacyRequestDto>()
val isForced = customTimetable.isForced
val isForced = req.parseQueryParam<Boolean>("isForced") ?: customTimetable.isForced

timetableLectureService.addCustomTimetableLecture(
userId = userId,
Expand All @@ -37,7 +37,7 @@ class TimetableLectureHandler(
val userId = req.userId
val timetableId = req.pathVariable("timetableId")
val lectureId = req.pathVariable("lectureId")
val isForced = req.awaitBodyOrNull<ForcedReq>()?.isForced ?: false
val isForced = req.parseQueryParam<Boolean>("isForced") ?: req.awaitBodyOrNull<ForcedReq>()?.isForced ?: false

timetableLectureService.addLecture(
userId = userId,
Expand All @@ -51,7 +51,7 @@ class TimetableLectureHandler(
val userId = req.userId
val timetableId = req.pathVariable("timetableId")
val timetableLectureId = req.pathVariable("timetableLectureId")
val isForced = req.awaitBodyOrNull<ForcedReq>()?.isForced ?: false
val isForced = req.parseQueryParam<Boolean>("isForced") ?: req.awaitBodyOrNull<ForcedReq>()?.isForced ?: false

timetableLectureService.resetTimetableLecture(
userId = userId,
Expand All @@ -66,7 +66,7 @@ class TimetableLectureHandler(
val timetableId = req.pathVariable("timetableId")
val timetableLectureId = req.pathVariable("timetableLectureId")
val modifyRequestDto = req.awaitBody<TimetableLectureModifyLegacyRequestDto>()
val isForced = modifyRequestDto.isForced
val isForced = req.parseQueryParam<Boolean>("isForced") ?: modifyRequestDto.isForced

timetableLectureService.modifyTimetableLecture(
userId = userId,
Expand Down
261 changes: 258 additions & 3 deletions api/src/main/kotlin/router/docs/TimetableDocs.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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))]
)
]
),
),
)
Expand Down

0 comments on commit 8e6b5d5

Please sign in to comment.