added models

This commit is contained in:
Alfred Kamanda 2024-10-14 14:33:33 +03:00
parent 27895bf211
commit b625b3cf5e
Signed by: Alfred-mk
GPG Key ID: 7EA3D01708908703
4 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,17 @@
package models
import (
"time"
"github.com/gofrs/uuid"
"gorm.io/gorm"
)
type ActiveVoucher struct {
gorm.Model
ID uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
UserID uuid.UUID
VoucherID uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
}

View File

@ -0,0 +1,21 @@
package models
import (
"time"
"github.com/gofrs/uuid"
"gorm.io/gorm"
)
type Transaction struct {
gorm.Model
ID uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
UserID uuid.UUID
VoucherID uuid.UUID
Amount string
Sender string
Receiver string
Status string
CreatedAt time.Time
UpdatedAt time.Time
}

View File

@ -0,0 +1,31 @@
package models
import (
"time"
"github.com/gofrs/uuid"
"gorm.io/gorm"
)
type User struct {
gorm.Model
ID uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
SessionID string `gorm:"unique"`
PublicKey string
CustodialID string
TrackingID string
FirstName string
FamilyName string
Offerings string
Gender string
YOB string
Location string
Status string
AccountPIN string
TemporaryPIN string
ActiveVouchers []ActiveVoucher `gorm:"foreignKey:UserID"`
Transactions []Transaction `gorm:"foreignKey:UserID"`
Vouchers []Voucher `gorm:"foreignKey:UserID"`
CreatedAt time.Time
UpdatedAt time.Time
}

View File

@ -0,0 +1,22 @@
package models
import (
"time"
"github.com/gofrs/uuid"
"gorm.io/gorm"
)
type Voucher struct {
gorm.Model
ID uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
UserID uuid.UUID
ContractAddress string
TokenSymbol string
TokenDecimals int
Balance float64
ActiveVouchers []ActiveVoucher `gorm:"foreignKey:VoucherID"`
Transactions []Transaction `gorm:"foreignKey:VoucherID"`
CreatedAt time.Time
UpdatedAt time.Time
}