usecase

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

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessTokenDuration  = time.Minute * 20
	RefreshTokenDuration = time.Hour * 24 * 7
)

Variables

View Source
var (
	// login
	ErrEmptyLoginCredentials = errors.New("all login credentials are empty")
	ErrUserNotExist          = errors.New("user not exist with given login credentials")
	ErrUserNotVerified       = errors.New("user not verified")
	ErrUserBlocked           = errors.New("user blocked by admin")
	ErrWrongPassword         = errors.New("password doesn't match")
	// otp
	ErrOtpExpired = errors.New("otp session expired")
	ErrInvalidOtp = errors.New("invalid otp")

	// refresh token
	ErrInvalidRefreshToken    = errors.New("invalid refresh token")
	ErrRefreshSessionNotExist = errors.New("there is no refresh token session for this token")
	ErrRefreshSessionExpired  = errors.New("refresh token expired in session")
	ErrRefreshSessionBlocked  = errors.New("refresh token blocked in session")

	// signup
	ErrUserAlreadyExit = errors.New("user already exist")

	// cart
	ErrProductItemOutOfStock = errors.New("product is now out of stock")
	ErrCartItemAlreadyExist  = errors.New("product_item already exist on the cart")
	ErrCartItemNotExit       = errors.New("product_item not exist on cart")
	ErrEmptyCart             = errors.New("user cart is empty")

	ErrRequireMinimumCartItemQty = errors.New("update cart item qty can not less than 1")
	ErrInvalidCartItemUpdateQty  = errors.New("update cart item qty reached max limit")

	// admin
	ErrSameBlockStatus = errors.New("user block status already in given status")

	//category
	ErrCategoryAlreadyExist = errors.New("category already exist")

	// variation
	ErrVariationAlreadyExist       = errors.New("variation already exist")
	ErrVariationOptionAlreadyExist = errors.New("variation already exist")

	// product
	ErrProductAlreadyExist = errors.New("product already exist with this name")

	// product item
	ErrProductItemAlreadyExist = errors.New("product item already exist with this configuration")
	ErrNotEnoughVariations     = errors.New("not enough variation options for this product select one variation option from each variation")

	// offer
	ErrOfferNameAlreadyExist = errors.New("offer already exist this name")
	ErrInvalidOfferEndDate   = errors.New("invalid offer end date")
	ErrOfferAlreadyEnded     = errors.New("offer already ended")

	ErrCategoryOfferAlreadyExist = errors.New("an offer already exist for this category")
	ErrProductOfferAlreadyExist  = errors.New("an offer already exist for this product")

	// order
	ErrOutOfStockOnCart = errors.New("cart is not valid for order out of stock is in cart")

	// wish list
	ErrExistWishListProductItem = errors.New("product item already exist on wish list")

	//  payment
	ErrBlockedPayment          = errors.New("selected payment is blocked by admin")
	ErrPaymentAmountReachedMax = errors.New("order total price reached payment method maximum amount")
	ErrPaymentNotApproved      = errors.New("payment not approved")

	// brand
	ErrBrandAlreadyExist = errors.New("brand name already exist")
)

Functions

func NewAuthUseCase

func NewAuthUseCase(authRepo interfaces.AuthRepository, tokenService token.TokenService,
	userRepo interfaces.UserRepository, adminRepo interfaces.AdminRepository,
	optAuth otp.OtpAuth) service.AuthUseCase

func NewCartUseCase

func NewCartUseCase(cartRepo interfaces.CartRepository, productRepo interfaces.ProductRepository) service.CartUseCase

func NewOfferUseCase

func NewOfferUseCase(offerRepo repo.OfferRepository) interfaces.OfferUseCase

func NewProductUseCase

func NewProductUseCase(productRepo interfaces.ProductRepository, cloudService cloud.CloudService) service.ProductUseCase

to get a new instance of productUseCase

func NewStockUseCase

func NewStockUseCase(stockRepo interfaces.StockRepository) service.StockUseCase

Types

type OrderUseCase

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

func (*OrderUseCase) CancelOrder

func (c *OrderUseCase) CancelOrder(ctx context.Context, shopOrderID uint) error

func (*OrderUseCase) FindAllOrderReturns

func (c *OrderUseCase) FindAllOrderReturns(ctx context.Context, pagination request.Pagination) ([]response.OrderReturn, error)

to get all order return

func (*OrderUseCase) FindAllOrderStatuses

func (c *OrderUseCase) FindAllOrderStatuses(ctx context.Context) ([]domain.OrderStatus, error)

get all order statuses

func (*OrderUseCase) FindAllPendingOrderReturns

func (c *OrderUseCase) FindAllPendingOrderReturns(ctx context.Context, pagination request.Pagination) ([]response.OrderReturn, error)

to get pending order returns

func (*OrderUseCase) FindAllShopOrders

func (c *OrderUseCase) FindAllShopOrders(ctx context.Context, pagination request.Pagination) ([]response.ShopOrder, error)

func to Find all shop order

func (*OrderUseCase) FindOrderItems

func (c *OrderUseCase) FindOrderItems(ctx context.Context, shopOrderID uint,
	pagination request.Pagination) (orderItems []response.OrderItem, err error)

func (*OrderUseCase) FindUserShopOrder

func (c *OrderUseCase) FindUserShopOrder(ctx context.Context, userID uint,
	pagination request.Pagination) ([]response.ShopOrder, error)

Find all orders of a user

func (*OrderUseCase) FindUserWallet

func (c *OrderUseCase) FindUserWallet(ctx context.Context, userID uint) (wallet domain.Wallet, err error)

func (*OrderUseCase) FindUserWalletTransactions

func (c *OrderUseCase) FindUserWalletTransactions(ctx context.Context,
	userID uint, pagination request.Pagination) (transactions []domain.Transaction, err error)

func (*OrderUseCase) SaveOrder

func (c *OrderUseCase) SaveOrder(ctx context.Context, userID, addressID uint) (uint, error)

Save order

func (*OrderUseCase) SubmitReturnRequest

func (c *OrderUseCase) SubmitReturnRequest(ctx context.Context, returnDetails request.Return) error

func (*OrderUseCase) UpdateOrderStatus

func (c *OrderUseCase) UpdateOrderStatus(ctx context.Context, shopOrderID, changeStatusID uint) error

update order

func (*OrderUseCase) UpdateReturnDetails

func (c *OrderUseCase) UpdateReturnDetails(ctx context.Context, updateDetails request.UpdateOrderReturn) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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