model

package
v0.0.0-...-1951ad6 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	bun.BaseModel `bun:"categories"                                  swaggerignore:"true"`
	ID            int        `bun:",pk,autoincrement"                           example:"1"          json:"id"`
	CreatedAt     time.Time  `bun:",nullzero,notnull,default:current_timestamp" swaggerignore:"true"`
	UpdatedAt     time.Time  `bun:",nullzero,notnull,default:current_timestamp" swaggerignore:"true"`
	DeletedAt     time.Time  `bun:",soft_delete,nullzero"                       swaggerignore:"true"`
	Name          string     `bun:",nullzero,notnull"                           example:"category1"  json:"name"`
	CategoryID    int        `bun:",nullzero,notnull"                           example:"1"          json:"category_id"`
	Products      []*Product `bun:"rel:has-many,join:id=category_id"`
}

type Client

type Client struct {
	bun.BaseModel `bun:"clients" swaggerignore:"true"`

	ID         int       `bun:",pk,autoincrement"                           json:"id"`
	CreatedAt  time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt  time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	DeletedAt  time.Time `bun:",soft_delete,nullzero"`
	Name       string    `bun:",notnull,nullzero"                           json:"name"`
	Email      string    `bun:",notnull,nullzero"                           json:"email"`
	Phone      string    `bun:",notnull,nullzero"                           json:"phone"`
	IsSupplier bool      `bun:",notnull,nullzero,default:true"              json:"is_supplier"`
	IsClient   bool      `bun:",notnull,nullzero,default:false"             json:"is_client"`
}

type Inventory

type Inventory struct {
	bun.BaseModel `bun:"inventories"                                     swaggerignore:"true"`
	ID            int                `bun:",pk,autoincrement"                               example:"1"          json:"id"`
	CreatedAt     time.Time          `bun:",nullzero,notnull,default:current_timestamp"     swaggerignore:"true"`
	UpdatedAt     time.Time          `bun:",nullzero,notnull,default:current_timestamp"     swaggerignore:"true"`
	DeletedAt     time.Time          `bun:",soft_delete,nullzero"                           swaggerignore:"true"`
	Name          string             `example:"category1"                                   json:"name"`
	Address       string             `bun:",nullzero,notnull"                               example:"address1"   json:"address"`
	Products      []Product          `bun:"m2m:inventory_to_product,join:Inventory=Product"`
	ProductStock  InventoryToProduct `bun:"rel:has-one,join:id=inventory_id"`
}

type InventoryToProduct

type InventoryToProduct struct {
	bun.BaseModel     `bun:"table:inventory_to_product" swaggerignore:"true"`
	ProductID         int        `bun:",pk"`
	Product           *Product   `bun:"rel:belongs-to,join:product_id=id"`
	InventoryID       int        `bun:",pk"`
	Inventory         *Inventory `bun:"rel:belongs-to,join:inventory_id=id"`
	Amount            int        `json:"amount"`
	SellInvoicesCount int        `json:"sell_invoices_count"`
	BuyInvoicesCount  int        `json:"buy_invoices_count"`
}

type Invoice

type Invoice struct {
	ID          int            `bun:",pk,autoincrement"                           example:"1"          json:"id"`
	CreatedAt   time.Time      `bun:",nullzero,notnull,default:current_timestamp" swaggerignore:"true"`
	UpdatedAt   time.Time      `bun:",nullzero,notnull,default:current_timestamp" swaggerignore:"true"`
	DeletedAt   time.Time      `bun:",soft_delete,nullzero"                       swaggerignore:"true"`
	IsSell      bool           `json:"is_sell"`
	TotalCost   float64        `json:"total_cost"`
	TotalPrice  float64        `json:"total_price"`
	InventoryID int            `json:"inventory_id"`
	Inventory   Inventory      `bun:"rel:belongs-to,join:inventory_id=id"`
	ClientID    int            `json:"client_id"`
	Client      Client         `bun:"rel:belongs-to,join:client_id=id"`
	UserID      int            `json:"user_id"`
	User        User           `bun:"rel:belongs-to,join:user_id=id"`
	Items       []*InvoiceItem `bun:"rel:has-many,join:id=invoice_id"`
}

type InvoiceItem

type InvoiceItem struct {
	bun.BaseModel `bun:"invoice_items"                               swaggerignore:"true"`
	ID            int       `bun:",pk,autoincrement"                           example:"1"          json:"id"`
	CreatedAt     time.Time `bun:",nullzero,notnull,default:current_timestamp" swaggerignore:"true"`
	UpdatedAt     time.Time `bun:",nullzero,notnull,default:current_timestamp" swaggerignore:"true"`
	DeletedAt     time.Time `bun:",soft_delete,nullzero"                       swaggerignore:"true"`
	UnitSellPrice float64   `json:"unit_sell_price"`
	UnitCostPrice float64   `json:"unit_cost_price"`
	Amount        float64   `json:"amount"`
	TotalCost     float64   `json:"total_cost"`
	TotalPrice    float64   `json:"total_price"`
	// UserID        int       `json:"user_id"`
	ProductID int       `json:"product_id"`
	Product   Product   `bun:"rel:belongs-to,join:product_id=id"`
	InvoiceID int       `json:"invoice_id"`
	Invoice   Inventory `bun:"rel:belongs-to,join:invoice_id=id"`
}

type Product

type Product struct {
	bun.BaseModel `bun:"products"                                        swaggerignore:"true"`
	ID            int         `bun:",pk,autoincrement"                               example:"1"                         json:"id"`
	CreatedAt     time.Time   `bun:",nullzero,notnull,default:current_timestamp"     swaggerignore:"true"`
	UpdatedAt     time.Time   `bun:",nullzero,notnull,default:current_timestamp"     swaggerignore:"true"`
	DeletedAt     time.Time   `bun:",soft_delete,nullzero"                           swaggerignore:"true"`
	Name          string      `example:"category1"                                   json:"name"`
	Code          string      `bun:",nullzero,notnull"                               example:"123"                       json:"code"`
	CostPrice     string      `bun:",nullzero,notnull"                               example:"10"                        json:"cost_price"`
	SellPrice     string      `bun:",nullzero,notnull"                               example:"100"                       json:"sell_price"`
	Image         string      `bun:",nullzero,notnull"                               example:"http://lorempicsm/100.jpg" json:"image"`
	CategoryID    int         `bun:",nullzero,notnull"                               example:"1"                         json:"category_id"`
	Category      *Category   `bun:"rel:belongs-to,join:category_id=id"`
	Inventories   []Inventory `bun:"m2m:inventory_to_product,join:Product=Inventory"`
}

type User

type User struct {
	bun.BaseModel `bun:"users" swaggerignore:"true"`

	ID        int       `bun:",pk,autoincrement"                           json:"id"`
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	DeletedAt time.Time `bun:",soft_delete,nullzero"`
	Name      string    `bun:",notnull,nullzero"                           json:"name"`
	Email     string    `bun:",notnull,nullzero"                           json:"email"`
	Phone     string    `bun:",notnull,nullzero"                           json:"phone"`
	Password  string    `bun:",notnull,nullzero"                           json:"password"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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