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) error
- func (a *App) Query(ctx context.Context, qp QueryParams) (query.Result[Product], error)
- func (a *App) QueryByID(ctx context.Context) (Product, error)
- func (a *App) Update(ctx context.Context, 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) Decode ¶
func (app *NewProduct) Decode(data []byte) error
Decode implments the decoder interface.
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 Rows string OrderBy string ID string Name string Cost string Quantity string }
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) Decode ¶
func (app *UpdateProduct) Decode(data []byte) error
Decode implments the decoder interface.
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.