From 0ee31097be4c72608e7ee17e2a947649a274532f Mon Sep 17 00:00:00 2001 From: xiaoyv404 Date: Sun, 12 May 2024 15:27:40 +0800 Subject: [PATCH] change web api parameter name --- .../app/webAPI/router/mincreaftServer/server.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/xiaoyv404/mirai/app/webAPI/router/mincreaftServer/server.kt b/src/main/kotlin/com/xiaoyv404/mirai/app/webAPI/router/mincreaftServer/server.kt index b1527ab..c0cb9c1 100644 --- a/src/main/kotlin/com/xiaoyv404/mirai/app/webAPI/router/mincreaftServer/server.kt +++ b/src/main/kotlin/com/xiaoyv404/mirai/app/webAPI/router/mincreaftServer/server.kt @@ -15,14 +15,14 @@ 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 @@ -30,13 +30,13 @@ fun Route.server() { call.respond(NfResult.success(data)) } - patch("/server/{n}") { + patch("/server/{id}") { val principal = call.principal() ?: 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() - data.id = n + data.id = id val changeLine = data.update() if (changeLine == 0) WebApi.requestError