models

package
v0.0.0-...-c9e3aad Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StockRole   = "stock"
	EmitentRole = "emitent"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Deal

type Deal struct {
	ID         uint  `gorm:"primaryKey,autoIncrement"`
	OwnerID    uint  `gorm:"index:idx_owner"`
	Owner      *User `gorm:"constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	SecurityID uint
	Security   *Security `gorm:"constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	Amount     uint      `gorm:"check:amount > 0"`
	Price      float64   `gorm:"check:price > 0"`
	Active     bool
	Sell       bool
}

type InventoryItem

type InventoryItem struct {
	ID         uint `gorm:"constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	SecurityID uint
	Security   Security `gorm:"constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	OwnerID    uint     `gorm:"index:idx_owner"`
	Amount     uint
}

type Security

type Security struct {
	ID   uint   `gorm:"primaryKey,autoIncrement"`
	Name string `gorm:"not null"`
}

type Session

type Session struct {
	ID         uint   `gorm:"primaryKey"`
	UserID     uint   `gorm:"not null;unique"`
	UserRole   string `gorm:"not null"`
	ValidUntil time.Time
}

type Transaction

type Transaction struct {
	ID      uint  `gorm:"primaryKey,autoIncrement"`
	Buyer   *User `gorm:"constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
	BuyerID uint

	Seller   *User `gorm:"constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
	SellerID uint

	Subject   *Deal `gorm:"constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
	SubjectID uint
	Amount    uint
}

type User

type User struct {
	ID        uint            `gorm:"primaryKey,autoIncrement"`
	LastName  string          `gorm:"not null"`
	Role      string          `gorm:"not null"`
	FirstName string          `gorm:"not null"`
	Email     string          `gorm:"index:idx_email,unique;not null"`
	Password  string          `gorm:"not null"`
	Balance   int             `gorm:"not null"`
	Deals     []Deal          `gorm:"foreignKey:OwnerID"`
	Inventory []InventoryItem `gorm:"foreignKey:OwnerID"`
}

Jump to

Keyboard shortcuts

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