models

package
v0.0.0-...-90e0d95 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CsrfTokenHeaderName = "X-CSRF-TOKEN"
	CsrfTokenCookieName = "jwt_token"
	CsrfTokenContextKey = contextKey("csrf_token_key")
	ExpireCsrfToken     = 900
)
View Source
const (
	SessionCookieName   = "session_id"
	SessionContextKey   = contextKey("session_key")
	RequireIdKey        = contextKey("require_key")
	RequireIdName       = "require_id"
	ExpireSessionCookie = 90 * 24 * 3600
)

Variables

View Source
var (
	FavoritesCostSort      = "cost"
	FavoritesRatingSort    = "rating"
	FavoritesDateAddedSort = "date"
	FavoritesDiscountSort  = "discount"

	FavoritesPaginatorASC  = "ASC"
	FavoritesPaginatorDESC = "DESC"
)
View Source
var (
	OrdersDateAddedSort = "date"

	OrdersPaginatorASC  = "ASC"
	OrdersPaginatorDESC = "DESC"
)
View Source
var (
	ProductsCostSort      = "cost"
	ProductsRatingSort    = "rating"
	ProductsDateAddedSort = "date"
	ProductsDiscountSort  = "discount"

	PaginatorASC  = "ASC"
	PaginatorDESC = "DESC"
)
View Source
var (
	ReviewDateAddedSort = "date"

	ReviewPaginatorASC  = "ASC"
	ReviewPaginatorDESC = "DESC"
)

Functions

This section is empty.

Types

type Avatar

type Avatar struct {
	Url string `json:"url" valid:"minstringlength(1)"`
}

User avatar

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 DiscountedPrice struct {
	TotalDiscount int `json:"total_discount"`
	TotalCost     int `json:"total_cost"`
	TotalBaseCost int `json:"total_base_cost"`
}

type FavoritesSortOptions

type FavoritesSortOptions struct {
	SortKey       string `json:"sort_key" valid:"in(cost|rating|date|discount)"`
	SortDirection string `json:"sort_direction" valid:"in(ASC|DESC)"`
}

type LoginUser

type LoginUser struct {
	Email    string `json:"email" valid:"email"`
	Password string `json:"password" valid:"stringlength(6|32)"`
}

Model contains fields for login

func (*LoginUser) Sanitize

func (lu *LoginUser) Sanitize()

type NotificationCredentials

type NotificationCredentials struct {
	UserIdentifier
	Keys NotificationKeys `json:"keys"`
}

func (*NotificationCredentials) Sanitize

func (nc *NotificationCredentials) Sanitize()

type NotificationKeys

type NotificationKeys struct {
	Auth   string `json:"auth"`
	P256dh string `json:"p256dh"`
}

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

func (*Order) Sanitize

func (o *Order) Sanitize()

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 PreviewOrderedProducts struct {
	Id           uint64 `json:"id"`
	PreviewImage string `json:"preview_image" valid:"minstringlength(1)"`
}

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 ProductFilter struct {
	MinPrice   uint64 `json:"min_price"`
	MaxPrice   uint64 `json:"max_price"`
	IsNew      bool   `json:"is_new"`
	IsRating   bool   `json:"is_rating"`
	IsDiscount bool   `json:"is_discount"`
}

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 PromoCodeGroup struct {
	Products  []uint64 `json:"products" valid:"notnull"`
	PromoCode string   `json:"promo_code" valid:"stringlength(1|30)"`
}

type PromoPrice

type PromoPrice struct {
	TotalCost int `json:"total_cost"`
	BaseCost  int `json:"base_cost"`
}

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 Review struct {
	ProductId     int    `json:"product_id"`
	Rating        int    `json:"rating" valid:"int"`
	Advantages    string `json:"advantages"`
	Disadvantages string `json:"disadvantages"`
	Comment       string `json:"comment"`
	IsPublic      bool   `json:"is_public"`
}

func (*Review) Sanitize

func (r *Review) Sanitize()

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 Session

type Session struct {
	Value    string
	UserData UserId
}

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 SortOptions struct {
	SortKey       string `json:"sort_key" valid:"in(cost|rating|date|discount)"`
	SortDirection string `json:"sort_direction" valid:"in(ASC|DESC)"`
}

type SortOrdersOptions

type SortOrdersOptions struct {
	SortKey       string `json:"sort_key" valid:"in(date)"`
	SortDirection string `json:"sort_direction" valid:"in(ASC|DESC)"`
}

type SortReviewsOptions

type SortReviewsOptions struct {
	SortKey       string `json:"sort_key" valid:"in(rating|date)"`
	SortDirection string `json:"sort_direction" valid:"in(ASC|DESC)"`
}

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 UserId

type UserId struct {
	Id uint64
}

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:"-"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL