Documentation ¶
Index ¶
- type AdminModel
- type AesEncryptUtil
- type AuthController
- type AuthControllerPayloadGetAccessToken
- type AuthControllerPayloadSignUp
- type AuthMiddleware
- type AuthUsecase
- type AuthUtil
- type CalculatedCart
- type CalculatedPrice
- type CartController
- type CartControllerPayloadCreateCartItem
- type CartControllerPayloadUpdateCartItem
- type CartControllerResponseGetCart
- type CartItemModel
- type CartModel
- type CartRepository
- type CartRepositoryPayloadCreateCartItem
- type CartRepositoryPayloadUpdateCart
- type CartRepositoryPayloadUpdateCartItem
- type CartUsecase
- type CartUsecasePayloadCreateCartItem
- type CartUsecasePayloadDeleteCartItem
- type CartUsecasePayloadUpdateCartItem
- type CartUtil
- type ControllerResponsePropertyCartItem
- type Env
- type HashUtil
- type JWTAccessTokenClaims
- type JWTUtil
- type LoggerUtil
- type Metadata
- type ProductController
- type ProductControllerPayloadCreateProduct
- type ProductControllerPayloadUpdateProduct
- type ProductControllerResponseGetProductByUID
- type ProductControllerResponseListProducts
- type ProductModel
- type ProductRepository
- type ProductRepositoryPayloadCreateProduct
- type ProductRepositoryPayloadUpdateProduct
- type ProductUsecase
- type ProductUsecasePayloadCreateProduct
- type ProductUsecasePayloadUpdateProduct
- type ProductUtil
- type StringSlice
- type UserModel
- type UserRepository
- type UserRepositoryPayloadCreateAdmin
- type UserRepositoryPayloadCreateUser
- type UserUsecase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminModel ¶
type AesEncryptUtil ¶
type AuthController ¶
type AuthMiddleware ¶
type AuthMiddleware interface { ValidateUser() echo.MiddlewareFunc ValidateAdmin() echo.MiddlewareFunc }
Controller
type AuthUsecase ¶
type AuthUsecase interface { SignUp(ctx context.Context, email, password string, isAdmin bool) error GetAccessToken(ctx context.Context, email, password string) (string, error) }
Usecase
type CalculatedCart ¶
type CalculatedPrice ¶
type CartController ¶
type CartController interface { // Cart GetCartByUserID(c echo.Context) error // Cart item CreateCartItem(c echo.Context) error UpdateCartItem(c echo.Context) error DeleteCartItemByUID(c echo.Context) error }
Controller
type CartControllerPayloadUpdateCartItem ¶
type CartControllerPayloadUpdateCartItem struct {
Quantity int `json:"quantity"`
}
type CartControllerResponseGetCart ¶
type CartControllerResponseGetCart struct { UID string `db:"uid" json:"uid"` Quantity int `db:"quantity" json:"quantity"` TotalPrice string `db:"total_price" json:"total_price"` TotalPriceValue int `db:"total_price_value" json:"total_price_value"` TotalWeight string `db:"total_weight" json:"total_weight"` TotalWeightValue float64 `db:"total_weight_value" json:"total_weight_value"` CartItems []ControllerResponsePropertyCartItem `db:"cart_items" json:"cart_items"` }
type CartItemModel ¶
type CartItemModel struct { ID int `db:"id" json:"id"` UID string `db:"uid" json:"uid"` Quantity int `db:"quantity" json:"quantity"` TotalPrice string `db:"total_price" json:"total_price"` TotalPriceValue int `db:"total_price_value" json:"total_price_value"` TotalWeight string `db:"total_weight" json:"total_weight"` TotalWeightValue float64 `db:"total_weight_value" json:"total_weight_value"` // Product information ProductName string `db:"product_name" json:"product_name"` ProductSlug string `db:"product_slug" json:"product_slug"` ProductImage string `db:"product_image" json:"product_image"` ProductWeight string `db:"product_weight" json:"product_weight"` ProductWeightValue float64 `db:"product_weight_value" json:"product_weight_value"` BasePrice string `db:"base_price" json:"base_price"` BasePriceValue int `db:"base_price_value" json:"base_price_value"` OfferPrice string `db:"offer_price" json:"offer_price"` OfferPriceValue int `db:"offer_price_value" json:"offer_price_value"` Discount int `db:"discount" json:"discount"` // Relationship CartID int `db:"cart_id" json:"cart_id"` ProductID int `db:"product_id" json:"product_id"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
type CartModel ¶
type CartModel struct { ID int `db:"id" json:"id"` UID string `db:"uid" json:"uid"` Quantity int `db:"quantity" json:"quantity"` TotalPrice string `db:"total_price" json:"total_price"` TotalPriceValue int `db:"total_price_value" json:"total_price_value"` TotalWeight string `db:"total_weight" json:"total_weight"` TotalWeightValue float64 `db:"total_weight_value" json:"total_weight_value"` // Relationship CartItems []CartItemModel `db:"cart_items" json:"cart_items"` UserID int `db:"user_id" json:"user_id"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
Repository
type CartRepository ¶
type CartRepository interface { GetProductByUID(UID string) (*ProductModel, error) // Cart CreateCart() error GetCartByUID(UID string) (*CartModel, error) GetCartByUserID(userID int) (*CartModel, error) // Cart item CreateCartItem(cartItemPayload CartRepositoryPayloadCreateCartItem, cartPayload CartRepositoryPayloadUpdateCart) (string, error) GetCartItemByUID(UID string) (*CartItemModel, error) GetCartItemByProductID(productID int) (*CartItemModel, error) UpdateCartItem(cartItemPayload CartRepositoryPayloadUpdateCartItem, cartPayload CartRepositoryPayloadUpdateCart) error DeleteCartItemByUID(UID string, cartPayload CartRepositoryPayloadUpdateCart) error }
type CartRepositoryPayloadCreateCartItem ¶
type CartRepositoryPayloadCreateCartItem struct { UID string `db:"uid" json:"uid"` Quantity int `db:"quantity" json:"quantity"` TotalPrice string `db:"total_price" json:"total_price"` TotalPriceValue int `db:"total_price_value" json:"total_price_value"` TotalWeight string `db:"total_weight" json:"total_weight"` TotalWeightValue float64 `db:"total_weight_value" json:"total_weight_value"` // Product information ProductName string `db:"product_name" json:"product_name"` ProductSlug string `db:"product_slug" json:"product_slug"` ProductImage string `db:"product_image" json:"product_image"` ProductWeight string `db:"product_weight" json:"product_weight"` ProductWeightValue float64 `db:"product_weight_value" json:"product_weight_value"` BasePrice string `db:"base_price" json:"base_price"` BasePriceValue int `db:"base_price_value" json:"base_price_value"` OfferPrice string `db:"offer_price" json:"offer_price"` OfferPriceValue int `db:"offer_price_value" json:"offer_price_value"` Discount int `db:"discount" json:"discount"` // Relationship CartID int `db:"cart_id" json:"cart_id"` ProductID int `db:"product_id" json:"product_id"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
type CartRepositoryPayloadUpdateCart ¶
type CartRepositoryPayloadUpdateCart struct { UID string `db:"uid" json:"uid"` Quantity int `db:"quantity" json:"quantity"` TotalPrice string `db:"total_price" json:"total_price"` TotalPriceValue int `db:"total_price_value" json:"total_price_value"` TotalWeight string `db:"total_weight" json:"total_weight"` TotalWeightValue float64 `db:"total_weight_value" json:"total_weight_value"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
type CartRepositoryPayloadUpdateCartItem ¶
type CartRepositoryPayloadUpdateCartItem struct { UID string `db:"uid" json:"uid"` Quantity int `db:"quantity" json:"quantity"` TotalPrice string `db:"total_price" json:"total_price"` TotalPriceValue int `db:"total_price_value" json:"total_price_value"` TotalWeight string `db:"total_weight" json:"total_weight"` TotalWeightValue float64 `db:"total_weight_value" json:"total_weight_value"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
type CartUsecase ¶
type CartUsecase interface { // Cart GetCartByUserID(ctx context.Context, userID int) (*CartControllerResponseGetCart, error) GetCartByUserIDMiddleware(ctx context.Context, userID int) (*CartModel, error) // Cart item CreateCartItem(ctx context.Context, payload *CartUsecasePayloadCreateCartItem) (string, error) GetCartItemByUID(ctx context.Context, UID string) (*CartItemModel, error) GetCartItemByProductID(ctx context.Context, productID int) (*CartItemModel, error) UpdateCartItem(ctx context.Context, payload *CartUsecasePayloadUpdateCartItem) error DeleteCartItemByUID(ctx context.Context, payload *CartUsecasePayloadDeleteCartItem) error }
Usecase
type CartUsecasePayloadCreateCartItem ¶
type CartUsecasePayloadCreateCartItem struct { Cart *CartModel `json:"cart"` Product *ProductModel `json:"product"` Quantity int `json:"quantity"` }
type CartUsecasePayloadDeleteCartItem ¶
type CartUsecasePayloadDeleteCartItem struct { Cart *CartModel `json:"cart"` CartItem *CartItemModel `json:"cart_item"` UID string `json:"uid"` }
type CartUsecasePayloadUpdateCartItem ¶
type CartUsecasePayloadUpdateCartItem struct { Cart *CartModel `json:"cart"` CartItem *CartItemModel `json:"cart_item"` UID string `json:"uid"` Quantity int `json:"quantity"` }
type CartUtil ¶
type CartUtil interface { CalculateCreateCartItem(payload *CartUsecasePayloadCreateCartItem) (*CalculatedCart, error) CalculateUpdateCartItem(payload *CartUsecasePayloadUpdateCartItem) (*CalculatedCart, error) CalculateDeleteCartItem(payload *CartUsecasePayloadDeleteCartItem) (*CalculatedCart, error) }
type ControllerResponsePropertyCartItem ¶
type ControllerResponsePropertyCartItem struct { UID string `db:"uid" json:"uid"` Quantity int `db:"quantity" json:"quantity"` TotalPrice string `db:"total_price" json:"total_price"` TotalPriceValue int `db:"total_price_value" json:"total_price_value"` TotalWeight string `db:"total_weight" json:"total_weight"` TotalWeightValue float64 `db:"total_weight_value" json:"total_weight_value"` // Product information ProductName string `db:"product_name" json:"product_name"` ProductSlug string `db:"product_slug" json:"product_slug"` ProductImage string `db:"product_image" json:"product_image"` ProductWeight string `db:"product_weight" json:"product_weight"` ProductWeightValue float64 `db:"product_weight_value" json:"product_weight_value"` BasePrice string `db:"base_price" json:"base_price"` BasePriceValue int `db:"base_price_value" json:"base_price_value"` OfferPrice string `db:"offer_price" json:"offer_price"` OfferPriceValue int `db:"offer_price_value" json:"offer_price_value"` Discount uint8 `db:"discount" json:"discount"` }
type Env ¶
type Env struct { AppEnv string `mapstructure:"APP_ENV"` Host string `mapstructure:"HOST"` Port string `mapstructure:"PORT"` FirebaseCredentialPath string `mapstructure:"FIREBASE_CREDENTIAL_PATH"` FirebaseVerifyPasswordURL string `mapstructure:"FIREBASE_VERIFY_PASSWORD_URL"` ContextTimeout int `mapstructure:"CONTEXT_TIMEOUT"` TestDBUrl string `mapstructure:"TEST_DB_URL"` TestDBUser string `mapstructure:"TEST_DB_USER"` TestDBPassword string `mapstructure:"TEST_DB_PASSWORD"` DBUrl string `mapstructure:"DB_URL"` DBName string `mapstructure:"DB_NAME"` AesSecret string `mapstructure:"AES_SECRET"` AccessTokenExpiryHour int `mapstructure:"ACCESS_TOKEN_EXPIRY_HOUR"` RefreshTokenExpiryHour int `mapstructure:"REFRESH_TOKEN_EXPIRY_HOUR"` AccessTokenSecret string `mapstructure:"ACCESS_TOKEN_SECRET"` RefreshTokenSecret string `mapstructure:"REFRESH_TOKEN_SECRET"` }
type JWTAccessTokenClaims ¶
type JWTAccessTokenClaims struct { UserUID string `json:"user_uid"` jwt.RegisteredClaims }
type LoggerUtil ¶
type LoggerUtil interface { Debugf(format string, args ...interface{}) Infoln(args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) EchoMiddlewareFunc() func(c echo.Context, values middleware.RequestLoggerValues) error }
type ProductController ¶
type ProductController interface { Create(c echo.Context) error GetByUID(c echo.Context) error UpdateByUID(c echo.Context) error DeleteByUID(c echo.Context) error }
Controller
type ProductControllerPayloadCreateProduct ¶
type ProductControllerPayloadCreateProduct struct { Name string `json:"name" validate:"required, min=5"` SKU string `json:"sku"` Description string `json:"description" validate:"required, min=30"` Images StringSlice `json:"images" validate:"required, min=1"` WeightValue float64 `json:"weight_value" validate:"required, min=100"` BasePriceValue int `json:"base_price_value" validate:"required, min=5000"` Discount *int `json:"discount" validate:"required, max=100"` Stock *int `json:"stock" validate:"required"` Status string `json:"status" validate:"required, oneof=ACTIVE INACTIVE"` }
type ProductControllerPayloadUpdateProduct ¶
type ProductControllerPayloadUpdateProduct struct { Name string `json:"name" validate:"required, min=5"` SKU string `json:"sku"` Description string `json:"description" validate:"required, min=30"` Images StringSlice `json:"images" validate:"required, min=1"` WeightValue float64 `json:"weight_value" validate:"required, min=100"` BasePriceValue int `json:"base_price_value" validate:"required, min=5000"` Discount *int `json:"discount" validate:"required, max=100"` Stock *int `json:"stock" validate:"required"` Status string `json:"status" validate:"required, oneof=ACTIVE INACTIVE"` }
type ProductControllerResponseGetProductByUID ¶
type ProductControllerResponseGetProductByUID struct { UID string `json:"uid"` Name string `json:"name"` Slug string `json:"slug"` SKU string `json:"sku"` Description string `json:"description"` Images StringSlice `json:"images"` Weight string `json:"weight"` WeightValue float64 `json:"weight_value"` BasePrice string `json:"base_price"` BasePriceValue int `json:"base_price_value"` OfferPrice string `json:"offer_price"` OfferPriceValue int `json:"offer_price_value"` Discount int `json:"discount"` Stock int `json:"stock"` Status string `json:"status"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
type ProductControllerResponseListProducts ¶
type ProductControllerResponseListProducts struct { Products []*ProductControllerResponseGetProductByUID IsFirstPage bool Limit int PrevCursor string NextCursor string }
type ProductModel ¶
type ProductModel struct { ID int `db:"id" json:"id"` UID string `db:"uid" json:"uid"` Name string `db:"name" json:"name"` Slug string `db:"slug" json:"slug"` SKU sql.NullString `db:"sku" json:"sku"` Description string `db:"description" json:"description"` Images StringSlice `db:"images" json:"images"` Weight string `db:"weight" json:"weight"` WeightValue float64 `db:"weight_value" json:"weight_value"` BasePrice string `db:"base_price" json:"base_price"` BasePriceValue int `db:"base_price_value" json:"base_price_value"` OfferPrice string `db:"offer_price" json:"offer_price"` OfferPriceValue int `db:"offer_price_value" json:"offer_price_value"` Discount int `db:"discount" json:"discount"` Stock int `db:"stock" json:"stock"` Status string `db:"status" json:"status"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
Repository
type ProductRepository ¶
type ProductRepository interface { Create(productPayload *ProductRepositoryPayloadCreateProduct) (string, error) List(limit, cursor int, direction string) ([]*ProductModel, error) GetByUID(UID string) (*ProductModel, error) UpdateByUID(productPayload *ProductRepositoryPayloadUpdateProduct) error DeleteByUID(UID string) error }
type ProductRepositoryPayloadCreateProduct ¶
type ProductRepositoryPayloadCreateProduct struct { UID string `db:"uid" json:"uid"` Name string `db:"name" json:"name"` Slug string `db:"slug" json:"slug"` SKU string `db:"sku" json:"sku"` Description string `db:"description" json:"description"` Images StringSlice `db:"images" json:"images"` Weight string `db:"weight" json:"weight"` WeightValue float64 `db:"weight_value" json:"weight_value"` BasePrice string `db:"base_price" json:"base_price"` BasePriceValue int `db:"base_price_value" json:"base_price_value"` OfferPrice string `db:"offer_price" json:"offer_price"` OfferPriceValue int `db:"offer_price_value" json:"offer_price_value"` Discount int `db:"discount" json:"discount"` Stock int `db:"stock" json:"stock"` Status string `db:"status" json:"status"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
type ProductRepositoryPayloadUpdateProduct ¶
type ProductRepositoryPayloadUpdateProduct struct { UID string `db:"uid" json:"uid"` Name string `db:"name" json:"name"` Slug string `db:"slug" json:"slug"` SKU string `db:"sku" json:"sku"` Description string `db:"description" json:"description"` Images StringSlice `db:"images" json:"images"` Weight string `db:"weight" json:"weight"` WeightValue float64 `db:"weight_value" json:"weight_value"` BasePrice string `db:"base_price" json:"base_price"` BasePriceValue int `db:"base_price_value" json:"base_price_value"` OfferPrice string `db:"offer_price" json:"offer_price"` OfferPriceValue int `db:"offer_price_value" json:"offer_price_value"` Discount int `db:"discount" json:"discount"` Stock int `db:"stock" json:"stock"` Status string `db:"status" json:"status"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
type ProductUsecase ¶
type ProductUsecase interface { Create(ctx context.Context, payload *ProductUsecasePayloadCreateProduct) (string, error) List(ctx context.Context, limit int, encryptedCursor, direction string) (*ProductControllerResponseListProducts, error) GetByUID(ctx context.Context, UID string) (*ProductControllerResponseGetProductByUID, error) UpdateByUID(ctx context.Context, UID string, payload *ProductUsecasePayloadUpdateProduct) error DeleteByUID(ctx context.Context, UID string) error }
Usecase
type ProductUsecasePayloadCreateProduct ¶
type ProductUsecasePayloadCreateProduct struct { Name string `json:"name"` SKU string `json:"sku"` Description string `json:"description"` Images StringSlice `json:"images"` WeightValue float64 `json:"weight_value"` BasePriceValue int `json:"base_price_value"` Discount int `json:"discount"` Stock int `json:"stock"` Status string `json:"status"` }
type ProductUsecasePayloadUpdateProduct ¶
type ProductUsecasePayloadUpdateProduct struct { Name string `json:"name"` SKU string `json:"sku"` Description string `json:"description"` Images StringSlice `json:"images"` WeightValue float64 `json:"weight_value"` BasePriceValue int `json:"base_price_value"` Discount int `json:"discount"` Stock int `json:"stock"` Status string `json:"status"` }
type ProductUtil ¶
type StringSlice ¶
type StringSlice []string
func (*StringSlice) Scan ¶
func (s *StringSlice) Scan(value interface{}) error
type UserModel ¶
type UserModel struct { ID int `db:"id" json:"id"` UID string `db:"uid" json:"uid"` FirebaseUID string `db:"firebase_uid" json:"firebase_uid"` Email string `db:"email" json:"email"` Name string `db:"name" json:"name"` Phone string `db:"phone" json:"phone"` ProfileImage string `db:"profile_image" json:"profile_image"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
Repository
type UserRepository ¶
type UserRepository interface { CreateUser(userPayload *UserRepositoryPayloadCreateUser) (int, error) CreateAdmin(adminPayload *UserRepositoryPayloadCreateAdmin) error GetUserByEmail(email string) (*UserModel, error) GetUserByFirebaseUID(UID string) (*UserModel, error) GetUserByUID(UID string) (*UserModel, error) GetAdminByUserID(UserID int) (*AdminModel, error) }
type UserRepositoryPayloadCreateUser ¶
type UserRepositoryPayloadCreateUser struct { UID string `db:"uid" json:"uid"` FirebaseUID string `db:"firebase_uid" json:"firebase_uid"` Email string `db:"email" json:"email"` Name string `db:"name" json:"name"` Phone string `db:"phone" json:"phone"` ProfileImage string `db:"profile_image" json:"profile_image"` IsAdmin bool `json:"is_admin"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
Click to show internal directories.
Click to hide internal directories.