[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libeufin] branch master updated: return ID upon successful
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libeufin] branch master updated: return ID upon successful user creation |
Date: |
Thu, 26 Sep 2019 19:14:02 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new e3024eb return ID upon successful user creation
e3024eb is described below
commit e3024eb76bc43feee3122a1ae95a5bfce2124183
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Sep 26 19:13:44 2019 +0200
return ID upon successful user creation
---
src/main/kotlin/Main.kt | 19 +++++++++++++------
src/main/kotlin/tech/libeufin/JSON.kt | 6 +++++-
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index 39d8458..6aa657a 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -35,6 +35,7 @@ import javax.xml.bind.JAXBElement
import io.ktor.features.*
import io.netty.handler.codec.http.HttpContent
import org.jetbrains.exposed.sql.insert
+import org.jetbrains.exposed.sql.insertAndGetId
import org.jetbrains.exposed.sql.transactions.transaction
import tech.libeufin.tech.libeufin.BankCustomers
import tech.libeufin.tech.libeufin.createSubscriber
@@ -64,18 +65,20 @@ fun main() {
}
post("/admin/customers") {
-
- // parse JSON
+ var returnId: Int = -1
try {
- val body = call.receive<Customer>()
+
+ val body = call.receive<CustomerRequest>()
logger.info(body.toString())
- logger.info("name:: ->> " + body.name)
+
transaction {
- BankCustomers.insert {
+ val newId = BankCustomers.insertAndGetId {
it[name] = body.name
it[ebicsSubscriber] = createSubscriber().id
}
+
+ returnId = newId.value
}
} catch (e: Exception) {
@@ -87,7 +90,11 @@ fun main() {
return@post
}
- call.respondText { "Successful user creation!\n" }
+ call.respond(
+ HttpStatusCode.OK,
+ CustomerResponse(id=returnId)
+ )
+
return@post
}
diff --git a/src/main/kotlin/tech/libeufin/JSON.kt
b/src/main/kotlin/tech/libeufin/JSON.kt
index d2b669f..ba4c964 100644
--- a/src/main/kotlin/tech/libeufin/JSON.kt
+++ b/src/main/kotlin/tech/libeufin/JSON.kt
@@ -11,10 +11,14 @@ data class SandboxError (
/**
* Request for POST /admin/customers
*/
-data class Customer (
+data class CustomerRequest (
val name: String
)
+data class CustomerResponse (
+ val id: Int
+)
+
/**
* Response for GET /admin/customers/:id
*/
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [libeufin] branch master updated: return ID upon successful user creation,
gnunet <=