model

package
v0.0.0-...-8a957f7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TransactionPeding    string = "pending"
	TransactionCompleted string = "completed"
	TransactionError     string = "error"
	TransactionConfirmed string = "comfirmed"
	TransactionCanceled  string = "canceled"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

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

func NewAccount

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

type Bank

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

func NewBank

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

type Base

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

type PixKey

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

func NewPixKey

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

type PixKeyRepository

type PixKeyRepository 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)
}

type Transaction

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

func NewTransaction

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

func (*Transaction) Cancel

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

func (*Transaction) Complete

func (transaction *Transaction) Complete() error

func (*Transaction) Confirm

func (transaction *Transaction) Confirm() error

type TransactionRepository

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

type Transactions

type Transactions struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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