order_infrastructure

package
v0.0.0-...-52e64fa Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOrderNotFound = errors.New("order not found")

Functions

This section is empty.

Types

type OrderDTO

type OrderDTO struct {
	ID           primitive.ObjectID `bson:"_id,omitempty"`
	CustomerID   primitive.ObjectID `bson:"customer_id"`
	OrderDetails []OrderDetailDTO   `bson:"order_details"`
	OrderDate    time.Time          `bson:"order_date"`
	TotalAmount  float64            `bson:"total_amount"`
	Status       string             `bson:"status"`
}

func NewOrderDTO

func NewOrderDTO(CustomerID primitive.ObjectID, OrderDetails []OrderDetailDTO, OrderDate time.Time, TotalAmount float64, Status string) *OrderDTO

type OrderDetailDTO

type OrderDetailDTO struct {
	ProductID primitive.ObjectID `bson:"product_id"`
	Quantity  int                `bson:"quantity"`
	Price     float64            `bson:"price"`
}

func NewOrderDetailDTO

func NewOrderDetailDTO(productID primitive.ObjectID, quantity int, price float64) *OrderDetailDTO

type OrderRepository

type OrderRepository struct {
	Ctx        context.Context
	Collection *mongo.Collection
}

func NewOrderRepository

func NewOrderRepository(ctx context.Context, DB *mongo.Database) OrderRepository

func (OrderRepository) Create

func (c OrderRepository) Create(dto *OrderDTO) (*OrderDTO, error)

func (OrderRepository) FindByCustomerID

func (c OrderRepository) FindByCustomerID(customerID primitive.ObjectID) ([]OrderDTO, error)

func (OrderRepository) GetTotalAmountSpent

func (cc OrderRepository) GetTotalAmountSpent(orderHistories []primitive.ObjectID) (float64, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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