models

package
v0.0.0-...-74b6fac Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StockSelect = []string{"ID", " Name", "Quantity"}
View Source
var TokenSelect = []string{"ID", "token", "user_id", "valid_until", "comment", "active"}
View Source
var TransactionSelect = []string{"ID", "seller_id", "buyer_id", "stock_id", " Quantity", " Type", "Price", "currency", "Status"}
View Source
var UserSelect = []string{"ID", " Username", " Email", " Address", "Funds", "currency"}

Functions

func IsTransactionStatus

func IsTransactionStatus(data string) bool

func IsTransactionsType

func IsTransactionsType(data string) bool

Types

type MonetaryUnit

type MonetaryUnit struct {
	Amount   float64 `json:"amount"`
	Currency string  `json:"currency"`
}

type Stock

type Stock struct {
	gorm.Model
	ID       string `gorm:"primaryKey;autoIncrement:false;not null"`
	Name     string `gorm:"not null;unique" json:"name"`
	Quantity int    `gorm:"not null" json:"quantity"`
}

type StockToUser

type StockToUser struct {
	gorm.Model
	ID       string `gorm:"primaryKey;autoIncrement:false;not null"`
	StockID  string `gorm:"foreignkey:StockID" json:"stock_id"`
	UserID   string `gorm:"foreignkey:UserID" json:"user_id"`
	Quantity int    `gorm:"not null" json:"quantity"`
}

type Token

type Token struct {
	gorm.Model
	ID         string `gorm:"primaryKey;autoIncrement:false;not null"`
	Active     bool   `json:"active"`
	Comment    string `json:"comment"`
	UserID     string `gorm:"foreignkey:userID;not null" json:"user_id"`
	ValidUntil int64  `json:"valid_until"`
	Token      string `json:"token"`
}

type Transaction

type Transaction struct {
	gorm.Model
	ID       string  `gorm:"primaryKey;autoIncrement:false;not null"`
	SellerID string  `gorm:"foreignkey:userID" json:"seller_id"`
	BuyerID  string  `gorm:"foreignkey:userID" json:"buyer_id"`
	StockID  string  `gorm:"foreignkey:stockID;not null" json:"stock_id"`
	Quantity int     `gorm:"not null" json:"quantity"`
	Price    float64 `gorm:"not null" json:"price"`
	Currency string  `gorm:"not null" json:"currency"`
	Type     string  `gorm:"not null" json:"type"`
	Status   string  `gorm:"not null;default:PENDING" json:"status"`
	Comment  string  `gorm:"default:initiated" json:"comment"`
}

type User

type User struct {
	gorm.Model
	ID       string  `gorm:"primaryKey;autoIncrement:false;not null"`
	Username string  `gorm:"unique;not null" json:"username"`
	Password string  `gorm:"not null" json:"password"`
	Email    string  `gorm:"unique" json:"email"`
	Address  string  `json:"address"`
	Funds    float64 `gorm:"default:0" json:"funds"`
	Currency string  `gorm:"not null" json:"currency"`
}

Jump to

Keyboard shortcuts

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