interfaces

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: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminRepository

type AdminRepository interface {
	FindAdminByEmail(ctx context.Context, email string) (domain.Admin, error)
	FindAdminByUserName(ctx context.Context, userName string) (domain.Admin, error)
	SaveAdmin(ctx context.Context, admin domain.Admin) error

	FindAllUser(ctx context.Context, pagination request.Pagination) (users []response.User, err error)

	CreateFullSalesReport(ctc context.Context, reqData request.SalesReport) (salesReport []response.SalesReport, err error)

	//stock side
	FindStockBySKU(ctx context.Context, sku string) (stock response.Stock, err error)
}

type AuthRepository

type AuthRepository interface {
	SaveRefreshSession(ctx context.Context, refreshSession domain.RefreshSession) error
	FindRefreshSessionByTokenID(ctx context.Context, tokenID string) (domain.RefreshSession, error)

	SaveOtpSession(ctx context.Context, otpSession domain.OtpSession) error
	FindOtpSession(ctx context.Context, otpID string) (domain.OtpSession, error)
}

//go:generate mockgen -destination=../../mock/mockrepo/auth_mock.go -package=mockrepo . AuthRepository

type BrandRepository

type BrandRepository interface {
	IsExist(brand domain.Brand) (bool, error)
	Save(brand domain.Brand) (domain.Brand, error)
	Update(brand domain.Brand) error
	FindAll(pagination request.Pagination) ([]domain.Brand, error)
	FindOne(brandID uint) (domain.Brand, error)
	Delete(brandID uint) error
}

type CartRepository

type CartRepository interface {
	FindCartByUserID(ctx context.Context, userID uint) (cart domain.Cart, err error)
	SaveCart(ctx context.Context, userID uint) (cartID uint, err error)
	UpdateCart(ctx context.Context, cartId, discountAmount, couponID uint) error

	FindCartItemByCartAndProductItemID(ctx context.Context, cartID, productItemID uint) (cartItem domain.CartItem, err error)
	FindAllCartItemsByCartID(ctx context.Context, cartID uint) (cartItems []response.CartItem, err error)
	SaveCartItem(ctx context.Context, cartId, productItemId uint) error
	DeleteCartItem(ctx context.Context, cartItemID uint) error
	DeleteAllCartItemsByCartID(ctx context.Context, cartID uint) error
	UpdateCartItemQty(ctx context.Context, cartItemId, qty uint) error

	IsCartValidForOrder(ctx context.Context, userID uint) (valid bool, err error)
}

type CouponRepository

type CouponRepository interface {
	CheckCouponDetailsAlreadyExist(ctx context.Context, coupon domain.Coupon) (couponID uint, err error)
	FindCouponByID(ctx context.Context, couponID uint) (coupon domain.Coupon, err error)

	FindCouponByCouponCode(ctx context.Context, couponCode string) (coupon domain.Coupon, err error)
	FindCouponByName(ctx context.Context, couponName string) (coupon domain.Coupon, err error)

	FindAllCoupons(ctx context.Context, pagination request.Pagination) (coupons []domain.Coupon, err error)
	SaveCoupon(ctx context.Context, coupon domain.Coupon) error
	UpdateCoupon(ctx context.Context, coupon domain.Coupon) error

	// uses coupon
	FindCouponUsesByCouponAndUserID(ctx context.Context, userID, couopnID uint) (couponUses domain.CouponUses, err error)
	SaveCouponUses(ctx context.Context, couponUses domain.CouponUses) error

	// find all coupon for user
	FindAllCouponForUser(ctx context.Context, userID uint, pagination request.Pagination) (coupons []response.UserCoupon, err error)
}

type OfferRepository

