events

package
v0.0.0-...-7dc96ab Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: GPL-3.0 Imports: 11 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"`
	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) ([]*Event, error)

FindAll devuelve todos los eventos por order id

func SaveArticleExist

func SaveArticleExist(data *ValidationEvent) (*Event, error)

SaveArticleExist saves the event for article exist

func SavePayment

func SavePayment(data *PaymentEvent) (*Event, error)

SavePayment saves a payment event

func SavePlaceOrder

func SavePlaceOrder(data *PlacedOrderData) (*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 {
	CartId string        `bson:"cartId"`
	Method PaymentMethod `bson:"metod" `
	Amount float32       `bson:"amount" `
}

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"`
	IsValid   bool    `bson:"isValid" `
	Stock     int     `bson:"stock" `
	Price     float32 `bson:"price" `
}

Jump to

Keyboard shortcuts

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