Documentation
¶
Index ¶
- Constants
- Variables
- type Avatar
- type Cart
- type CartArticle
- type CartProductPrice
- type CategoriesCatalog
- type CsrfToken
- type DiscountedPrice
- type FavoritesSortOptions
- type LoginUser
- type NotificationCredentials
- type NotificationKeys
- type NotificationPublicKey
- type Order
- type OrderAddress
- type OrderNotification
- type OrderNumber
- type OrderRecipient
- type PaginatorFavorites
- type PaginatorOrders
- type PaginatorProducts
- type PaginatorRecommendations
- type PaginatorReviews
- type PlacedOrder
- type PreviewCart
- type PreviewCartArticle
- type PreviewOrder
- type PreviewOrderedProducts
- type Product
- type ProductFilter
- type ProductIdentifier
- type ProductPosition
- type ProductPrice
- type ProfileUser
- type PromoCodeGroup
- type PromoPrice
- type RangeFavorites
- type RangeOrders
- type RangeProducts
- type RangeReviews
- type RecommendationProduct
- type Review
- type ReviewStatistics
- type SearchQuery
- type Session
- type SignupUser
- type SortOptions
- type SortOrdersOptions
- type SortReviewsOptions
- type Subscribes
- type TotalPrice
- type UpdateOrder
- type UpdateUser
- type UserFavorites
- type UserId
- type UserIdentifier
- type ViewFavorite
- type ViewProduct
- type ViewReview
Constants ¶
const ( CsrfTokenHeaderName = "X-CSRF-TOKEN" CsrfTokenCookieName = "jwt_token" CsrfTokenContextKey = contextKey("csrf_token_key") ExpireCsrfToken = 900 )
const ( SessionCookieName = "session_id" SessionContextKey = contextKey("session_key") RequireIdKey = contextKey("require_key") RequireIdName = "require_id" ExpireSessionCookie = 90 * 24 * 3600 )
Variables ¶
var ( FavoritesCostSort = "cost" FavoritesRatingSort = "rating" FavoritesDateAddedSort = "date" FavoritesDiscountSort = "discount" FavoritesPaginatorASC = "ASC" FavoritesPaginatorDESC = "DESC" )
var ( OrdersDateAddedSort = "date" OrdersPaginatorASC = "ASC" OrdersPaginatorDESC = "DESC" )
var ( ProductsCostSort = "cost" ProductsRatingSort = "rating" ProductsDateAddedSort = "date" ProductsDiscountSort = "discount" PaginatorASC = "ASC" PaginatorDESC = "DESC" )
var ( ReviewDateAddedSort = "date" ReviewPaginatorASC = "ASC" ReviewPaginatorDESC = "DESC" )
Functions ¶
This section is empty.
Types ¶
type Cart ¶
type Cart struct {
Products map[uint64]*ProductPosition `json:"products" valid:"notnull"`
}
All cart information This models saved in database
type CartArticle ¶
type CartArticle struct { ProductPosition ProductIdentifier }
One product in cart
type CartProductPrice ¶
type CartProductPrice struct { Discount int `json:"discount"` BaseCost int `json:"base_cost"` TotalCost int `json:"total_cost"` }
Price product kept in integer nums and contains base price and discount
type CategoriesCatalog ¶
type CategoriesCatalog struct { Id uint64 `json:"id"` Name string `json:"name" valid:"utfletter, stringlength(1|30)"` Next []*CategoriesCatalog `json:"next,omitempty" valid:"notnull"` }
Node of categories tree
type CsrfToken ¶
type CsrfToken struct {
Value string `json:"token"`
}
func NewCsrfToken ¶
func NewCsrfToken() *CsrfToken
type DiscountedPrice ¶
type FavoritesSortOptions ¶
type LoginUser ¶
type LoginUser struct { Email string `json:"email" valid:"email"` Password string `json:"password" valid:"stringlength(6|32)"` }
Model contains fields for login
type NotificationCredentials ¶
type NotificationCredentials struct { UserIdentifier Keys NotificationKeys `json:"keys"` }
func (*NotificationCredentials) Sanitize ¶
func (nc *NotificationCredentials) Sanitize()
type NotificationKeys ¶
func (*NotificationKeys) Sanitize ¶
func (nk *NotificationKeys) Sanitize()
type NotificationPublicKey ¶
type NotificationPublicKey struct {
Key string `json:"key"`
}
type Order ¶
type Order struct { Recipient OrderRecipient `json:"recipient" valid:"notnull"` Address OrderAddress `json:"address" valid:"notnull"` PromoCode string `json:"promo_code"` }
All order information This models saved in database
type OrderAddress ¶
type OrderAddress struct {
Address string `json:"address" valid:"utfletter, stringlength(1|30)"`
}
Order address for delivery
type OrderNotification ¶
type OrderNotification struct { Number OrderNumber `json:"order_number"` Status string `json:"status"` }
type OrderNumber ¶
type OrderNumber struct {
Number string `json:"number"`
}
type OrderRecipient ¶
type OrderRecipient struct { FirstName string `json:"first_name" valid:"utfletter, stringlength(1|30)"` LastName string `json:"last_name" valid:"utfletter, stringlength(1|30)"` Email string `json:"email" valid:"email"` }
Info about order recipient
type PaginatorFavorites ¶
type PaginatorFavorites struct { PageNum int `json:"page_num"` Count int `json:"count"` SortOptions }
Paginator for showing page of favorites
type PaginatorOrders ¶
type PaginatorOrders struct { PageNum int `json:"page_num"` Count int `json:"count"` SortOrdersOptions }
Paginator for showing page of orders
func (*PaginatorOrders) Sanitize ¶
func (p *PaginatorOrders) Sanitize()
type PaginatorProducts ¶
type PaginatorProducts struct { PageNum int `json:"page_num"` Count int `json:"count"` Category uint64 `json:"category"` Filter *ProductFilter `json:"filter"` SortOptions }
Paginator for showing page of product
func (*PaginatorProducts) Sanitize ¶
func (pp *PaginatorProducts) Sanitize()
type PaginatorRecommendations ¶
type PaginatorRecommendations struct {
Count int `json:"count"`
}
Paginator for showing page of product
type PaginatorReviews ¶
type PaginatorReviews struct { PageNum int `json:"page_num"` Count int `json:"count"` SortReviewsOptions }
Paginator for showing page of reviews
func (*PaginatorReviews) Sanitize ¶
func (pr *PaginatorReviews) Sanitize()
type PlacedOrder ¶
type PlacedOrder struct { Id uint64 `json:"id"` Address OrderAddress `json:"address" valid:"notnull"` TotalCost int `json:"total_cost"` Products []*PreviewOrderedProducts `json:"product_images" valid:"notnull"` DateAdded time.Time `json:"date_added"` DateDelivery time.Time `json:"date_delivery"` OrderNumber OrderNumber `json:"order_number"` Status string `json:"status"` }
type PreviewCart ¶
type PreviewCart struct { Products []*PreviewCartArticle `json:"products" valid:"notnull"` Price TotalPrice `json:"price" valid:"notnull"` }
View of cart This model contains field for preview information
type PreviewCartArticle ¶
type PreviewCartArticle struct { Id uint64 `json:"id"` Title string `json:"title" valid:"minstringlength(1)"` Price CartProductPrice `json:"price" valid:"notnull"` PreviewImage string `json:"preview_image" valid:"minstringlength(1)"` Count uint64 `json:"count"` }
View of product in cart This model contains field for showing product in user cart
type PreviewOrder ¶
type PreviewOrder struct { Products []*PreviewOrderedProducts `json:"products" valid:"notnull"` Recipient OrderRecipient `json:"recipient" valid:"notnull"` Price TotalPrice `json:"price" valid:"notnull"` Address OrderAddress `json:"address" valid:"notnull"` }
All order information This model preview info for user
type PreviewOrderedProducts ¶
type Product ¶
type Product struct { Id uint64 `json:"id"` Title string `json:"title" valid:"minstringlength(3)"` Price ProductPrice `json:"price" valid:"notnull, json"` Rating float32 `json:"rating" valid:"float, range(0, 10)"` CountReviews uint64 `json:"count_reviews"` Properties string `json:"properties"` Description string `json:"description" valid:"utfletter"` Category uint64 `json:"category"` CategoryPath []*CategoriesCatalog `json:"category_path" valid:"notnull"` Images []string `json:"images" valid:"notnull"` }
All product information This models saved in database
type ProductFilter ¶
type ProductIdentifier ¶
type ProductIdentifier struct {
ProductId uint64 `json:"product_id"`
}
type ProductPosition ¶
type ProductPosition struct {
Count uint64 `json:"count"`
}
type ProductPrice ¶
type ProductPrice struct { Discount int `json:"discount"` BaseCost int `json:"base_cost"` TotalCost int `json:"total_cost"` }
Price product kept in integer nums and contains base price and discount
type ProfileUser ¶
type ProfileUser struct { Id uint64 `json:"-"` FirstName string `json:"first_name" valid:"utfletter, stringlength(1|30)"` LastName string `json:"last_name" valid:"utfletter, stringlength(1|30)"` Avatar Avatar `json:"avatar" valid:"notnull, json"` AuthId uint64 `json:"-"` Email string `json:"email" valid:"email"` }
All user information This models saved in database
type PromoCodeGroup ¶
type PromoPrice ¶
type RangeFavorites ¶
type RangeFavorites struct { ListPreviewProducts []*ViewFavorite `json:"list_preview_products" valid:"notnull"` MaxCountPages int `json:"max_count_pages"` }
Set of product with count uniq sets of this size
type RangeOrders ¶
type RangeOrders struct { ListPreviewOrders []*PlacedOrder `json:"list_placed_orders" valid:"notnull"` MaxCountPages int `json:"max_count_pages"` }
Set of product with count uniq sets of this size
type RangeProducts ¶
type RangeProducts struct { ListPreviewProducts []*ViewProduct `json:"list_preview_products" valid:"notnull"` MaxCountPages int `json:"max_count_pages"` }
Set of product with count uniq sets of this size
type RangeReviews ¶
type RangeReviews struct { ListPreviews []*ViewReview `json:"list_reviews" valid:"notnull"` MaxCountPages int `json:"max_count_pages"` }
Set of reviews with count uniq sets of this size
type RecommendationProduct ¶
type RecommendationProduct struct { Id uint64 `json:"id"` Title string `json:"title" valid:"minstringlength(3)"` Price ProductPrice `json:"price" valid:"notnull, json"` PreviewImage string `json:"preview_image" valid:"minstringlength(3)"` }
type Review ¶
type ReviewStatistics ¶
type ReviewStatistics struct {
Stars []int `json:"stars"`
}
type SearchQuery ¶
type SearchQuery struct { QueryString string `json:"query_string" valid:"minstringlength(2)"` PageNum int `json:"page_num"` Count int `json:"count"` Category uint64 `json:"category"` Filter *ProductFilter `json:"filter"` SortOptions }
Search query with options
func (*SearchQuery) Sanitize ¶
func (sq *SearchQuery) Sanitize()
type SignupUser ¶
type SignupUser struct { Email string `json:"email" valid:"email"` Password string `json:"password" valid:"stringlength(6|32)"` }
Model contains fields for registration new user
func (*SignupUser) Sanitize ¶
func (su *SignupUser) Sanitize()
type SortOptions ¶
type SortOrdersOptions ¶
type SortReviewsOptions ¶
type Subscribes ¶
type Subscribes struct {
Credentials map[string]*NotificationKeys `json:"subscribes" valid:"notnull"`
}
type TotalPrice ¶
type TotalPrice struct { TotalDiscount int `json:"total_discount"` TotalCost int `json:"total_cost"` TotalBaseCost int `json:"total_base_cost"` }
Order price kept in integer nums and contains base price and discount
type UpdateOrder ¶
type UpdateOrder struct { OrderId uint64 `json:"order_id"` Status string `json:"status" valid:"in(в пути|оформлен|получен)"` }
func (*UpdateOrder) Sanitize ¶
func (u *UpdateOrder) Sanitize()
type UpdateUser ¶
type UpdateUser struct { FirstName string `json:"first_name" valid:"utfletter, stringlength(1|30)"` LastName string `json:"last_name" valid:"utfletter, stringlength(1|30)"` }
Model contains fields for updating user information
func (*UpdateUser) Sanitize ¶
func (uu *UpdateUser) Sanitize()
type UserFavorites ¶
type UserFavorites struct {
Products []uint64 `json:"products"`
}
type UserIdentifier ¶
type UserIdentifier struct {
Endpoint string `json:"endpoint"`
}
func (*UserIdentifier) Sanitize ¶
func (ui *UserIdentifier) Sanitize()
type ViewFavorite ¶
type ViewFavorite struct { Id uint64 `json:"id"` Title string `json:"title" valid:"minstringlength(3)"` Price ProductPrice `json:"price" valid:"notnull, json"` Rating float32 `json:"rating" valid:"float, range(0, 10)"` CountReviews uint64 `json:"count_reviews"` PreviewImage string `json:"preview_image" valid:"minstringlength(3)"` }
View of product This model contains field for preview information
type ViewProduct ¶
type ViewProduct struct { Id uint64 `json:"id"` Title string `json:"title" valid:"minstringlength(3)"` Price ProductPrice `json:"price" valid:"notnull, json"` Rating float32 `json:"rating" valid:"float, range(0, 10)"` CountReviews uint64 `json:"count_reviews"` PreviewImage string `json:"preview_image" valid:"minstringlength(3)"` }
View of product This model contains field for preview information
type ViewReview ¶
type ViewReview struct { UserName string `json:"user_name" valid:"minstringlength(1)"` UserAvatar string `json:"user_avatar" valid:"minstringlength(1)"` DateAdded time.Time `json:"date_added" valid:"notnull"` Rating int `json:"rating" valid:"int"` Advantages string `json:"advantages"` Disadvantages string `json:"disadvantages"` Comment string `json:"comment"` IsPublic bool `json:"-"` UserId int `json:"-"` }