type OfferRepository interface {
	Transactions(ctx context.Context, trxFn func(repo OfferRepository) error) error

	// offer
	FindOfferByID(ctx context.Context, offerID uint) (domain.Offer, error)
	FindOfferByName(ctx context.Context, offerName string) (domain.Offer, error)
	FindAllOffers(ctx context.Context, pagination request.Pagination) ([]domain.Offer, error)
	SaveOffer(ctx context.Context, offer request.Offer) error
	DeleteOffer(ctx context.Context, offerID uint) error

	// to calculate the discount price and update
	UpdateProductsDiscountByCategoryOfferID(ctx context.Context, categoryOfferID uint) error
	UpdateProductItemsDiscountByCategoryOfferID(ctx context.Context, categoryOfferID uint) error
	UpdateProductsDiscountByProductOfferID(ctx context.Context, productOfferID uint) error
	UpdateProductItemsDiscountByProductOfferID(ctx context.Context, productOfferID uint) error

	// to remove the discount product price
	RemoveProductsDiscountByCategoryOfferID(ctx context.Context, categoryOfferID uint) error
	RemoveProductItemsDiscountByCategoryOfferID(ctx context.Context, categoryOfferID uint) error
	RemoveProductsDiscountByProductOfferID(ctx context.Context, productOfferID uint) error
	RemoveProductItemsDiscountByProductOfferID(ctx context.Context, productOfferID uint) error

	// offer category
	FindOfferCategoryCategoryID(ctx context.Context, categoryID uint) (domain.OfferCategory, error)
	FindAllOfferCategories(ctx context.Context, pagination request.Pagination) ([]response.OfferCategory, error)

	SaveCategoryOffer(ctx context.Context, categoryOffer request.OfferCategory) (categoryOfferID uint, err error)
	DeleteCategoryOffer(ctx context.Context, categoryOfferID uint) error
	UpdateCategoryOffer(ctx context.Context, categoryOfferID, offerID uint) error

	// offer products
	FindOfferProductByProductID(ctx context.Context, productID uint) (domain.OfferProduct, error)
	FindAllOfferProducts(ctx context.Context, pagination request.Pagination) ([]response.OfferProduct, error)

	SaveOfferProduct(ctx context.Context, offerProduct domain.OfferProduct) (productOfferId uint, err error)
	DeleteOfferProduct(ctx context.Context, productOfferID uint) error
	UpdateOfferProduct(ctx context.Context, productOfferID, offerID uint) error

	DeleteAllProductOffersByOfferID(ctx context.Context, offerID uint) error
	DeleteAllCategoryOffersByOfferID(ctx context.Context, offerID uint) error
}

type OrderRepository

type OrderRepository interface {
	Transaction(callBack func(transactionRepo OrderRepository) error) error

	SaveOrderLine(ctx context.Context, orderLine domain.OrderLine) error

	UpdateShopOrderOrderStatus(ctx context.Context, shopOrderID, changeStatusID uint) error
	UpdateShopOrderStatusAndSavePaymentMethod(ctx context.Context, shopOrderID, orderStatusID, paymentID uint) error

	// shop order order
	SaveShopOrder(ctx context.Context, shopOrder domain.ShopOrder) (shopOrderID uint, err error)
	FindShopOrderByShopOrderID(ctx context.Context, shopOrderID uint) (domain.ShopOrder, error)
	FindAllShopOrders(ctx context.Context, pagination request.Pagination) (shopOrders []response.ShopOrder, err error)
	FindAllShopOrdersByUserID(ctx context.Context, userID uint, pagination request.Pagination) ([]response.ShopOrder, error)

	// find shop order items
	FindAllOrdersItemsByShopOrderID(ctx context.Context,
		shopOrderID uint, pagination request.Pagination) (orderItems []response.OrderItem, err error)

	// order status
	FindOrderStatusByShopOrderID(ctx context.Context, shopOrderID uint) (domain.OrderStatus, error)
	FindOrderStatusByID(ctx context.Context, orderStatusID uint) (domain.OrderStatus, error)
	FindOrderStatusByStatus(ctx context.Context, orderStatus domain.OrderStatusType) (domain.OrderStatus, error)
	FindAllOrderStatuses(ctx context.Context) ([]domain.OrderStatus, error)

	//order return
	FindOrderReturnByReturnID(ctx context.Context, orderReturnID uint) (domain.OrderReturn, error)
	FindOrderReturnByShopOrderID(ctx context.Context, shopOrderID uint) (orderReturn domain.OrderReturn, err error)
	FindAllOrderReturns(ctx context.Context, pagination request.Pagination) ([]response.OrderReturn, error)
	FindAllPendingOrderReturns(ctx context.Context, pagination request.Pagination) ([]response.OrderReturn, error)
	SaveOrderReturn(ctx context.Context, orderReturn domain.OrderReturn) error
	UpdateOrderReturn(ctx context.Context, orderReturn domain.OrderReturn) error

	// wallet
	FindWalletByUserID(ctx context.Context, userID uint) (wallet domain.Wallet, err error)
	SaveWallet(ctx context.Context, userID uint) (walletID uint, err error)
	UpdateWallet(ctx context.Context, walletID, updateTotalAmount uint) error
	SaveWalletTransaction(ctx context.Context, walletTrx domain.Transaction) error

	FindWalletTransactions(ctx context.Context, walletID uint,
		pagination request.Pagination) (transaction []domain.Transaction, err error)
}

type PaymentRepository

type PaymentRepository interface {
	FindPaymentMethodByID(ctx context.Context, paymentMethodID uint) (paymentMethods domain.PaymentMethod, err error)
	FindPaymentMethodByType(ctx context.Context, paymentType domain.PaymentType) (paymentMethod domain.PaymentMethod, err error)
	FindAllPaymentMethods(ctx context.Context) ([]domain.PaymentMethod, error)
	UpdatePaymentMethod(ctx context.Context, paymentMethod request.PaymentMethodUpdate) error
}

type ProductRepository

