usecase

package
v0.0.0-...-4c8fc35 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFRCreateDatabaseTransaction = fiber.NewError(fiber.StatusInternalServerError, "failed+to+create+database+transaction")
	ErrFRFailedToReadData          = fiber.NewError(fiber.StatusInternalServerError, "failed+to+get+data+from+database")
	ErrFRNotFacebookUser           = fiber.NewError(fiber.StatusConflict, "account+registered+using+Facebook.+Please+login+using+Facebook.")
	ErrFRNotGoogleUser             = fiber.NewError(fiber.StatusConflict, "account+registered+using+Google.+Please+login+using+Google.")
	ErrFRCreateToken               = fiber.NewError(fiber.StatusInternalServerError, "failed+to+create+token")
	ErrFRFailedToStoreData         = fiber.NewError(fiber.StatusInternalServerError, "failed+to+store+data")
	ErrFRFailedToUpdateData        = fiber.NewError(fiber.StatusInternalServerError, "failed+to+update+data")
)

general error

View Source
var (
	ErrCreateDatabaseTransaction = fiber.NewError(fiber.StatusInternalServerError, "failed to create database transaction")
	ErrFailedToReadData          = fiber.NewError(fiber.StatusInternalServerError, "failed to get data from database")
	ErrInvalidToken              = fiber.NewError(fiber.StatusUnauthorized, "invalid token")
	ErrFailedToMarshal           = fiber.NewError(fiber.StatusInternalServerError, "failed to marshal")
	ErrFailedToUnMarshal         = fiber.NewError(fiber.StatusInternalServerError, "failed to unmarshal")
	ErrDuplicateUser             = fiber.NewError(fiber.StatusConflict, "duplicate user")
	ErrFailedToClearData         = fiber.NewError(fiber.StatusInternalServerError, "failed to clear data")
	ErrFailedToStoreData         = fiber.NewError(fiber.StatusInternalServerError, "failed to store data")
	ErrFailedToGeneratePassword  = fiber.NewError(fiber.StatusInternalServerError, "failed to generate password")
	ErrFailedToGenerateCode      = fiber.NewError(fiber.StatusInternalServerError, "failed to generate code")
	ErrFailedToSendEmail         = fiber.NewError(fiber.StatusInternalServerError, "failed to send email")
	ErrFailedToVerifyAccount     = fiber.NewError(fiber.StatusConflict, "failed to verify account")
	ErrSendEmailLimitExceeded    = fiber.NewError(fiber.StatusTooManyRequests, "limit to send email exceeded")
	ErrFailedToUpdateData        = fiber.NewError(fiber.StatusInternalServerError, "failed to update data")
	ErrWrongPassword             = fiber.NewError(fiber.StatusUnauthorized, "password you entered is incorrect")
	ErrNeedEmailVerification     = fiber.NewError(fiber.StatusUnauthorized, "please verify your account first")
	ErrLoginTypeOAuth            = fiber.NewError(fiber.StatusUnauthorized, "please login with oauth")
	ErrCreateToken               = fiber.NewError(fiber.StatusInternalServerError, "failed to create token")
	ErrCalculateShipping         = fiber.NewError(fiber.StatusInternalServerError, "failed to calculate shipping cost and estimated days")
	ErrParseStringToNumber       = fiber.NewError(fiber.StatusInternalServerError, "failed to parse string to number")
	ErrOutOfStock                = fiber.NewError(fiber.StatusBadRequest, "failed to add product because out of stock")
)

Functions

func NewCartUseCase

func NewCartUseCase(DB *sqlx.DB,
	log *logrus.Logger,
	redis *redis.Client,
	cartRepository repositoryInterface.CartRepository,
	productRepository repositoryInterface.ProductRepository,
	userRepository repositoryInterface.UserRepository) interfaces.CartUseCase

func NewMenuUseCase

