Documentation
¶
Index ¶
- Variables
- func IsValidOrderStatus(status OrderStatus) bool
- func ValidateAddress(address *Address) error
- func ValidateComment(comment *Comment, exists bool) error
- func ValidateImage(image *Image, exists bool) error
- func ValidateInvoice(invoice *Invoice, exists bool) error
- func ValidateItem(item *Item, exists bool) error
- func ValidateOrder(order *Order, exists bool) error
- func ValidatePrice(price *Price) error
- func ValidateProduct(product *Product, exists bool) error
- func ValidateRating(rating *Rating) error
- func ValidateUser(user *User, exists bool) error
- type Address
- type Comment
- type Currency
- type Image
- type Invoice
- type Item
- type NullBoolJSON
- type NullFloat64JSON
- type NullInt64JSON
- type NullStringJSON
- type Order
- type OrderStatus
- type Price
- type Product
- type ProductCategory
- type Rating
- type User
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ProductCategories = map[ProductCategory]string{ Home: "Home", Clothing: "Clothing", Shoes: "Shoes", Sport: "Sport", Appliances: "Appliances", Technology: "Technology", Entertainment: "Entertainment", Books: "Books", Cars: "Cars", } )
Functions ¶
func IsValidOrderStatus ¶
func IsValidOrderStatus(status OrderStatus) bool
func ValidateAddress ¶
func ValidateComment ¶
func ValidateImage ¶
func ValidateInvoice ¶
func ValidateItem ¶
func ValidateOrder ¶
func ValidatePrice ¶
func ValidateProduct ¶
func ValidateRating ¶
func ValidateUser ¶
Types ¶
type Address ¶
type Address struct { ID NullInt64JSON `json:"id"` City NullStringJSON `json:"city"` Country NullStringJSON `json:"country"` Address NullStringJSON `json:"address"` PostalCode NullStringJSON `json:"postalCode"` }
type Comment ¶
type Comment struct { ID NullInt64JSON `json:"id"` User User `json:"user"` ProductID NullInt64JSON `json:"productId"` Comment NullStringJSON `json:"comment"` CreatedAt NullStringJSON `json:"createdAt"` }
type Image ¶
type Image struct { ID NullInt64JSON `json:"id"` ProductID NullInt64JSON `json:"productId"` Data string `json:"data"` Format string `json:"format"` }
type Invoice ¶
type Invoice struct { ID NullInt64JSON `json:"id"` UserID NullInt64JSON `json:"userId"` Order Order `json:"order"` TotalPrice Price `json:"totalPrice"` CreatedAt NullStringJSON `json:"createdAt"` }
type Item ¶
type Item struct { ID NullInt64JSON `json:"id"` ProductID NullInt64JSON `json:"productId"` OrderID NullInt64JSON `json:"orderId"` Quantity NullInt64JSON `json:"quantity"` Price Price `json:"price"` }
type NullBoolJSON ¶
func (NullBoolJSON) MarshalJSON ¶
func (n NullBoolJSON) MarshalJSON() ([]byte, error)
func (*NullBoolJSON) Scan ¶
func (n *NullBoolJSON) Scan(value interface{}) error
func (*NullBoolJSON) UnmarshalJSON ¶
func (n *NullBoolJSON) UnmarshalJSON(data []byte) error
type NullFloat64JSON ¶
type NullFloat64JSON sql.NullFloat64
func (NullFloat64JSON) MarshalJSON ¶
func (n NullFloat64JSON) MarshalJSON() ([]byte, error)
func (*NullFloat64JSON) Scan ¶
func (n *NullFloat64JSON) Scan(value interface{}) error
func (*NullFloat64JSON) UnmarshalJSON ¶
func (n *NullFloat64JSON) UnmarshalJSON(data []byte) error
type NullInt64JSON ¶
func (NullInt64JSON) MarshalJSON ¶
func (n NullInt64JSON) MarshalJSON() ([]byte, error)
func (*NullInt64JSON) Scan ¶
func (n *NullInt64JSON) Scan(value any) error
func (*NullInt64JSON) UnmarshalJSON ¶
func (n *NullInt64JSON) UnmarshalJSON(data []byte) error
type NullStringJSON ¶
type NullStringJSON sql.NullString
func (NullStringJSON) MarshalJSON ¶
func (n NullStringJSON) MarshalJSON() ([]byte, error)
func (*NullStringJSON) Scan ¶
func (n *NullStringJSON) Scan(value interface{}) error
func (*NullStringJSON) UnmarshalJSON ¶
func (n *NullStringJSON) UnmarshalJSON(data []byte) error
type Order ¶
type Order struct { ID NullInt64JSON `json:"id"` UserID NullInt64JSON `json:"userId"` Products []*Item `json:"products"` Status OrderStatus `json:"status"` Address Address `json:"address"` CreatedAt NullStringJSON `json:"createdAt"` LatestUpdate NullStringJSON `json:"latestUpdate"` }
type OrderStatus ¶
type OrderStatus int
const ( InCart OrderStatus = iota + 1 InProgress Completed Canceled InvalidOrderStatus )
type Price ¶
type Price struct { Units int64 `json:"units,omitempty"` Currency Currency `json:"currency,omitempty"` }
func FromString ¶
func (Price) MultiplyInt ¶
type Product ¶
type Product struct { ID NullInt64JSON `json:"id"` Name NullStringJSON `json:"name"` Description NullStringJSON `json:"description"` Price Price `json:"price"` Quantity NullInt64JSON `json:"quantity"` Category ProductCategory `json:"category"` Available NullBoolJSON `json:"available"` Comments []*Comment `json:"comments"` Rating NullFloat64JSON `json:"rating"` RatingsCount NullInt64JSON `json:"ratingsCount"` Ratings []*Rating `json:"-"` CreatedAt NullStringJSON `json:"createdAt"` UserID NullInt64JSON `json:"userId"` }
type ProductCategory ¶
type ProductCategory int
const ( Home ProductCategory = 1 << iota Clothing Shoes Sport Appliances Technology Entertainment Books Cars ProductCategoryMask = 1<<iota - 1 )
type Rating ¶
type Rating struct { UserID NullInt64JSON `json:"userId"` ProductID NullInt64JSON `json:"productId"` Rating NullInt64JSON `json:"rating"` }
type User ¶
type User struct { ID NullInt64JSON `json:"id"` Name NullStringJSON `json:"name"` FirstName NullStringJSON `json:"firstName"` LastName NullStringJSON `json:"lastName"` PictureURL NullStringJSON `json:"pictureUrl"` Email NullStringJSON `json:"email"` Address Address `json:"address"` CreatedAt NullStringJSON `json:"createdAt"` }
type ValidationError ¶
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.