model

package
v0.0.0-...-18aef32 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 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 Inventory

type Inventory struct {
	ID           uuid.UUID `json:"id" db:"entity_id" validate:"min=36,max=36"`
	ProductID    uuid.UUID `json:"productId" db:"product_entity_id" validate:"min=36,max=36"`
	QtyInStore   int       `json:"qtyInStore" db:"qty_in_store" validate:"min=0"`
	QtyReserved  int       `json:"qtyReserved" db:"qty_reserved" validate:"min=0"`
	QtyAvailable int       `json:"qtyAvailable" db:"qty_available" validate:"min=0"`
}

Inventory represents an Inventory object

func (*Inventory) Reserve

func (i *Inventory) Reserve(qty int) error

Reserve reserves the specified amount of inventory

func (*Inventory) Validate

func (i *Inventory) Validate() error

Validate validates the Inventory object

type Order

type Order struct {
	ID         uuid.UUID   `json:"id" db:"entity_id" validate:"min=36,max=36"`
	Code       string      `json:"code" db:"order_code"`
	TotalPrice float64     `json:"totalPrice" db:"total_price" validate:"min=0"`
	Status     string      `json:"status" db:"status"`
	Items      []OrderItem `json:"items" db:"-"`
}

Order represents an Order entity

func (*Order) AttachItems

func (o *Order) AttachItems(items []OrderItem) Order

AttachItems attaches Order Items to an Order

func (*Order) Process

func (o *Order) Process() error

Process updates an Order's status to processing

type OrderItem

type OrderItem struct {
	ID        uuid.UUID `json:"id" db:"entity_id" validate:"min=36,max=36"`
	OrderID   uuid.UUID `json:"orderId" db:"order_entity_id" validate:"min=36,max=36"`
	ProductID uuid.UUID `json:"productId" db:"product_entity_id" validate:"min=36,max=36"`
	Qty       int       `json:"qty" db:"qty" validate:"min=1"`
	Price     float64   `json:"price" db:"price"`
}

OrderItem represents an Order Item entity

type OrderProcessInput

type OrderProcessInput struct {
	OrderID uuid.UUID `json:"orderId"`
}

OrderProcessInput represents an input where the user wants to process an Order

Jump to

Keyboard shortcuts

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