model

package
v0.0.0-...-0091320 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TransactionPending represents a pending transaction
	TransactionPending string = "pending"
	// TransactionConfirmed represents a confirmed transaction
	TransactionConfirmed string = "confirmed"
	// TransactionCompleted represents a completed transaction
	TransactionCompleted string = "completed"
	// TransactionError represents a error transaction
	TransactionError string = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Base      `valid:"required"`
	OwnerName string    `json:"owner_name" gorm:"column:owner_name;type:varchar(255);not null" valid:"notnull"`
	BankID    string    `gorm:"column:bank_id;type:uuid;not null" valid:"-"`
	Bank      *Bank     `valid:"-"`
	Number    string    `json:"number" gorm:"column:number;type:varchar(20);not null" valid:"notnull"`
	PixKeys   []*PixKey `gorm:"ForeignKey:AccountID" valid:"-"`
}

Account represents a model account

func NewAccount

func NewAccount(bank *Bank, number string, ownerName string) (*Account, error)

NewAccount return a new instance of a Account

type Bank

type Bank struct {
	Base     `valid:"required"`
	Code     string     `json:"code" gorm:"column:code;type:varchar(20);not null" valid:"notnull"`
	Name     string     `json:"name" gorm:"column:name;type:varchar(255);not null" valid:"notnull"`
	Accounts []*Account `gorm:"ForeignKey:BankID" valid:"-"`
}

Bank represents a model bank

func NewBank

func NewBank(code string, name string) (*Bank, error)

NewBank return a new instance of a Bank

type Base

type Base struct {
	ID        string    `json:"id" gorm:"column:id;type:uuid;primary_key" valid:"uuid"`
	CreatedAt time.Time `json:"created_at" gorm:"column:created_at;type:timestamp" valid:"-"`
	UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at;type:timestamp" valid:"-"`
}

Base represents base information for various models

type PixKey

type PixKey struct {
	Base      `valid:"required"`
	Kind      string   `json:"kind" gorm:"column:kind;type:varchar(20)" valid:"notnull"`
	Key       string   `json:"key" gorm:"column:key;type:varchar(255)" valid:"notnull"`
	AccountID string   `json:"account_id" gorm:"column:account_id;type:uuid;not null" valid:"notnull"`
	Account   *Account `valid:"-"`
	Status    string   `json:"status" gorm:"type:varchar(20)" valid:"notnull"`
}

PixKey represents a model pix key

func NewPixKey

func NewPixKey(kind string, account *Account, key string) (*PixKey, error)

NewPixKey return a new instance of a PixKey

type PixKeyRepositoryInterface

type PixKeyRepositoryInterface interface {
	RegisterKey(pixKey *PixKey) (*PixKey, error)
	FindKeyByKind(key string, kind string) (*PixKey, error)
	AddBank(bank *Bank) error
	AddAccount(account *Account) error
	FindAccount(id string) (*Account, error)
}

PixKeyRepositoryInterface represents a interface of all operations

type Transaction

type Transaction struct {
	Base              `valid:"required"`
	AccountFrom       *Account `valid:"-"`
	AccountFromID     string   `json:"account_from_id" gorm:"column:account_from_id;type:uuid;not null" valid:"notnull"`
	Amount            float64  `json:"amount" gorm:"column:ammount;type:float;not null" valid:"notnull"`
	PixKeyTo          *PixKey  `valid:"-"`
	PixKeyToID        string   `json:"pix_key_to_id" gorm:"column:pix_key_to_id;type:uuid;not null" valid:"notnull"`
	Status            string   `json:"status" gorm:"column:status;type:varchar(20);not null" valid:"notnull"`
	Description       string   `json:"description" gorm:"column:description;type:varchar(255)" valid:"-"`
	CancelDescription string   `json:"cancel_description" gorm:"column:cancel_description;type:varchar(255)" valid:"-"`
}

Transaction represents a model transaction

func NewTransaction

func NewTransaction(accountFrom *Account, amount float64, pixKeyTo *PixKey, description string, id string) (*Transaction, error)

NewTransaction return a new instance of a Transaction

func (*Transaction) Cancel

func (transaction *Transaction) Cancel(description string) error

Cancel cancels a transaction

func (*Transaction) Complete

func (transaction *Transaction) Complete() error

Complete completes a transaction

func (*Transaction) Confirm

func (transaction *Transaction) Confirm() error

Confirm confirm a transaction

type TransactionRepositoryInterface

type TransactionRepositoryInterface interface {
	Register(transaction *Transaction) error
	Save(transaction *Transaction) error
	Find(id string) (*Transaction, error)
}

TransactionRepositoryInterface represents a interface of all operations

type Transactions

type Transactions struct {
	Transaction []*Transaction
}

Transactions represents a list of transactions

type User

type User struct {
	Base  `valid:"required"`
	Name  string `json:"name" valid:"notnull"`
	Email string `json:"email" valid:"notnull"`
}

User represents a model user

func NewUser

func NewUser(name string, email string) (*User, error)

NewUser return a new instance of a User

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL