Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles shop endpoints.
func NewHandler ¶
NewHandler returns a new shop handler.
func (*Handler) Create ¶
func (h *Handler) Create() http.HandlerFunc
Create creates a new shop and saves it.
func (*Handler) GetByID ¶
func (h *Handler) GetByID() http.HandlerFunc
GetByID lists the shop with the id requested.
func (*Handler) Search ¶
func (h *Handler) Search() http.HandlerFunc
Search looks for the products with the given value.
func (*Handler) Update ¶
func (h *Handler) Update() http.HandlerFunc
Update updates the shop with the given id.
type Location ¶
type Location struct {
ShopID string `json:"shop_id,omitempty" db:"shop_id"`
Country string `json:"country,omitempty" validate:"required"`
State string `json:"state,omitempty"`
ZipCode string `json:"zip_code,omitempty" db:"zip_code"`
City string `json:"city,omitempty" validate:"required"`
Address string `json:"address,omitempty" validate:"required"`
}
Location of the shop.
type Service ¶
type Service interface {
Create(ctx context.Context, shop Shop) error
Delete(ctx context.Context, id string) error
Get(ctx context.Context, params params.Query) ([]Shop, error)
GetByID(ctx context.Context, id string) (Shop, error)
Search(ctx context.Context, query string) ([]Shop, error)
Update(ctx context.Context, id string, shop UpdateShop) error
}
Service provides shop operations.
type Shop ¶
type Shop struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty" validate:"required"`
Location Location `json:"location,omitempty"`
Reviews []review.Review `json:"reviews,omitempty"`
Products []product.Product `json:"products,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"`
UpdatedAt zero.Time `json:"updated_at,omitempty" db:"updated_at"`
}
Shop represents a market with its name and location. Each shop has multiple reviews and products.
type UpdateShop ¶
type UpdateShop struct {
Name string `json:"name,omitempty" validate:"required"`
}
UpdateShop is the structure used to update shops.
Click to show internal directories.
Click to hide internal directories.