products

package
v0.0.0-...-769f8fb Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetProduct

func GetProduct(w http.ResponseWriter, r *http.Request)

func PutProduct

func PutProduct(w http.ResponseWriter, r *http.Request)

func PutProductImage

func PutProductImage(w http.ResponseWriter, r *http.Request)

func SearchProducts

func SearchProducts(w http.ResponseWriter, r *http.Request)

Types

type Image

type Image struct {
	ID         string `json:"id" gorm:"primaryKey"`
	ProductSku string `json:"productSku" gorm:"index"`
}

type Product

type Product struct {
	Sku         string    `json:"sku" gorm:"primaryKey"`
	Name        string    `json:"name"`
	Price       float64   `json:"price"`
	Description string    `json:"description"`
	Category    string    `json:"category" gorm:"index"`
	Stock       int64     `json:"stock"`
	Images      []Image   `json:"images" gorm:"foreignKey:ProductSku"`
	CreatedAt   time.Time `json:"createdAt" gorm:"autoUpdateTime"`
	UpdatedAt   time.Time `json:"updatedAt" gorm:"autoCreateTime"`
}

func (Product) MarshalJSON

func (p Product) MarshalJSON() ([]byte, error)

type Usecases

type Usecases struct{}

func (Usecases) AddImageToProduct

func (u Usecases) AddImageToProduct(sku string, image io.ReadSeeker) (*Image, error)

func (Usecases) GetProduct

func (u Usecases) GetProduct(sku string) (*Product, error)

func (Usecases) SaveProduct

func (u Usecases) SaveProduct(product Product) (*Product, error)

func (Usecases) SearchProducts

func (u Usecases) SearchProducts(search, category string, page int) (responses.PaginatedResponse, error)

Jump to

Keyboard shortcuts

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