From b625b3cf5e45e353b75a4cbcd3226c92a9b35f3b Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 14 Oct 2024 14:33:33 +0300 Subject: [PATCH] added models --- internal/models/ActiveVoucherModel.go | 17 +++++++++++++++ internal/models/TransactionModel.go | 21 ++++++++++++++++++ internal/models/UserModel.go | 31 +++++++++++++++++++++++++++ internal/models/VoucherModel.go | 22 +++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 internal/models/ActiveVoucherModel.go create mode 100644 internal/models/TransactionModel.go create mode 100644 internal/models/UserModel.go create mode 100644 internal/models/VoucherModel.go diff --git a/internal/models/ActiveVoucherModel.go b/internal/models/ActiveVoucherModel.go new file mode 100644 index 0000000..4eca12f --- /dev/null +++ b/internal/models/ActiveVoucherModel.go @@ -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 +} diff --git a/internal/models/TransactionModel.go b/internal/models/TransactionModel.go new file mode 100644 index 0000000..c1dcbd6 --- /dev/null +++ b/internal/models/TransactionModel.go @@ -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 +} diff --git a/internal/models/UserModel.go b/internal/models/UserModel.go new file mode 100644 index 0000000..4a375d1 --- /dev/null +++ b/internal/models/UserModel.go @@ -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 +} diff --git a/internal/models/VoucherModel.go b/internal/models/VoucherModel.go new file mode 100644 index 0000000..2878e9d --- /dev/null +++ b/internal/models/VoucherModel.go @@ -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 +}