Documentation ¶
Index ¶
- Constants
- Variables
- func NewContextWithUser(ctx context.Context, u *User) context.Context
- type AuthService
- type BaseProduct
- type Category
- type CategoryService
- type FilterOption
- type GetProductsByCategoryParams
- type Product
- type ProductPricing
- type ProductRating
- type ProductService
- type ProductStatus
- type Rating
- type Role
- type SKU
- type SKUPricing
- type SellerStore
- type SortOption
- type User
- type UserService
- type UserStatus
Constants ¶
View Source
const (
EINTERNALMSG = "Something went wrong. Please try again later."
)
Variables ¶
View Source
var ( ErrNotFound = errors.New("not found") ErrUserExists = errors.New("user exists") )
Functions ¶
Types ¶
type AuthService ¶
type AuthService interface { Signup(ctx context.Context, name, email, password string) error SignupConfirm(ctx context.Context, otp, email string) error Signin(ctx context.Context, email, password string) (int64, error) ResendOTP(ctx context.Context, email string) error SendResetPasswordLink(ctx context.Context, email string) error VerifyResetPasswordToken(ctx context.Context, token string) (bool, error) ResetPassword(ctx context.Context, token string, password string) error }
type BaseProduct ¶
type BaseProduct struct { ID int64 StoreID int32 CategoryID int32 Name string Brand string Slug string ShortInfo []string ThumbImg string // thumbnail image link ThumbImgUrls map[string]string ImageLinks map[int]string Specs map[string]string // product item specifications, e.g. Ebay Status ProductStatus CreatedAt time.Time UpdatedAt time.Time }
type CategoryService ¶
type CategoryService interface { GetCategory(ctx context.Context, id int32) (Category, error) GetAncestorCategories(ctx context.Context, id int32) ([]Category, error) GetSiblingCategories(ctx context.Context, id int32) ([]Category, error) GetChildCategories(ctx context.Context, id int32) ([]Category, error) }
type FilterOption ¶
type GetProductsByCategoryParams ¶
type GetProductsByCategoryParams struct { FilterOption FilterOption SortOption SortOption Offset int Limit int }
type Product ¶
type Product struct { BaseProduct Store SellerStore Category Category SKUs []SKU Pricing ProductPricing Rating Rating // Rating is calculated using Reviews (in the future, using also some statistical method) Reviews []ProductRating // Product Reviews SoldCount int LeftCount int Attributes map[string][]string // attributes with their values, e.g. color, size }
type ProductPricing ¶
type ProductRating ¶
type ProductService ¶
type ProductService interface { GetProduct(ctx context.Context, id int64) (*Product, error) GetProductsByLeafCategoryID(ctx context.Context, categoryID int32, params GetProductsByCategoryParams) ([]Product, int64, error) GetProductsByNonLeafCategoryID(ctx context.Context, categoryID int32, params GetProductsByCategoryParams) ([]Product, int64, error) }
type ProductStatus ¶
type ProductStatus string
const ( ProductStatusDraft ProductStatus = "Draft" ProductStatusPendingApproval ProductStatus = "PendingApproval" ProductStatusActive ProductStatus = "Active" )
type SKUPricing ¶
type SellerStore ¶
type SortOption ¶
type SortOption string
const ( SortOptionBestMatch SortOption = "BestMatch" SortOptionPriceHighToLow SortOption = "PriceHighToLow" SortOptionPriceLowToHigh SortOption = "PriceLowToHigh" SortOptionHighestRated SortOption = "HighestRated" SortOptionNewArrivals SortOption = "NewArrivals" SortOptionBestSellers SortOption = "BestSellers" )
type User ¶
type User struct { ID int64 Email string Password string PhoneNumber string FullName string Status UserStatus OTP string OTPExpiry int64 CreatedAt time.Time UpdatedAt time.Time Roles []Role }
func UserFromContext ¶
UserFromContext FromContext returns the User value stored in ctx, if any.
func (User) GetFirstname ¶
type UserService ¶
type UserService interface { CreateUser(ctx context.Context, user User) error GetUser(ctx context.Context, id int64) (User, error) GetUserByEmail(ctx context.Context, email string) (User, error) UpdateUserStatus(ctx context.Context, status UserStatus, id int64) error UpdateUserOTP(ctx context.Context, id int64, otp string, otpExpiry int64) error UpdateUserPassword(ctx context.Context, id int64, password string) error }
type UserStatus ¶
type UserStatus string
const ( UserStatusBlocked UserStatus = "Blocked" UserStatusRegistrationPending UserStatus = "RegistrationPending" UserStatusActive UserStatus = "Active" UserStatusInactive UserStatus = "Inactive" )
Source Files ¶
Click to show internal directories.
Click to hide internal directories.