Skip to content

Commit

Permalink
change web api parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyv404 committed May 12, 2024
1 parent 36f8876 commit 0ee3109
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ import io.ktor.server.response.*
import io.ktor.server.routing.*

fun Route.server() {
get("/server/{n}") {
val n = call.parameters["n"] ?: error(WebApi.requestError)
if (n == "all") {
get("/server/{id}") {
val id = call.parameters["id"] ?: error(WebApi.requestError)
if (id == "all") {
val map = getAll().map { it.apiModel() }
call.respond(NfResult.success(map))
return@get
}
val serverID = n.toIntOrNull() ?: error(WebApi.requestError)
val serverID = id.toIntOrNull() ?: error(WebApi.requestError)

val data = MinecraftServer {
this.id = serverID
}.findById()?.apiModel()

call.respond(NfResult.success(data))
}
patch("/server/{n}") {
patch("/server/{id}") {
val principal = call.principal<UserIdPrincipal>() ?: error(WebApi.noPrincipal)
val n = call.parameters["n"]?.toIntOrNull() ?: error(WebApi.requestError)
val id = call.parameters["id"]?.toIntOrNull() ?: error(WebApi.requestError)
principal.name.permissionRequiredAdmin()

val data = call.receive<MinecraftServer>()
data.id = n
data.id = id
val changeLine = data.update()
if (changeLine == 0)
WebApi.requestError
Expand Down

0 comments on commit 0ee3109

Please sign in to comment.