func NewMenuUseCase(DB *sqlx.DB, log *logrus.Logger, redis *redis.Client, userRepository repositoryInterface.UserRepository,
	cartRepository repositoryInterface.CartRepository, propertyRepository repositoryInterface.PropertyRepository,
	productRepository repositoryInterface.ProductRepository, educationRepository repositoryInterface.EducationRepository) interfaces.MenuUseCase

func NewProductUseCase

func NewProductUseCase(DB *sqlx.DB,
	log *logrus.Logger,
	redis *redis.Client,
	addressRepository repositoryInterface.AddressRepository,
	productRepository repositoryInterface.ProductRepository,
	productMediaRepository repositoryInterface.ProductMediaRepository,
	ratingRepository repositoryInterface.RatingRepository,
	cartRepository repositoryInterface.CartRepository,
	userRepository repositoryInterface.UserRepository) interfaces.ProductUseCase

func NewPropertyUseCase

func NewPropertyUseCase(DB *sqlx.DB, log *logrus.Logger, redis *redis.Client,
	propertyRepository repositoryInterface.PropertyRepository,
	propertyRatingRepository repositoryInterface.PropertyRatingRepository,
	discussRepository repositoryInterface.DiscussRepository,
	wishlistRepository repositoryInterface.WishlistRepository,
	userRepository repositoryInterface.UserRepository,
	cartRepository repositoryInterface.CartRepository) interfaces.PropertyUseCase

func NewUserUseCase

func NewUserUseCase(DB *sqlx.DB, log *logrus.Logger, redis *redis.Client, userRepository repositoryInterface.UserRepository, addressRepository repositoryInterface.AddressRepository, refreshRepository repositoryInterface.RefreshRepository) interfaces.UserUseCase

func NewWishlistUseCase

func NewWishlistUseCase(DB *sqlx.DB, log *logrus.Logger, redis *redis.Client, wishlistRepository repositoryInterface.WishlistRepository, userRepository repositoryInterface.UserRepository, cartRepository repositoryInterface.CartRepository) interfaces.WishlistUseCase

Types

type CartUseCase

type CartUseCase struct {
	DB             *sqlx.DB
	Log            *logrus.Logger
	Redis          *redis.Client
	UserRepository repositoryInterface.UserRepository
	CartRepository repositoryInterface.CartRepository
	ProductUseCase repositoryInterface.ProductRepository
}

func (*CartUseCase) GetMyCart

func (u *CartUseCase) GetMyCart(ctx context.Context, userID string) (*response.MyCart, error)

func (*CartUseCase) ManageCart

func (u *CartUseCase) ManageCart(ctx context.Context, userID string, req *request.ManageCart) (*response.ManageCart, error)
type MenuUseCase struct {
	DB                  *sqlx.DB
	Log                 *logrus.Logger
	Redis               *redis.Client
	UserRepository      repositoryInterface.UserRepository
	CartRepository      repositoryInterface.CartRepository
	PropertyRepository  repositoryInterface.PropertyRepository
	ProductRepository   repositoryInterface.ProductRepository
	EducationRepository repositoryInterface.EducationRepository
}
func (u *MenuUseCase) Education(ctx context.Context, userID string) (*response.Education, error)
func (u *MenuUseCase) EducationDetails(ctx context.Context, userID, educationID string) (*response.EducationDetails, error)
func (u *MenuUseCase) Homepage(ctx context.Context, userID string) (*response.Homepage, error)
func (u *MenuUseCase) Market(ctx context.Context, userID string) (*response.Market, error)

type ProductUseCase

type ProductUseCase struct {
	//
	DB                     *sqlx.DB
	Log                    *logrus.Logger
	Redis                  *redis.Client
	AddressRepository      repositoryInterface.AddressRepository
	ProductRepository      repositoryInterface.ProductRepository
	ProductMediaRepository repositoryInterface.ProductMediaRepository
	RatingRepository       repositoryInterface.RatingRepository
	CartRepository         repositoryInterface.CartRepository
	UserRepository         repositoryInterface.UserRepository
}

func (*ProductUseCase) GetProductDetails

