business

package
v0.0.0-...-2551f53 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHavenNoActiveCart    = errors.New("haven no active cart")
	ErrCannotGetCart        = errors.New("cannot get cart")
	ErrCannotCheckout       = errors.New("cannot checkout")
	ErrProductNotFound      = errors.New("product not found")
	ErrNegativeQuantity     = errors.New("quantity must be at least 1")
	ErrCannotAddCartItem    = errors.New("cannot add cart item")
	ErrCannotRemoveCartItem = errors.New("cannot remove cart item")
	ErrNoItems              = errors.New("cart has no items")
)
View Source
var (
	ErrCannotCreateProduct  = errors.New("cannot create product")
	ErrCannotUpdateProduct  = errors.New("cannot update product")
	ErrCannotDeleteProduct  = errors.New("cannot delete product")
	ErrCannotGetProduct     = errors.New("cannot get product")
	ErrProductDeleted       = errors.New("product is deleted")
	ErrCannotGetProductList = errors.New("cannot get all products")
)
View Source
var (
	ErrUserExisted    = errors.New("user existed")
	ErrCannotRegister = errors.New("cannot register")
)
View Source
var (
	ErrEmailOrPasswordInvalid = errors.New("email or password invalid")
)

Functions

func NewAuthBusiness

func NewAuthBusiness(repo repository.Repository, tokenMaker token.TokenMaker) *authBusiness

func NewBusiness

func NewBusiness(repo repository.Repository, tokenMaker token.TokenMaker) *business

func NewCartBusiness

func NewCartBusiness(repo repository.Repository) *cartBusiness

func NewProductBusiness

func NewProductBusiness(repo repository.Repository) *productBusiness

func NewUserBusiness

func NewUserBusiness(repo repository.Repository) *userBusiness

Types

type AuthBusiness

type AuthBusiness interface {
	Login(ctx context.Context, data *model.LoginParams) (interface{}, error)
}

type Business

type Business interface {
	Product() ProductBusiness
	Cart() CartBusiness
	User() UserBusiness
	Auth() AuthBusiness
}

type CartBusiness

type CartBusiness interface {
	AddItem(ctx context.Context, data *model.ModifyCartItemParams) error
	RemoveItem(ctx context.Context, data *model.ModifyCartItemParams) error
	GetByID(ctx context.Context, id *int64) (interface{}, error)
	Checkout(ctx context.Context) (*model.Payment, error)
}

type ProductBusiness

type ProductBusiness interface {
	Create(ctx context.Context, data *model.CreateProductParams) (*model.Product, error)
	Update(ctx context.Context, id int64, data *model.UpdateProductParams) (*model.Product, error)
	DeleteByID(ctx context.Context, id int64) error
	GetByID(ctx context.Context, id int64) (*model.Product, error)
	GetAll(ctx context.Context) ([]model.Product, error)
}

type UserBusiness

type UserBusiness interface {
	Register(ctx context.Context, data *model.CreateUserParams) (*model.User, error)
}

Jump to

Keyboard shortcuts

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