events

package
v0.0.0-...-8eac59e Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	ArticleId string `json:"articleId" binding:"required,min=1,max=100"`
	Quantity  int    `json:"quantity" binding:"required,min=1"`
}

type Event

type Event struct {
	ID         primitive.ObjectID `bson:"_id,omitempty"`
	OrderId    string             `bson:"orderId" validate:"required,min=1,max=100"`
	Type       EventType          `bson:"type" validate:"required"`
	PlaceEvent *PlaceEvent        `bson:"placeEvent"`
	Validation *ValidationEvent   `bson:"validation"`
	Payment    *PaymentEvent      `bson:"payment"`
	Created    time.Time          `bson:"created"`
	Updated    time.Time          `bson:"updated"`
}

Estuctura basica de del evento

func FindByOrderId

func FindByOrderId(orderId string, deps ...interface{}) ([]*Event, error)

FindAll devuelve todos los eventos por order id

func SaveArticleExist

func SaveArticleExist(data *ValidationEvent, deps ...interface{}) (*Event, error)

SaveArticleExist saves the event for article exist

func SavePayment

func SavePayment(data *PaymentEvent, deps ...interface{}) (*Event, error)

SavePayment saves a payment event

func SavePlaceOrder

func SavePlaceOrder(data *PlacedOrderData, deps ...interface{}) (*Event, error)

SavePlaceOrder saves the event for place order

func (*Event) ValidateSchema

func (e *Event) ValidateSchema() error

ValidateSchema valida la estructura para ser insertada en la db

type EventType

type EventType string
const (
	Place      EventType = "place_order"
	Validation EventType = "aticle_validation"
	Payment    EventType = "payment"
)

type PaymentEvent

type PaymentEvent struct {
	OrderId string        `bson:"orderId" binding:"required"`
	Method  PaymentMethod `bson:"metod" binding:"required"`
	Amount  float32       `bson:"amount" binding:"required"`
}

type PaymentMethod

type PaymentMethod string
const (
	Cash   PaymentMethod = "CASH"
	Credit PaymentMethod = "CREDIT"
	Debit  PaymentMethod = "DEBIT"
)

type PlaceEvent

type PlaceEvent struct {
	CartId   string    `bson:"cartId"`
	UserId   string    `bson:"userId" `
	Articles []Article `bson:"articles" `
}

type PlacePrderArticleData

type PlacePrderArticleData struct {
	Id       string `json:"id" binding:"required,min=1,max=100"`
	Quantity int    `json:"quantity" binding:"required,min=1"`
}

type PlacedOrderData

type PlacedOrderData struct {
	CartId   string                  `json:"cartId" binding:"required,min=1,max=100"`
	UserId   string                  `json:"userId" binding:"required,min=1,max=100"`
	Articles []PlacePrderArticleData `json:"articles" binding:"required,gt=0"`
}

type ValidationEvent

type ValidationEvent struct {
	ArticleId   string  `bson:"articleId" json:"articleId"`
	ReferenceId string  `bson:"referenceId" json:"referenceId"`
	IsValid     bool    `bson:"isValid" json:"valid"`
	Stock       int     `bson:"stock" json:"stock"`
	Price       float32 `bson:"price" json:"price"`
}

Jump to

Keyboard shortcuts

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