diff --git a/src/main/kotlin/routes/LibraryRoutes.kt b/src/main/kotlin/routes/LibraryRoutes.kt new file mode 100644 index 0000000..622e10d --- /dev/null +++ b/src/main/kotlin/routes/LibraryRoutes.kt @@ -0,0 +1,36 @@ +package codes.kalar.routes + +import codes.kalar.model.Library +import io.ktor.server.application.* +import io.ktor.server.request.* +import io.ktor.server.response.* +import io.ktor.server.routing.* +import java.sql.Connection + +fun Application.configureLibraryRoutes(dbConnection: Connection) { + + routing { + get("/libraries") { + call.respondText("Libraries are neat!") + } + + get("/libraries/{libraryId}/items/{itemId}") { + call.respondText("You asked for ${call.parameters["itemId"]} from ${call.parameters["libraryId"]}") + } + + post("/libraries") { + val library = call.receive() + call.respondText("${library.name} is posted") + } + + patch("/libraries") { + val library = call.receive() + call.respondText("${library.name} is patched") + } + + delete("/libraries") { + call.respondText("We hate to see you go!") + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/routes/PatronRoutes.kt b/src/main/kotlin/routes/PatronRoutes.kt new file mode 100644 index 0000000..c0f95cb --- /dev/null +++ b/src/main/kotlin/routes/PatronRoutes.kt @@ -0,0 +1,41 @@ +package codes.kalar.routes + +import codes.kalar.model.Patron +import io.ktor.http.* +import io.ktor.server.application.* +import io.ktor.server.request.* +import io.ktor.server.response.* +import io.ktor.server.routing.* +import java.sql.Connection + +fun Application.configurePatronRoutes(dbConnection: Connection) { + + routing { + get("/patron") { + if (call.request.queryParameters["patron"] == null) { + call.respond(HttpStatusCode.BadRequest, "Invalid parameters") + } + else { + call.respondText("Hello, ${call.request.queryParameters["patron"]}") + } + } + + post("/patron") { + val patron = call.receive() + call.respondText("${patron.name} is posted") + } + + patch("/patron") { + val patron = call.receive() + call.respondText("${patron.name} is patched") + } + + delete("/patron") { + if (call.request.queryParameters["id"] == null) { + call.respond(HttpStatusCode.BadRequest, "Invalid parameters") + } else { + call.respondText("Do you have permissions?") + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/routes/StaffRoutes.kt b/src/main/kotlin/routes/StaffRoutes.kt new file mode 100644 index 0000000..d3a28ba --- /dev/null +++ b/src/main/kotlin/routes/StaffRoutes.kt @@ -0,0 +1,31 @@ +package codes.kalar.routes + +import io.ktor.server.application.* +import io.ktor.server.response.* +import io.ktor.server.routing.* +import java.sql.Connection + +fun Application.configureStaffRoutes(dbConnection: Connection) { + + routing { + get("/staff") { + call.respondText("You better have sent a body") + } + + get("/staff/{id}") { + call.respondText(call.parameters["id"]!!) + } + + post("/staff") { + + } + + patch("/staff") { + + } + + delete("/staff/{id}") { + + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/service/LibraryService.kt b/src/main/kotlin/service/LibraryService.kt new file mode 100644 index 0000000..cef250f --- /dev/null +++ b/src/main/kotlin/service/LibraryService.kt @@ -0,0 +1,26 @@ +package codes.kalar.service + +import codes.kalar.exception.DbElementInsertionException +import codes.kalar.exception.DbElementNotFoundException +import kotlinx.serialization.json.Json +import java.sql.* + +class LibraryService(private val connection: Connection) { + + companion object { + private const val SELECT_LIBRARY_BY_ID = "" + private const val INSERT_LIBRARY = "" + private const val UPDATE_LIBRARY_BY_ID = "" + // In the event are "deleted" erroneously, having a flag set instead of actually removing the entry allows + // for quick reversal. + private const val ARCHIVE_LIBRARY_BY_ID = "" + } + + suspend fun create() {} + + suspend fun read() {} + + suspend fun update() {} + + suspend fun delete() {} +} diff --git a/src/main/kotlin/service/PartonService.kt b/src/main/kotlin/service/PartonService.kt new file mode 100644 index 0000000..6f7eafb --- /dev/null +++ b/src/main/kotlin/service/PartonService.kt @@ -0,0 +1,26 @@ +package codes.kalar.service + +import codes.kalar.exception.DbElementInsertionException +import codes.kalar.exception.DbElementNotFoundException +import kotlinx.serialization.json.Json +import java.sql.* + +class PartonService(private val connection: Connection) { + + companion object { + private const val SELECT_PATRON_BY_ = "" + private const val INSERT_PATRON = "" + private const val UPDATE_PATRON_BY_ID = "" + // In the event are "deleted" erroneously, having a flag set instead of actually removing the entry allows + // for quick reversal. + private const val ARCHIVE_PATRON_BY_ID = "" + } + + suspend fun create() {} + + suspend fun read() {} + + suspend fun update() {} + + suspend fun delete() {} +} diff --git a/src/main/kotlin/service/StaffService.kt b/src/main/kotlin/service/StaffService.kt new file mode 100644 index 0000000..cdf7416 --- /dev/null +++ b/src/main/kotlin/service/StaffService.kt @@ -0,0 +1,26 @@ +package codes.kalar.service + +import codes.kalar.exception.DbElementInsertionException +import codes.kalar.exception.DbElementNotFoundException +import kotlinx.serialization.json.Json +import java.sql.Connection + +class StaffService(private val connection: Connection) { + + companion object { + private const val SELECT_STAFF_BY_ID = "" + private const val INSERT_STAFF = "" + private const val UPDATE_STAFF_BY_ID = "" + // In the event are "deleted" erroneously, having a flag set instead of actually removing the entry allows + // for quick reversal. + private const val ARCHIVE_STAFF_BY_ID = "" + } + + suspend fun create() {} + + suspend fun read() {} + + suspend fun update() {} + + suspend fun delete() {} +} \ No newline at end of file