diff --git a/src/main/kotlin/com/wyattjmiller/entities/Recipe.kt b/src/main/kotlin/com/wyattjmiller/entities/Recipe.kt index ef681e1..1e6f087 100644 --- a/src/main/kotlin/com/wyattjmiller/entities/Recipe.kt +++ b/src/main/kotlin/com/wyattjmiller/entities/Recipe.kt @@ -1,24 +1,25 @@ package com.wyattjmiller.entities -import com.wyattjmiller.data.Authors import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable @SerialName("Recipe") data class Recipe( - val id: Int?, - val name: String, - val desc: String, - val ingredients: String, - var createdTimestamp: String, - val author: Int, + val id: Int?, + val name: String, + val desc: String, + val ingredients: String, + var createdTimestamp: String, + val author: Int, + val deletedTimestamp: String, ) + @Serializable @SerialName("RecipeDraft") data class RecipeDraft( - val name: String, - val desc: String, - val ingredients: String, - val author: Int, + val name: String, + val desc: String, + val ingredients: String, + val author: Int, ) diff --git a/src/main/kotlin/com/wyattjmiller/routes/AuthorRoute.kt b/src/main/kotlin/com/wyattjmiller/routes/AuthorRoute.kt index 1bbc765..9f6ca31 100644 --- a/src/main/kotlin/com/wyattjmiller/routes/AuthorRoute.kt +++ b/src/main/kotlin/com/wyattjmiller/routes/AuthorRoute.kt @@ -13,20 +13,24 @@ class AuthorRoute { private val author = AuthorDao() private fun Route.getAllAuthors() { - get("/author") { - call.respond(author.getAllAuthors()) - } + get("/author") { call.respond(author.getAllAuthors()) } } private fun Route.getAuthor() { get("/author/{id?}") { - val id = call.parameters["id"]?.toInt() ?: return@get call.respond( - HttpStatusCode.BadRequest, "Missing author identifier :(" - ) + val id = + call.parameters["id"]?.toInt() + ?: return@get call.respond( + HttpStatusCode.BadRequest, + "Missing author identifier :(" + ) - val res = author.getAuthor(id) ?: return@get call.respond( - HttpStatusCode.NotFound, "No recipe found :(" - ) + val res = + author.getAuthor(id) + ?: return@get call.respond( + HttpStatusCode.NotFound, + "No recipe found :(" + ) call.respond(res) } @@ -35,7 +39,7 @@ class AuthorRoute { private fun Route.createAuthor() { post("/author") { val req = call.receive() - val res = author.createAuthor(req) + val _res = author.createAuthor(req) call.respond(HttpStatusCode.Created) } } @@ -43,16 +47,17 @@ class AuthorRoute { private fun Route.updateAuthor() { put("/author/{id?}") { val req = call.receive() - val id = call.parameters["id"]?.toIntOrNull() ?: return@put call.respond( - HttpStatusCode.BadRequest, "Missing author identifier :(" - ) + val id = + call.parameters["id"]?.toIntOrNull() + ?: return@put call.respond( + HttpStatusCode.BadRequest, + "Missing author identifier :(" + ) if (author.updateAuthor(id, req)) { call.respond(HttpStatusCode.Created) } else { - call.respond( - HttpStatusCode.NotFound, "No author found :(" - ) + call.respond(HttpStatusCode.NotFound, "No author found :(") } } } @@ -66,4 +71,5 @@ class AuthorRoute { } } } -} \ No newline at end of file +} +