models

package
v0.0.0-...-22617c7 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	BaseModel
	Name       string          `gorm:"size:64;not null" json:"name"`
	Balance    decimal.Decimal `gorm:"type:decimal(16, 2);default:0;not null;" json:"balance"`
	UserID     int             `gorm:"not null" json:"-"`
	User       User            `gorm:"foreignKey:UserID" json:"user"`
	CurrencyID int             `gorm:"not null" json:"-"`
	Currency   Currency        `gorm:"foreignKey:CurrencyID" json:"currency"`
}

func (Account) TableName

func (Account) TableName() string

type BaseModel

type BaseModel struct {
	ID        uint       `gorm:"primarykey" json:"id"`
	CreatedAt time.Time  `gorm:"autoCreateTime;type:timestamp;default:NOW()" json:"-"`
	UpdatedAt time.Time  `gorm:"autoUpdateTime;type:timestamp;default:NOW()" json:"-"`
	DeletedAt *time.Time `gorm:"type:timestamp;index" json:"-"`
}

type Currency

type Currency struct {
	BaseModel
	Code string `gorm:"size:5" json:"code"`
	Name string `gorm:"size:64" json:"name"`
}

func (Currency) TableName

func (Currency) TableName() string

type RevokedToken

type RevokedToken struct {
	BaseModel
	Token     string    `gorm:"unique;index;"`
	ExpiredAt time.Time `gorm:"notnull;index;"`
}

func (RevokedToken) TableName

func (RevokedToken) TableName() string

type Transaction

type Transaction struct {
	BaseModel
	Amount     decimal.Decimal     `json:"amount"`
	Type       TransactionType     `json:"transaction_type"`
	CategoryID int                 `json:"-"`
	Category   TransactionCategory `gorm:"foreignKey:CategoryID" json:"category"`
	AccountID  int                 `json:"-"`
	Account    Account             `gorm:"foreignKey:AccountID" json:"account"`
	Comment    string              `json:"comment"`
}

func (Transaction) TableName

func (Transaction) TableName() string

type TransactionCategory

type TransactionCategory struct {
	BaseModel
	UserID     int             `json:"-"`
	User       User            `gorm:"foreignKey:UserID" json:"user"`
	Name       string          `gorm:"size:64" json:"name"`
	Type       TransactionType `gorm:"type:transaction_types"`
	MonthLimit decimal.Decimal `gorm:"type:decimal(16, 2);" json:"month_limit"`
}

func (TransactionCategory) TableName

func (TransactionCategory) TableName() string

type TransactionType

type TransactionType string
const (
	Income  TransactionType = "income"
	Expense TransactionType = "expense"
)

func (*TransactionType) Scan

func (t *TransactionType) Scan(value interface{}) error

func (TransactionType) Value

func (t TransactionType) Value() (driver.Value, error)

type User

type User struct {
	BaseModel
	Email    string `gorm:"size:64;unique" json:"email"`
	Password string `gorm:"size:128" json:"-"`
}

func (User) TableName

func (User) TableName() string

Jump to

Keyboard shortcuts

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