type ProductRepository interface {
	Transactions(ctx context.Context, trxFn func(repo ProductRepository) error) error

	// category
	IsCategoryNameExist(ctx context.Context, categoryName string) (bool, error)
	FindAllMainCategories(ctx context.Context, pagination request.Pagination) ([]response.Category, error)
	SaveCategory(ctx context.Context, categoryName string) error

	// sub category
	IsSubCategoryNameExist(ctx context.Context, categoryName string, categoryID uint) (bool, error)
	FindAllSubCategories(ctx context.Context, categoryID uint) ([]response.SubCategory, error)
	SaveSubCategory(ctx context.Context, categoryID uint, categoryName string) error

	// variation
	IsVariationNameExistForCategory(ctx context.Context, name string, categoryID uint) (bool, error)
	SaveVariation(ctx context.Context, categoryID uint, variationName string) error
	FindAllVariationsByCategoryID(ctx context.Context, categoryID uint) ([]response.Variation, error)

	// variation values
	IsVariationValueExistForVariation(ctx context.Context, value string, variationID uint) (exist bool, err error)
	SaveVariationOption(ctx context.Context, variationID uint, variationValue string) error
	FindAllVariationOptionsByVariationID(ctx context.Context, variationID uint) ([]response.VariationOption, error)

	FindAllVariationValuesOfProductItem(ctx context.Context, productItemID uint) ([]response.ProductVariationValue, error)
	//product
	FindProductByID(ctx context.Context, productID uint) (product domain.Product, err error)
	IsProductNameExistForOtherProduct(ctx context.Context, name string, productID uint) (bool, error)
	IsProductNameExist(ctx context.Context, productName string) (exist bool, err error)

	FindAllProducts(ctx context.Context, pagination request.Pagination) ([]response.Product, error)
	SaveProduct(ctx context.Context, product domain.Product) error
	UpdateProduct(ctx context.Context, product domain.Product) error

	// product items
	FindProductItemByID(ctx context.Context, productItemID uint) (domain.ProductItem, error)
	FindAllProductItems(ctx context.Context, productID uint) ([]response.ProductItems, error)
	FindVariationCountForProduct(ctx context.Context, productID uint) (variationCount uint, err error) // to check the product config already exist
	FindAllProductItemIDsByProductIDAndVariationOptionID(ctx context.Context, productID, variationOptionID uint) ([]uint, error)
	SaveProductConfiguration(ctx context.Context, productItemID, variationOptionID uint) error
	SaveProductItem(ctx context.Context, productItem domain.ProductItem) (productItemID uint, err error)
	// product item image
	FindAllProductItemImages(ctx context.Context, productItemID uint) (images []string, err error)
	SaveProductItemImage(ctx context.Context, productItemID uint, image string) error
}

type StockRepository

type StockRepository interface {
	FindAll(ctx context.Context, pagination request.Pagination) (stocks []response.Stock, err error)
	Update(ctx context.Context, updateValues request.UpdateStock) error
}

type UserRepository

type UserRepository interface {
	FindUserByUserID(ctx context.Context, userID uint) (user domain.User, err error)
	FindUserByEmail(ctx context.Context, email string) (user domain.User, err error)
	FindUserByUserName(ctx context.Context, userName string) (user domain.User, err error)
	FindUserByPhoneNumber(ctx context.Context, phoneNumber string) (user domain.User, err error)
	FindUserByUserNameEmailOrPhoneNotID(ctx context.Context, user domain.User) (domain.User, error)

	SaveUser(ctx context.Context, user domain.User) (userID uint, err error)
	UpdateVerified(ctx context.Context, userID uint) error
	UpdateUser(ctx context.Context, user domain.User) (err error)
	UpdateBlockStatus(ctx context.Context, userID uint, blockStatus bool) error

	//address
	FindCountryByID(ctx context.Context, countryID uint) (domain.Country, error)
	FindAddressByID(ctx context.Context, addressID uint) (response.Address, error)
	IsAddressIDExist(ctx context.Context, addressID uint) (exist bool, err error)
	IsAddressAlreadyExistForUser(ctx context.Context, address domain.Address, userID uint) (bool, error)
	FindAllAddressByUserID(ctx context.Context, userID uint) ([]response.Address, error)
	SaveAddress(ctx context.Context, address domain.Address) (addressID uint, err error)
	UpdateAddress(ctx context.Context, address domain.Address) error
	// address join table
	SaveUserAddress(ctx context.Context, userAdress domain.UserAddress) error
	UpdateUserAddress(ctx context.Context, userAddress domain.UserAddress) error

	//wishlist
	FindWishListItem(ctx context.Context, productID, userID uint) (domain.WishList, error)
	FindAllWishListItemsByUserID(ctx context.Context, userID uint) ([]response.WishListItem, error)
	SaveWishListItem(ctx context.Context, wishList domain.WishList) error
	RemoveWishListItem(ctx context.Context, userID, productItemID uint) error
}

Jump to

Keyboard shortcuts

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