Documentation ¶
Index ¶
- type Address
- type ConfirmedOrderState
- func (cS ConfirmedOrderState) Confirm(_ *Order) bool
- func (cS ConfirmedOrderState) Delivered(order *Order) bool
- func (cS ConfirmedOrderState) IsConfirmed() bool
- func (cS ConfirmedOrderState) IsDelivered() bool
- func (cS ConfirmedOrderState) MarshalJSON() ([]byte, error)
- func (cS ConfirmedOrderState) String() string
- type DeliveredOrderState
- func (dS DeliveredOrderState) Confirm(_ *Order) bool
- func (dS DeliveredOrderState) Delivered(_ *Order) bool
- func (dS DeliveredOrderState) IsConfirmed() bool
- func (dS DeliveredOrderState) IsDelivered() bool
- func (dS DeliveredOrderState) MarshalJSON() ([]byte, error)
- func (dS DeliveredOrderState) String() string
- type Logger
- type LoggerFields
- type Order
- type OrderRepository
- type OrderState
- type Paging
- type PagingRequest
- type PendingOrderState
- func (pS PendingOrderState) Confirm(order *Order) bool
- func (pS PendingOrderState) Delivered(_ *Order) bool
- func (pS PendingOrderState) IsConfirmed() bool
- func (pS PendingOrderState) IsDelivered() bool
- func (pS PendingOrderState) MarshalJSON() ([]byte, error)
- func (pS PendingOrderState) String() string
- type Product
- type ProductRepository
- type ProductSearchFilter
- type Seller
- type SellerRepository
- type UpdateProduct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { Street string `json:"street" bson:"street" binding:"required"` City string `json:"city" bson:"city" binding:"required"` State string `json:"state" bson:"state" binding:"required"` Country string `json:"country" bson:"country" binding:"required"` Observation string `json:"observation" bson:"observation"` }
type ConfirmedOrderState ¶
type ConfirmedOrderState struct{}
func (ConfirmedOrderState) Confirm ¶
func (cS ConfirmedOrderState) Confirm(_ *Order) bool
func (ConfirmedOrderState) Delivered ¶
func (cS ConfirmedOrderState) Delivered(order *Order) bool
func (ConfirmedOrderState) IsConfirmed ¶
func (cS ConfirmedOrderState) IsConfirmed() bool
func (ConfirmedOrderState) IsDelivered ¶
func (cS ConfirmedOrderState) IsDelivered() bool
func (ConfirmedOrderState) MarshalJSON ¶
func (cS ConfirmedOrderState) MarshalJSON() ([]byte, error)
func (ConfirmedOrderState) String ¶
func (cS ConfirmedOrderState) String() string
type DeliveredOrderState ¶
type DeliveredOrderState struct{}
func (DeliveredOrderState) Confirm ¶
func (dS DeliveredOrderState) Confirm(_ *Order) bool
func (DeliveredOrderState) Delivered ¶
func (dS DeliveredOrderState) Delivered(_ *Order) bool
func (DeliveredOrderState) IsConfirmed ¶
func (dS DeliveredOrderState) IsConfirmed() bool
func (DeliveredOrderState) IsDelivered ¶
func (dS DeliveredOrderState) IsDelivered() bool
func (DeliveredOrderState) MarshalJSON ¶
func (dS DeliveredOrderState) MarshalJSON() ([]byte, error)
func (DeliveredOrderState) String ¶
func (dS DeliveredOrderState) String() string
type Logger ¶
type Logger interface { WithFields(map[string]interface{}) Logger WithRequestId(context.Context) Logger Print(...interface{}) Debug(...interface{}) Info(...interface{}) Warn(...interface{}) Error(...interface{}) Fatal(...interface{}) Panic(...interface{}) Printf(string, ...interface{}) Debugf(string, ...interface{}) Infof(string, ...interface{}) Warnf(string, ...interface{}) Errorf(string, ...interface{}) Fatalf(string, ...interface{}) Panicf(string, ...interface{}) }
type LoggerFields ¶
type LoggerFields map[string]interface{}
type Order ¶
type Order struct { Id int64 CustomerId int64 CreatedOn time.Time UpdatedOn time.Time DeliveryDate time.Time State OrderState Product *Product DeliveryAddress Address }
func (*Order) GetProductId ¶
func (*Order) IsConfirmed ¶
func (*Order) IsDelivered ¶
func (*Order) StateAsString ¶
type OrderRepository ¶
type OrderState ¶
type OrderState interface { // Confirm returns true when order mutates Confirm(order *Order) bool // Delivered returns true when order mutates Delivered(order *Order) bool IsConfirmed() bool IsDelivered() bool String() string MarshalJSON() ([]byte, error) }
func GetStateByString ¶
func GetStateByString(state string) (OrderState, bool)
type Paging ¶
type Paging struct { Total int `json:"total"` PageSize int `json:"pageSize"` Pages int `json:"pages"` CurrentPage int `json:"currentPage"` }
func NewEmptyPage ¶
func NewEmptyPage() Paging
type PagingRequest ¶
func NewPagingRequest ¶
func NewPagingRequest(page, size int) PagingRequest
func (PagingRequest) String ¶
func (pr PagingRequest) String() string
type PendingOrderState ¶
type PendingOrderState struct{}
func (PendingOrderState) Confirm ¶
func (pS PendingOrderState) Confirm(order *Order) bool
func (PendingOrderState) Delivered ¶
func (pS PendingOrderState) Delivered(_ *Order) bool
func (PendingOrderState) IsConfirmed ¶
func (pS PendingOrderState) IsConfirmed() bool
func (PendingOrderState) IsDelivered ¶
func (pS PendingOrderState) IsDelivered() bool
func (PendingOrderState) MarshalJSON ¶
func (pS PendingOrderState) MarshalJSON() ([]byte, error)
func (PendingOrderState) String ¶
func (pS PendingOrderState) String() string
type Product ¶
type Product struct { Id int64 `json:"id" bson:"_id"` SellerId int64 `json:"sellerId" bson:"sellerId"` Name string `json:"name" bson:"name"` Description string `json:"description" bson:"description"` Price float64 `json:"price" bson:"price"` Category string `json:"category" bson:"category"` Stock int `json:"stock" bson:"stock"` }
func (*Product) Merge ¶
func (p *Product) Merge(updateProduct UpdateProduct)
func (*Product) ReduceStock ¶
ReduceStock if stock < 0 returns false; otherwise decrease in 1 product stock and returns true
func (*Product) ValidStock ¶
ValidStock returns true when: stock > 0
type ProductRepository ¶
type ProductRepository interface { FindById(ctx context.Context, id int64) (*Product, error) Create(ctx context.Context, product Product) (int64, error) Update(ctx context.Context, product Product) (bool, error) Delete(ctx context.Context, id int64) (bool, error) DeleteAllBySellerId(ctx context.Context, sellerId int64) (bool, error) FindAllBySellerId(ctx context.Context, sellerId int64) ([]Product, error) Search(ctx context.Context, filters ProductSearchFilter, pagingReq PagingRequest) ([]Product, Paging, error) }
type ProductSearchFilter ¶
type ProductSearchFilter struct { Name string `json:"name"` Category string `json:"category"` SellerId int64 `json:"sellerId"` PriceMin *float64 `json:"priceMin"` PriceMax *float64 `json:"priceMax"` }
func NewProductSearchFilter ¶
func NewProductSearchFilter(name, category string, sellerId int64, priceMin, priceMax *float64) ProductSearchFilter
func (*ProductSearchFilter) ContainsAnyPriceFilter ¶
func (f *ProductSearchFilter) ContainsAnyPriceFilter() bool
func (*ProductSearchFilter) GetPriceMaxOrDefault ¶
func (f *ProductSearchFilter) GetPriceMaxOrDefault() float64
func (*ProductSearchFilter) GetPriceMinOrDefault ¶
func (f *ProductSearchFilter) GetPriceMinOrDefault() float64
func (*ProductSearchFilter) String ¶
func (f *ProductSearchFilter) String() string
type Seller ¶
type SellerRepository ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.