Documentation ¶
Overview ¶
Package productapp maintains the app layer api for the product domain.
Index ¶
- type App
- func (a *App) Create(ctx context.Context, app NewProduct) (Product, error)
- func (a *App) Delete(ctx context.Context, productID string) error
- func (a *App) Query(ctx context.Context, qp QueryParams) (page.Document[Product], error)
- func (a *App) QueryByID(ctx context.Context, productID string) (Product, error)
- func (a *App) Update(ctx context.Context, productID string, app UpdateProduct) (Product, error)
- type NewProduct
- type Product
- type QueryParams
- type UpdateProduct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App manages the set of app layer api functions for the product domain.
func NewApp ¶
func NewApp(productBus *productbus.Business) *App
NewApp constructs a product app API for use.
type NewProduct ¶
type NewProduct struct { Name string `json:"name" validate:"required"` Cost float64 `json:"cost" validate:"required,gte=0"` Quantity int `json:"quantity" validate:"required,gte=1"` }
NewProduct defines the data needed to add a new product.
func (NewProduct) Validate ¶
func (app NewProduct) Validate() error
Validate checks the data in the model is considered clean.
type Product ¶
type Product struct { ID string `json:"id"` UserID string `json:"userID"` Name string `json:"name"` Cost float64 `json:"cost"` Quantity int `json:"quantity"` DateCreated string `json:"dateCreated"` DateUpdated string `json:"dateUpdated"` }
Product represents information about an individual product.
type QueryParams ¶
type QueryParams struct { Page string `query:"page"` Rows string `query:"rows"` OrderBy string `query:"orderBy"` ID string `query:"product_id"` Name string `query:"name"` Cost string `query:"cost"` Quantity string `query:"quantity"` }
QueryParams represents the set of possible query strings.
type UpdateProduct ¶
type UpdateProduct struct { Name *string `json:"name"` Cost *float64 `json:"cost" validate:"omitempty,gte=0"` Quantity *int `json:"quantity" validate:"omitempty,gte=1"` }
UpdateProduct defines the data needed to update a product.
func (UpdateProduct) Validate ¶
func (app UpdateProduct) Validate() error
Validate checks the data in the model is considered clean.
Click to show internal directories.
Click to hide internal directories.