models

package
v0.0.0-...-1a41d03 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateProduct

func CreateProduct(p Product) bool

func DeleteProduct

func DeleteProduct(id string)

func UpdateProduct

func UpdateProduct(id string, toUpdate map[string]interface{}) bool

Types

type Cart

type Cart struct {
	Items      map[string]CartItem `json:"items"`
	TotalPrice float64             `json:"total_price"`
}

func ToCart

func ToCart(cartMap map[string]int) Cart

type CartItem

type CartItem struct {
	ID     primitive.ObjectID `json:"_id,omitempty"`
	Name   string             `json:"name"`
	Price  float64            `json:"price"`
	Amount int                `josn:"amount"`
}

type Product

type Product struct {
	ID          primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	Name        string             `json:"name" bson:"name"`
	Price       float64            `json:"price" bson:"price"`
	Amount      float64            `json:"amount" bson:"amount"`
	Description string             `json:"description,omitempty" bson:"description"`
}

func GetAllProducts

func GetAllProducts() []Product

func (*Product) Update

func (p *Product) Update(toUpdate map[string]interface{})

type Reservation

type Reservation struct {
	// ID        primitive.ObjectID `json:"_id,omitempty"` // TODO: change to ObjectID ???
	ID        string         `json:"id,omitempty"`
	Dates     []time.Time    `json:"dates"`
	Timestamp time.Time      `json:"timestamp,omitempty"` // TODO: get from http request?
	Email     string         `json:"email"`
	Items     map[string]int `json:"items"`
}

type ReservationManager

type ReservationManager struct {
	ReservedItems map[time.Time]map[string]int
	Reservations  map[string]Reservation
}

func NewReservationManager

func NewReservationManager() *ReservationManager

func (ReservationManager) CreateReservation

func (rm ReservationManager) CreateReservation(r Reservation) bool

func (ReservationManager) DeleteReservation

func (rm ReservationManager) DeleteReservation(id string)

type Result

type Result struct {
	P  *Product
	OK bool
}

func GetProduct

func GetProduct(id string) Result

Jump to

Keyboard shortcuts

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