func (u *ProductUseCase) GetProductDetails(ctx context.Context, userID, productID string) (*response.GetProductDetails, error)

func (*ProductUseCase) GetProductReviews

func (u *ProductUseCase) GetProductReviews(ctx context.Context, userID, productID, sortBy string, page int) (*response.ReviewDetails, error)

func (*ProductUseCase) GetProducts

func (u *ProductUseCase) GetProducts(ctx context.Context, userID, categoryName, sortBy string, page int) (*response.GetProductWithPagination, error)

type PropertyUseCase

type PropertyUseCase struct {
	DB                       *sqlx.DB
	Log                      *logrus.Logger
	Redis                    *redis.Client
	PropertyRepository       repositoryInterface.PropertyRepository
	PropertyRatingRepository repositoryInterface.PropertyRatingRepository
	DiscussRepository        repositoryInterface.DiscussRepository
	WishlistRepository       repositoryInterface.WishlistRepository
	UserRepository           repositoryInterface.UserRepository
	CartRepository           repositoryInterface.CartRepository
}

func (*PropertyUseCase) GetAllWishlistsProperties

func (u *PropertyUseCase) GetAllWishlistsProperties(ctx context.Context, userID string) (*response.PropertiesWishlist, error)

func (*PropertyUseCase) GetProperties

func (u *PropertyUseCase) GetProperties(ctx context.Context, userID, categoryName, sortBy, province string, page int) (*response.GetPropertiesWithPagination, error)

func (*PropertyUseCase) GetPropertyDetails

func (u *PropertyUseCase) GetPropertyDetails(ctx context.Context, userID, propertyID string) (*response.GetPropertyDetails, error)

func (*PropertyUseCase) ManageWishlistProperties

type UserUseCase

type UserUseCase struct {
	DB                *sqlx.DB
	Log               *logrus.Logger
	Redis             *redis.Client
	UserRepository    repositoryInterface.UserRepository
	AddressRepository repositoryInterface.AddressRepository
	RefreshRepository repositoryInterface.RefreshRepository
}

func (*UserUseCase) FacebookCallBack

func (u *UserUseCase) FacebookCallBack(ctx context.Context, profile *response.FetchFacebookProfile) (*response.OAuth, error)

func (*UserUseCase) GoogleCallBack

func (u *UserUseCase) GoogleCallBack(ctx context.Context, profile *response.FetchGoogleProfile) (*response.OAuth, error)

func (*UserUseCase) Login

func (*UserUseCase) Logout

func (u *UserUseCase) Logout(ctx context.Context, refreshToken string) error

func (*UserUseCase) RegisterWithEmailPassword

func (u *UserUseCase) RegisterWithEmailPassword(ctx context.Context, req *request.Register) error

func (*UserUseCase) RegisterWithOAuth

func (u *UserUseCase) RegisterWithOAuth(ctx context.Context, req *request.FinishRegisterOAuth) (*response.FinishRegister, error)

func (*UserUseCase) RenewAccessToken

func (u *UserUseCase) RenewAccessToken(ctx context.Context, refreshToken string) (*response.FinishRegister, error)

func (*UserUseCase) SendVerificationCodeForRegister

func (u *UserUseCase) SendVerificationCodeForRegister(ctx context.Context, req *request.PostRegister) error

func (*UserUseCase) VerifySixCode

type WishlistUseCase

type WishlistUseCase struct {
	DB                 *sqlx.DB
	Log                *logrus.Logger
	Redis              *redis.Client
	WishlistRepository repositoryInterface.WishlistRepository
	UserRepository     repositoryInterface.UserRepository
	CartRepository     repositoryInterface.CartRepository
}

func (*WishlistUseCase) GetAllWishlists

func (u *WishlistUseCase) GetAllWishlists(ctx context.Context, userID string) (*response.ProductWishlist, error)

func (*WishlistUseCase) ManageWishlist

func (u *WishlistUseCase) ManageWishlist(ctx context.Context, userID string, req *request.ManageWishlist) (*response.ManageWishlist, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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