cart

package
v0.0.0-...-56fc341 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cart

type Cart struct {
	ID         primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	UserID     primitive.ObjectID `json:"user_id" bson:"user_id,omitempty"`
	CartItems  []CartItem         `json:"cart_items" bson:"cart_items"`
	TotalPrice float64            `json:"total_price" bson:"total_price"`
	UpdatedAt  time.Time          `json:"updated_at" bson:"updated_at"`
}

type CartController

type CartController struct {
	// contains filtered or unexported fields
}

func NewCartController

func NewCartController(cartServices CartServices) *CartController

func (*CartController) GetCart

func (cc *CartController) GetCart(c *gin.Context)

func (*CartController) UpdateCart

func (cc *CartController) UpdateCart(c *gin.Context)

type CartItem

type CartItem struct {
	ItemID     primitive.ObjectID `json:"item_id" bson:"item_id,omitempty"`
	Quantity   int                `json:"quantity" bson:"quantity"`
	Price      float64            `json:"price" bson:"price"`
	TotalPrice float64            `json:"total_price" bson:"total_price"`
}

type CartRepo

type CartRepo struct {
	Collection *mongo.Collection
}

func NewCartRepo

func NewCartRepo(collection *mongo.Collection) *CartRepo

func (*CartRepo) CreateCart

func (cr *CartRepo) CreateCart(cart *Cart) error

func (*CartRepo) DeleteCart

func (cr *CartRepo) DeleteCart(filter interface{}, opts ...*options.DeleteOptions) error

func (*CartRepo) GetCart

func (cr *CartRepo) GetCart(filter interface{}, opts ...*options.FindOneOptions) (*Cart, error)

func (*CartRepo) GetCarts

func (cr *CartRepo) GetCarts(filter interface{}, opts ...*options.FindOptions) ([]*Cart, error)

func (*CartRepo) UpdateCart

func (cr *CartRepo) UpdateCart(filter interface{}, update interface{}, opts ...*options.UpdateOptions) error

type CartRepository

type CartRepository interface {
	CreateCart(cart *Cart) error
	UpdateCart(filter interface{}, update interface{}, opts ...*options.UpdateOptions) error
	GetCart(filter interface{}, opts ...*options.FindOneOptions) (*Cart, error)
	GetCarts(filter interface{}, opts ...*options.FindOptions) ([]*Cart, error)
}

type CartService

type CartService struct {
	// contains filtered or unexported fields
}

func NewCartService

func NewCartService(cartRepository CartRepository, itemRepository ItemRepository) *CartService

func (*CartService) AddToCart

func (cs *CartService) AddToCart(userid primitive.ObjectID, cartItem CartItem) *errors.AppError

func (*CartService) GetCart

func (cs *CartService) GetCart(userid primitive.ObjectID) (*Cart, *errors.AppError)

func (*CartService) RemoveFromCart

func (cs *CartService) RemoveFromCart(userid primitive.ObjectID, cartItem CartItem) *errors.AppError

type CartServices

type CartServices interface {
	AddToCart(userid primitive.ObjectID, cartItem CartItem) *errors.AppError
	RemoveFromCart(userid primitive.ObjectID, cartItem CartItem) *errors.AppError
	GetCart(userid primitive.ObjectID) (*Cart, *errors.AppError)
}

type ItemRepository

type ItemRepository interface {
	GetItem(filter interface{}, opts ...*options.FindOneOptions) (*item.Item, error)
	UpdateItem(filter interface{}, update interface{}, opts ...*options.UpdateOptions) error
}

Jump to

Keyboard shortcuts

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