gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: introduce balances (database)


From: gnunet
Subject: [libeufin] branch master updated: introduce balances (database)
Date: Thu, 28 Nov 2019 19:07:48 +0100

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 40584d1  introduce balances (database)
40584d1 is described below

commit 40584d155da002ca78073df6c7352f887ef198cf
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Nov 28 19:07:40 2019 +0100

    introduce balances (database)
---
 sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt | 21 ++++++++++++++++++---
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt   |  8 +++++++-
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index 99cd1d8..99b135b 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -97,17 +97,30 @@ fun Blob.toByteArray(): ByteArray {
 object BankCustomersTable : IntIdTable() {
     // Customer ID is the default 'id' field provided by the constructor.
     val name = varchar("name", CUSTOMER_NAME_MAX_LENGTH).primaryKey()
-    val ebicsSubscriber = reference("ebicsSubscriber", EbicsSubscribersTable)
+    val balance = reference("balance", BalanceTable)
 }
 
 class BankCustomerEntity(id: EntityID<Int>) : IntEntity(id) {
     companion object : IntEntityClass<BankCustomerEntity>(BankCustomersTable)
-
     var name by BankCustomersTable.name
-    var ebicsSubscriber by EbicsSubscriberEntity referencedOn 
BankCustomersTable.ebicsSubscriber
+    val balance by BalanceTable referencedOn BankCustomersTable.balance
+}
+
+object BalanceTable : IntIdTable() {
+    // Customer ID is the default 'id' field provided by the constructor.
+    val value = int("value")
+    val fraction = int("fraction") // from 0 to 99
+}
+
+class BalanceEntity(id: EntityID<Int>) : IntEntity(id) {
+    companion object : IntEntityClass<BankCustomerEntity>(BankCustomersTable)
+
+    var balance by BalanceTable.balance
 }
 
 
+
+
 /**
  * This table stores RSA public keys of subscribers.
  */
@@ -163,6 +176,7 @@ object EbicsSubscribersTable : IntIdTable() {
     val nextOrderID = integer("nextOrderID")
 
     val state = enumeration("state", SubscriberState::class)
+    val balance = reference("balance", BalanceTable)
 }
 
 class EbicsSubscriberEntity(id: EntityID<Int>) : IntEntity(id) {
@@ -179,6 +193,7 @@ class EbicsSubscriberEntity(id: EntityID<Int>) : 
IntEntity(id) {
     var nextOrderID by EbicsSubscribersTable.nextOrderID
 
     var state by EbicsSubscribersTable.state
+    var balance by BalanceTable referencedOn EbicsSubscribersTable.balance
 }
 
 
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 4c70c90..2d14a0f 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -110,13 +110,19 @@ fun main() {
             signaturePrivateKey = SerialBlob(pairC.private.encoded)
         }
 
-        EbicsSubscriberEntity.new {
+        val subscriber = EbicsSubscriberEntity.new {
             partnerId = "PARTNER1"
             userId = "USER1"
             systemId = null
             state = SubscriberState.NEW
             nextOrderID = 1
         }
+
+        BankCustomerEntity.new {
+            name = "Mina"
+            balance = 0
+            ebicsSubscriber = subscriber
+        }
     }
 
     val server = embeddedServer(Netty, port = 5000) {

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]