Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
AuthHandler represents the HTTP handler for authentication-related requests
func NewAuthHandler ¶
func NewAuthHandler(svc port.AuthService) *AuthHandler
NewAuthHandler creates a new AuthHandler instance
func (*AuthHandler) Login ¶
func (ah *AuthHandler) Login(ctx *gin.Context)
Login godoc
@Summary Login and get an access token @Description Logs in a registered user and returns an access token if the credentials are valid. @Tags Users @Accept json @Produce json @Param request body loginRequest true "Login request body" @Success 200 {object} authResponse "Succesfully logged in" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 500 {object} errorResponse "Internal server error" @Router /users/login [post]
type CategoryHandler ¶
type CategoryHandler struct {
// contains filtered or unexported fields
}
CategoryHandler represents the HTTP handler for category-related requests
func NewCategoryHandler ¶
func NewCategoryHandler(svc port.CategoryService) *CategoryHandler
NewCategoryHandler creates a new CategoryHandler instance
func (*CategoryHandler) CreateCategory ¶
func (ch *CategoryHandler) CreateCategory(ctx *gin.Context)
CreateCategory godoc
@Summary Create a new category @Description create a new category with name @Tags Categories @Accept json @Produce json @Param createCategoryRequest body createCategoryRequest true "Create category request" @Success 200 {object} categoryResponse "Category created" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 403 {object} errorResponse "Forbidden error" @Failure 404 {object} errorResponse "Data not found error" @Failure 409 {object} errorResponse "Data conflict error" @Failure 500 {object} errorResponse "Internal server error" @Router /categories [post] @Security BearerAuth
func (*CategoryHandler) DeleteCategory ¶
func (ch *CategoryHandler) DeleteCategory(ctx *gin.Context)
DeleteCategory godoc
@Summary Delete a category @Description Delete a category by id @Tags Categories @Accept json @Produce json @Param id path uint64 true "Category ID" @Success 200 {object} response "Category deleted" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 403 {object} errorResponse "Forbidden error" @Failure 404 {object} errorResponse "Data not found error" @Failure 500 {object} errorResponse "Internal server error" @Router /categories/{id} [delete] @Security BearerAuth
func (*CategoryHandler) GetCategory ¶
func (ch *CategoryHandler) GetCategory(ctx *gin.Context)
GetCategory godoc
@Summary Get a category @Description get a category by id @Tags Categories @Accept json @Produce json @Param id path uint64 true "Category ID" @Success 200 {object} categoryResponse "Category retrieved" @Failure 400 {object} errorResponse "Validation error" @Failure 404 {object} errorResponse "Data not found error" @Failure 500 {object} errorResponse "Internal server error" @Router /categories/{id} [get] @Security BearerAuth
func (*CategoryHandler) ListCategories ¶
func (ch *CategoryHandler) ListCategories(ctx *gin.Context)
ListCategories godoc
@Summary List categories @Description List categories with pagination @Tags Categories @Accept json @Produce json @Param skip query uint64 true "Skip" @Param limit query uint64 true "Limit" @Success 200 {object} meta "Categories displayed" @Failure 400 {object} errorResponse "Validation error" @Failure 500 {object} errorResponse "Internal server error" @Router /categories [get] @Security BearerAuth
func (*CategoryHandler) UpdateCategory ¶
func (ch *CategoryHandler) UpdateCategory(ctx *gin.Context)
UpdateCategory godoc
@Summary Update a category @Description update a category's name by id @Tags Categories @Accept json @Produce json @Param id path uint64 true "Category ID" @Param updateCategoryRequest body updateCategoryRequest true "Update category request" @Success 200 {object} categoryResponse "Category updated" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 403 {object} errorResponse "Forbidden error" @Failure 404 {object} errorResponse "Data not found error" @Failure 409 {object} errorResponse "Data conflict error" @Failure 500 {object} errorResponse "Internal server error" @Router /categories/{id} [put] @Security BearerAuth
type OrderHandler ¶
type OrderHandler struct {
// contains filtered or unexported fields
}
OrderHandler represents the HTTP handler for order-related requests
func NewOrderHandler ¶
func NewOrderHandler(svc port.OrderService) *OrderHandler
NewOrderHandler creates a new OrderHandler instance
func (*OrderHandler) CreateOrder ¶
func (oh *OrderHandler) CreateOrder(ctx *gin.Context)
CreateOrder godoc
@Summary Create a new order @Description Create a new order and return the order data with purchase details @Tags Orders @Accept json @Produce json @Param createOrderRequest body createOrderRequest true "Create order request" @Success 200 {object} orderResponse "Order created" @Failure 400 {object} errorResponse "Validation error" @Failure 404 {object} errorResponse "Data not found error" @Failure 409 {object} errorResponse "Data conflict error" @Failure 500 {object} errorResponse "Internal server error" @Router /orders [post] @Security BearerAuth
func (*OrderHandler) GetOrder ¶
func (oh *OrderHandler) GetOrder(ctx *gin.Context)
GetOrder godoc
@Summary Get an order @Description Get an order by id and return the order data with purchase details @Tags Orders @Accept json @Produce json @Param id path uint64 true "Order ID" @Success 200 {object} orderResponse "Order displayed" @Failure 400 {object} errorResponse "Validation error" @Failure 404 {object} errorResponse "Data not found error" @Failure 500 {object} errorResponse "Internal server error" @Router /orders/{id} [get] @Security BearerAuth
func (*OrderHandler) ListOrders ¶
func (oh *OrderHandler) ListOrders(ctx *gin.Context)
ListOrders godoc
@Summary List orders @Description List orders and return an array of order data with purchase details @Tags Orders @Accept json @Produce json @Param skip query uint64 true "Skip records" @Param limit query uint64 true "Limit records" @Success 200 {object} meta "Orders displayed" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 500 {object} errorResponse "Internal server error" @Router /orders [get] @Security BearerAuth
type PaymentHandler ¶
type PaymentHandler struct {
// contains filtered or unexported fields
}
PaymentHandler represents the HTTP handler for payment-related requests
func NewPaymentHandler ¶
func NewPaymentHandler(svc port.PaymentService) *PaymentHandler
NewPaymentHandler creates a new PaymentHandler instance
func (*PaymentHandler) CreatePayment ¶
func (ph *PaymentHandler) CreatePayment(ctx *gin.Context)
CreatePayment godoc
@Summary Create a new payment @Description create a new payment with name, type, and logo @Tags Payments @Accept json @Produce json @Param createPaymentRequest body createPaymentRequest true "Create payment request" @Success 200 {object} paymentResponse "Payment created" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 403 {object} errorResponse "Forbidden error" @Failure 404 {object} errorResponse "Data not found error" @Failure 409 {object} errorResponse "Data conflict error" @Failure 500 {object} errorResponse "Internal server error" @Router /payments [post] @Security BearerAuth
func (*PaymentHandler) DeletePayment ¶
func (ph *PaymentHandler) DeletePayment(ctx *gin.Context)
DeletePayment godoc
@Summary Delete a payment @Description Delete a payment by id @Tags Payments @Accept json @Produce json @Param id path uint64 true "Payment ID" @Success 200 {object} response "Payment deleted" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 403 {object} errorResponse "Forbidden error" @Failure 404 {object} errorResponse "Data not found error" @Failure 500 {object} errorResponse "Internal server error" @Router /payments/{id} [delete] @Security BearerAuth
func (*PaymentHandler) GetPayment ¶
func (ph *PaymentHandler) GetPayment(ctx *gin.Context)
GetPayment godoc
@Summary Get a payment @Description get a payment by id @Tags Payments @Accept json @Produce json @Param id path int true "Payment ID" @Success 200 {object} paymentResponse "Payment retrieved" @Failure 400 {object} errorResponse "Validation error" @Failure 404 {object} errorResponse "Data not found error" @Failure 500 {object} errorResponse "Internal server error" @Router /payments/{id} [get] @Security BearerAuth
func (*PaymentHandler) ListPayments ¶
func (ph *PaymentHandler) ListPayments(ctx *gin.Context)
ListPayments godoc
@Summary List payments @Description List payments with pagination @Tags Payments @Accept json @Produce json @Param skip query uint64 true "Skip" @Param limit query uint64 true "Limit" @Success 200 {object} meta "Payments displayed" @Failure 400 {object} errorResponse "Validation error" @Failure 500 {object} errorResponse "Internal server error" @Router /payments [get] @Security BearerAuth
func (*PaymentHandler) UpdatePayment ¶
func (ph *PaymentHandler) UpdatePayment(ctx *gin.Context)
UpdatePayment godoc
@Summary Update a payment @Description update a payment's name, type, or logo by id @Tags Payments @Accept json @Produce json @Param id path int true "Payment ID" @Param updatePaymentRequest body updatePaymentRequest true "Update payment request" @Success 200 {object} paymentResponse "Payment updated" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 403 {object} errorResponse "Forbidden error" @Failure 404 {object} errorResponse "Data not found error" @Failure 409 {object} errorResponse "Data conflict error" @Failure 500 {object} errorResponse "Internal server error" @Router /payments/{id} [put] @Security BearerAuth
type ProductHandler ¶
type ProductHandler struct {
// contains filtered or unexported fields
}
ProductHandler represents the HTTP handler for product-related requests
func NewProductHandler ¶
func NewProductHandler(svc port.ProductService) *ProductHandler
NewProductHandler creates a new ProductHandler instance
func (*ProductHandler) CreateProduct ¶
func (ph *ProductHandler) CreateProduct(ctx *gin.Context)
CreateProduct godoc
@Summary Create a new product @Description create a new product with name, image, price, and stock @Tags Products @Accept json @Produce json @Param createProductRequest body createProductRequest true "Create product request" @Success 200 {object} productResponse "Product created" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 403 {object} errorResponse "Forbidden error" @Failure 404 {object} errorResponse "Data not found error" @Failure 409 {object} errorResponse "Data conflict error" @Failure 500 {object} errorResponse "Internal server error" @Router /products [post] @Security BearerAuth
func (*ProductHandler) DeleteProduct ¶
func (ph *ProductHandler) DeleteProduct(ctx *gin.Context)
DeleteProduct godoc
@Summary Delete a product @Description Delete a product by id @Tags Products @Accept json @Produce json @Param id path uint64 true "Product ID" @Success 200 {object} response "Product deleted" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 403 {object} errorResponse "Forbidden error" @Failure 404 {object} errorResponse "Data not found error" @Failure 500 {object} errorResponse "Internal server error" @Router /products/{id} [delete] @Security BearerAuth
func (*ProductHandler) GetProduct ¶
func (ph *ProductHandler) GetProduct(ctx *gin.Context)
GetProduct godoc
@Summary Get a product @Description get a product by id with its category @Tags Products @Accept json @Produce json @Param id path uint64 true "Product ID" @Success 200 {object} productResponse "Product retrieved" @Failure 400 {object} errorResponse "Validation error" @Failure 404 {object} errorResponse "Data not found error" @Failure 500 {object} errorResponse "Internal server error" @Router /products/{id} [get] @Security BearerAuth
func (*ProductHandler) ListProducts ¶
func (ph *ProductHandler) ListProducts(ctx *gin.Context)
ListProducts godoc
@Summary List products @Description List products with pagination @Tags Products @Accept json @Produce json @Param category_id query uint64 false "Category ID" @Param q query string false "Query" @Param skip query uint64 true "Skip" @Param limit query uint64 true "Limit" @Success 200 {object} meta "Products retrieved" @Failure 400 {object} errorResponse "Validation error" @Failure 500 {object} errorResponse "Internal server error" @Router /products [get] @Security BearerAuth
func (*ProductHandler) UpdateProduct ¶
func (ph *ProductHandler) UpdateProduct(ctx *gin.Context)
UpdateProduct godoc
@Summary Update a product @Description update a product's name, image, price, or stock by id @Tags Products @Accept json @Produce json @Param id path uint64 true "Product ID" @Param updateProductRequest body updateProductRequest true "Update product request" @Success 200 {object} productResponse "Product updated" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 403 {object} errorResponse "Forbidden error" @Failure 404 {object} errorResponse "Data not found error" @Failure 409 {object} errorResponse "Data conflict error" @Failure 500 {object} errorResponse "Internal server error" @Router /products/{id} [put] @Security BearerAuth
type Router ¶
Router is a wrapper for HTTP router
func NewRouter ¶
func NewRouter( config *config.HTTP, token port.TokenService, userHandler UserHandler, authHandler AuthHandler, paymentHandler PaymentHandler, categoryHandler CategoryHandler, productHandler ProductHandler, orderHandler OrderHandler, ) (*Router, error)
NewRouter creates a new HTTP router
type UserHandler ¶
type UserHandler struct {
// contains filtered or unexported fields
}
UserHandler represents the HTTP handler for user-related requests
func NewUserHandler ¶
func NewUserHandler(svc port.UserService) *UserHandler
NewUserHandler creates a new UserHandler instance
func (*UserHandler) DeleteUser ¶
func (uh *UserHandler) DeleteUser(ctx *gin.Context)
DeleteUser godoc
@Summary Delete a user @Description Delete a user by id @Tags Users @Accept json @Produce json @Param id path uint64 true "User ID" @Success 200 {object} response "User deleted" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 403 {object} errorResponse "Forbidden error" @Failure 404 {object} errorResponse "Data not found error" @Failure 500 {object} errorResponse "Internal server error" @Router /users/{id} [delete] @Security BearerAuth
func (*UserHandler) GetUser ¶
func (uh *UserHandler) GetUser(ctx *gin.Context)
GetUser godoc
@Summary Get a user @Description Get a user by id @Tags Users @Accept json @Produce json @Param id path uint64 true "User ID" @Success 200 {object} userResponse "User displayed" @Failure 400 {object} errorResponse "Validation error" @Failure 404 {object} errorResponse "Data not found error" @Failure 500 {object} errorResponse "Internal server error" @Router /users/{id} [get] @Security BearerAuth
func (*UserHandler) ListUsers ¶
func (uh *UserHandler) ListUsers(ctx *gin.Context)
ListUsers godoc
@Summary List users @Description List users with pagination @Tags Users @Accept json @Produce json @Param skip query uint64 true "Skip" @Param limit query uint64 true "Limit" @Success 200 {object} meta "Users displayed" @Failure 400 {object} errorResponse "Validation error" @Failure 500 {object} errorResponse "Internal server error" @Router /users [get] @Security BearerAuth
func (*UserHandler) Register ¶
func (uh *UserHandler) Register(ctx *gin.Context)
Register godoc
@Summary Register a new user @Description create a new user account with default role "cashier" @Tags Users @Accept json @Produce json @Param registerRequest body registerRequest true "Register request" @Success 200 {object} userResponse "User created" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 404 {object} errorResponse "Data not found error" @Failure 409 {object} errorResponse "Data conflict error" @Failure 500 {object} errorResponse "Internal server error" @Router /users [post]
func (*UserHandler) UpdateUser ¶
func (uh *UserHandler) UpdateUser(ctx *gin.Context)
UpdateUser godoc
@Summary Update a user @Description Update a user's name, email, password, or role by id @Tags Users @Accept json @Produce json @Param id path uint64 true "User ID" @Param updateUserRequest body updateUserRequest true "Update user request" @Success 200 {object} userResponse "User updated" @Failure 400 {object} errorResponse "Validation error" @Failure 401 {object} errorResponse "Unauthorized error" @Failure 403 {object} errorResponse "Forbidden error" @Failure 404 {object} errorResponse "Data not found error" @Failure 500 {object} errorResponse "Internal server error" @Router /users/{id} [put] @Security BearerAuth