cart

package
v0.0.0-...-ae60a63 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: GPL-3.0 Imports: 7 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 {
	ArticleId string `bson:"articleId" json:"articleId" validate:"required,min=1,max=100"`
	Quantity  int    `bson:"quantity" json:"quantity" validate:"required,min=1,max=100"`
	Valid     bool   `bson:"valid" json:"valid"`
	Validated bool   `bson:"validated" json:"validated"`
}

type Cart

type Cart struct {
	ID       primitive.ObjectID `bson:"_id" json:"_id"`
	UserId   string             `bson:"userId"  json:"userId" validate:"required,min=1,max=100"`
	OrderId  string             `bson:"orderId" json:"orderId"`
	Articles []*Article         `bson:"articles"  json:"articles" validate:"required"`
	Enabled  bool               `bson:"enabled" json:"enabled"`
	Created  time.Time          `bson:"created" json:"created"`
	Updated  time.Time          `bson:"updated" json:"updated"`
}

Estuctura basica de del evento

type CartRepository

type CartRepository interface {
	FindByUserId(userId string) (*Cart, error)
	FindById(cartId string) (*Cart, error)
	Insert(crt *Cart) (*Cart, error)
	Replace(crt *Cart) (*Cart, error)
	Invalidate(crt *Cart) (*Cart, error)
	NewCart(userId string) *Cart
}

func NewCartRepository

func NewCartRepository(log log.LogRusEntry, collection db.Collection) CartRepository

type CartService

type CartService interface {
	CurrentCart(userId string) (*Cart, error)
	AddArticle(userId string, articleId string, quantity int) (*Cart, error)
	RemoveArticle(userId string, articleId string) (*Cart, error)
	ProcessOrderPlaced(data *OrderPlacedEvent) error
	InvalidateCurrentCart(cry *Cart) (*Cart, error)
	FindCartById(cartId string) (*Cart, error)
	ProcessArticleData(data *ValidationEvent) error
}

func NewCartService

func NewCartService(log log.LogRusEntry, repository CartRepository) CartService

type DbDeleteTokenBody

type DbDeleteTokenBody struct {
	Enabled bool `bson:"enabled"`
}

type DbDeleteTokenDocument

type DbDeleteTokenDocument struct {
	Set DbDeleteTokenBody `bson:"$set"`
}

type DbIdFilter

type DbIdFilter struct {
	ID primitive.ObjectID `bson:"_id" json:"_id"`
}

type DbUserIdFilter

type DbUserIdFilter struct {
	UserId  string `bson:"userId"`
	Enabled bool   `bson:"enabled"`
}

type OrderPlacedEvent

type OrderPlacedEvent struct {
	CartId  string `json:"cartId" example:"CartId"`
	OrderId string `json:"orderId" example:"OrderId"`
	Valid   bool   `json:"valid" example:"true"`
}

type ValidationEvent

type ValidationEvent struct {
	ReferenceId string `json:"referenceId" example:"UserId"`
	ArticleId   string `json:"articleId" example:"ArticleId"`
	Valid       bool   `json:"valid" example:"true"`
}

Jump to

Keyboard shortcuts

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