models

package
v0.0.0-...-ffde8a0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package models contains all database models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddCustomer

type AddCustomer struct {
	Name    string `json:"name" example:"A Company Ltd." format:"string"`
	Address string `json:"address" example:"Street 1234, 01234 City, Country" format:"string"`
}

AddCustomer is a limited creation version of customer object.

func (AddCustomer) Validate

func (a AddCustomer) Validate() error

Validate whether customer creation request is correct.

type AddOrder

type AddOrder struct {
	CustomerID uuid.UUID  `json:"customer_id"`
	Items      []MenuItem `json:"items"`
}

AddOrder is a limited creation version of order object.

func (AddOrder) Validate

func (a AddOrder) Validate() error

Validate whether order creation request is correct.

type Customer

type Customer struct {
	ID      uuid.UUID `json:"id" example:"f3537d5c-cf15-48cc-b309-7a51312a574f" format:"uuid"`
	Name    string    `json:"name" example:"A Company Ltd." format:"string"`
	Address string    `json:"address" example:"Street 1234, 01234 City, Country" format:"string"`
}

Customer is a model representing customer.

func FindCustomerByID

func FindCustomerByID(id uuid.UUID) (Customer, error)

FindCustomerByID finds customer by ID and returns it.

func (*Customer) Insert

func (c *Customer) Insert() (uuid.UUID, error)

Insert newly created customer object into database.

type MenuItem struct {
	Name      string  `json:"name" example:"Food" format:"string"`
	Count     uint    `json:"count" example:"1" format:"uint"`
	UnitPrice float64 `json:"unit_price" example:"3.99" format:"float64"`
}

MenuItem is a model representing an item on the menu.

type Order

type Order struct {
	ID        uuid.UUID  `json:"id" example:"f3537d5c-cf15-48cc-b309-7a51312a574f" format:"uuid"`
	Customer  Customer   `json:"customer"`
	Items     []MenuItem `json:"items"`
	CreatedAt time.Time  `json:"created_at"`
}

Order is a model representing order.

func (*Order) Insert

func (o *Order) Insert() (uuid.UUID, error)

Insert newly created order object into database.

Jump to

Keyboard shortcuts

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