model

package
v0.0.0-...-86c91f4 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Product

type Product struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Price int    `json:"price"`
	Color string `json:"color"`
	Size  string `json:"size"`
}

Product model

func (*Product) IsValid

func (p *Product) IsValid() bool

IsValid checks whether a product is valid

type ProductCreated

type ProductCreated struct {
	ID int `json:"id"`
}

ProductCreated model

type ProductDAO

type ProductDAO struct {
	// contains filtered or unexported fields
}

ProductDAO access to product data

func (*ProductDAO) AddProduct

func (dao *ProductDAO) AddProduct(p *Product)

AddProduct adds a product

func (*ProductDAO) DeleteProduct

func (dao *ProductDAO) DeleteProduct(id int) (bool, *ProductError)

DeleteProduct deletes a product

func (*ProductDAO) FindProduct

func (dao *ProductDAO) FindProduct(id int) (*Product, *ProductError)

FindProduct finds a product by id

func (*ProductDAO) GetProducts

func (dao *ProductDAO) GetProducts(offset int, limit int) (*ProductPage, *ProductError)

GetProducts obtains products in batches

func (*ProductDAO) UpdateProduct

func (dao *ProductDAO) UpdateProduct(id int, p *Product) (bool, *ProductError)

UpdateProduct updates a product

type ProductError

type ProductError struct {
	Code    int
	Message string
}

ProductError model

func (*ProductError) Error

func (err *ProductError) Error() string

type ProductPage

type ProductPage struct {
	Products   []Product `json:"products"`
	TotalCount int       `json:"totalCount"`
}

ProductPage model

Jump to

Keyboard shortcuts

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