article

package
v0.0.0-...-6aeb5bb Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

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 ArticleData struct {
	ID          primitive.ObjectID `json:"_id"`
	Name        string             `json:"name"`
	Description string             `json:"description"`
	Image       string             `json:"image"`
	Price       float32            `json:"price"`
	Stock       int                `json:"stock"`
	Enabled     bool               `json:"enabled"`
}

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 DBCriteriaElement struct {
	RegEx   string `bson:"$regex"`
	Options string `bson:"$options"`
}

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 DbIdFilter struct {
	ID primitive.ObjectID `bson:"_id"`
}

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 Description struct {
	Name        string `bson:"name"  json:"name" validate:"required,min=1,max=100"`
	Description string `bson:"description"  json:"description" validate:"required,min=1,max=256"`
	Image       string `bson:"image"  json:"image" validate:"max=100"`
}

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

Jump to

Keyboard shortcuts

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