biz

package
v0.0.0-...-657e486 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(NewCartUsecase)

ProviderSet is biz providers.

Functions

This section is empty.

Types

type Cart

type Cart struct {
	UserId string     `json:"user_id"`
	Items  []CartItem `json:"items,omitempty"`
}

Cart is a Cart model.

type CartItem

type CartItem struct {
	ProductId string `json:"product_id"`
	Quantity  int32  `json:"quantity"`
}

type CartRepo

type CartRepo interface {
	Empty(context.Context, string) error
	AddItem(context.Context, string, *CartItem) error
	Get(context.Context, string) (*Cart, error)
}

CartRepo is a Cart repo.

type CartUsecase

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

CartUsecase is a Cart usecase.

func NewCartUsecase

func NewCartUsecase(repo CartRepo, logger log.Logger) *CartUsecase

NewCartUsecase new a Cart usecase.

func (*CartUsecase) AddItem

func (uc *CartUsecase) AddItem(ctx context.Context, userId string, item *CartItem) error

AddItem add cart item into a cart for a user.

func (*CartUsecase) Empty

func (uc *CartUsecase) Empty(ctx context.Context, userId string) error

EmptyCart clear all items in a cart.

func (*CartUsecase) GetCart

func (uc *CartUsecase) GetCart(ctx context.Context, userId string) (*Cart, error)

GetCart get cart of a user.

Jump to

Keyboard shortcuts

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