Documentation ¶
Index ¶
- Variables
- type Article
- type ArticleData
- type ArticleRepository
- type ArticleService
- type DBCriteriaElement
- type DBCriteriaFilter
- type DbEnableBody
- type DbEnableDocument
- type DbIdFilter
- type DbUpdateDescriptionBody
- type DbUpdateDescriptionDocument
- type DbUpdatePriceBody
- type DbUpdatePriceDocument
- type DbUpdateStockBody
- type DbUpdateStockDocument
- type Description
- type PaymentMethod
- type UpdateArticleData
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrID = errs.NewValidation().Add("id", "Invalid")
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct { ID primitive.ObjectID `bson:"_id" json:"_id"` Description Description `bson:"description" json:"description" validate:"required"` Price float32 `bson:"price" json:"price"` Stock int `bson:"stock" json:"stock"` Created time.Time `bson:"created" json:"created"` Updated time.Time `bson:"updated" json:"updated"` Enabled bool `bson:"enabled" json:"enabled"` }
Estuctura basica de del evento
type ArticleData ¶
type ArticleRepository ¶
type ArticleRepository interface { FindByCriteria(criteria string) ([]*Article, error) FindById(articleId string) (*Article, error) Insert(article *Article) (*Article, error) Disable(articleId string) error UpdateDescription(articleId string, description Description) error UpdatePrice(articleId string, price float32) error UpdateStock(articleId string, stock int) error DecrementStock(articleId primitive.ObjectID, amount int) error }
func NewArticleRepository ¶
func NewArticleRepository(log log.LogRusEntry, collection db.Collection) ArticleRepository
type ArticleService ¶
type ArticleService interface { UpdateArticle(articleId string, articleData *UpdateArticleData) error FindById(id string, deps ...interface{}) (*ArticleData, error) FindByCriteria(criteria string) ([]*ArticleData, error) CreateArticle(articleData *UpdateArticleData, deps ...interface{}) (*ArticleData, error) Disable(articleId string) error DecrementStock(articleId primitive.ObjectID, amount int) error }
func NewArticleService ¶
func NewArticleService(log log.LogRusEntry, repository ArticleRepository) ArticleService
type DBCriteriaElement ¶
type DBCriteriaFilter ¶
type DBCriteriaFilter struct {
Or []map[string]DBCriteriaElement `bson:"$or"`
}
type DbEnableBody ¶
type DbEnableBody struct {
Enabled bool `bson:"enabled" json:"enabled"`
}
type DbEnableDocument ¶
type DbEnableDocument struct {
Set DbEnableBody `bson:"$set"`
}
type DbIdFilter ¶
type DbUpdateDescriptionBody ¶
type DbUpdateDescriptionBody struct {
Description Description `bson:"description" json:"description" validate:"required"`
}
type DbUpdateDescriptionDocument ¶
type DbUpdateDescriptionDocument struct {
Set DbUpdateDescriptionBody `bson:"$set"`
}
type DbUpdatePriceBody ¶
type DbUpdatePriceBody struct {
Price float32 `bson:"price" json:"price"`
}
type DbUpdatePriceDocument ¶
type DbUpdatePriceDocument struct {
Set DbUpdatePriceBody `bson:"$set"`
}
type DbUpdateStockBody ¶
type DbUpdateStockBody struct {
Stock int `bson:"stock" json:"stock"`
}
type DbUpdateStockDocument ¶
type DbUpdateStockDocument struct {
Set DbUpdateStockBody `bson:"$set"`
}
type Description ¶
type PaymentMethod ¶
type PaymentMethod string
type UpdateArticleData ¶
type UpdateArticleData struct { Name string `json:"name" validate:"required,min=1,max=100"` Description string `json:"description" validate:"required,min=1,max=256"` Image string `json:"image" validate:"max=100"` Price float32 `json:"price" validate:"required,min=1"` Stock int `json:"stock" validate:"required,min=1"` }
Click to show internal directories.
Click to hide internal directories.