Documentation
¶
Index ¶
- func CancelOrder(c *gin.Context)
- func CheckPassword(plain, hashed string) error
- func CreateProduct(c *gin.Context)
- func DeleteProduct(c *gin.Context)
- func GetProductByID(c *gin.Context)
- func GetProducts(c *gin.Context)
- func GetUserOrders(c *gin.Context)
- func HashPassword(password string) (string, error)
- func LoginUser(c *gin.Context)
- func PlaceOrder(c *gin.Context)
- func RegisterUser(c *gin.Context)
- func UpdateOrderStatus(c *gin.Context)
- func UpdateProduct(c *gin.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CancelOrder ¶
CancelOrder cancels the order if it's still pending CancelOrder godoc @Summary Cancel an order @Description Allows an authenticated user to cancel an order if it is in "Pending" status @Tags Orders @Param id path string true "Order ID" @Security BearerAuth @Success 200 {object} models.SuccessResponse "Order canceled successfully" @Failure 400 {object} models.ErrorResponse "Invalid order ID or status" @Failure 401 {object} models.ErrorResponse "Unauthorized" @Failure 404 {object} models.ErrorResponse "Order not found" @Failure 500 {object} models.ErrorResponse "Failed to cancel order" @Router /orders/{id}/cancel [put]
func CheckPassword ¶
CheckPassword compares plain password with hashed
func CreateProduct ¶
CreateProduct allows an admin user to add a new product CreateProduct godoc @Summary Create a new product @Description Allows an admin user to add a new product @Tags Products @Accept json @Produce json @Param product body models.ProductInput true "Product payload" @Security BearerAuth @Success 200 {object} models.SuccessResponse "Product created successfully" @Failure 400 {object} models.ValidationErrorResponse "Invalid product payload" @Failure 500 {object} models.ErrorResponse "Failed to create product" @Router /products [post]
func DeleteProduct ¶
DeleteProduct deletes a product by ID (admin only) DeleteProduct godoc @Summary Delete a product @Description Allows an admin user to delete a product by ID @Tags Products @Param id path string true "Product ID" @Security BearerAuth @Success 200 {object} models.SuccessResponse "Product deleted successfully" @Failure 400 {object} models.ErrorResponse "Invalid product ID" @Failure 404 {object} models.ErrorResponse "Product not found" @Failure 500 {object} models.ErrorResponse "Failed to delete product" @Router /products/{id} [delete]
func GetProductByID ¶
GetProductByID retrieves a single product by ID GetProductByID godoc @Summary Get product by ID @Description Retrieves a single product by its ID @Tags Products @Param id path string true "Product ID" @Security BearerAuth @Success 200 {object} models.SuccessResponse "Product retrieved successfully" @Failure 400 {object} models.ErrorResponse "Invalid product ID" @Failure 404 {object} models.ErrorResponse "Product not found" @Failure 500 {object} models.ErrorResponse "Failed to retrieve product" @Router /products/{id} [get]
func GetProducts ¶
GetProducts lists all products GetProducts godoc @Summary Get all products @Description Retrieves a list of all products available in the store @Tags Products @Produce json @Security BearerAuth @Success 200 {object} models.SuccessResponse "Product(s) retrieved successfully" @Failure 500 {object} models.ErrorResponse "Failed to retrieve products" @Router /products [get]
func GetUserOrders ¶
GetUserOrders lists all orders for the authenticated user GetUserOrders godoc @Summary Get all orders for a user @Description Retrieve a list of all orders placed by the authenticated user @Tags Orders @Produce json @Security BearerAuth @Success 200 {object} models.SuccessResponse "List of orders" @Failure 401 {object} models.ErrorResponse "Unauthorized" @Failure 500 {object} models.ErrorResponse "Failed to fetch orders" @Router /orders [get]
func HashPassword ¶
HashPassword hashes the plain text password
func LoginUser ¶
LoginUser handles user authentication LoginUser godoc @Summary Authenticate a user @Description Authenticate a user with email and password, returning a JWT token @Tags Users @Accept json @Produce json @Param login body models.LoginInput true "User login payload" @Success 200 {object} models.SuccessResponse "Login successful" @Failure 400 {object} models.ValidationErrorResponse "Validation errors" @Failure 401 {object} models.ErrorResponse "Invalid email or password" @Failure 500 {object} models.ErrorResponse "Failed to generate token" @Router /users/login [post]
func PlaceOrder ¶
PlaceOrder allows an authenticated user to create a new order PlaceOrder godoc @Summary Place a new order @Description Allows an authenticated user to place an order with one or more products @Tags Orders @Accept json @Produce json @Param order body models.PlaceOrderInput true "Order payload" @Security BearerAuth @Success 200 {object} models.SuccessResponse "Order created successfully" @Failure 400 {object} models.ValidationErrorResponse "Invalid order payload" @Failure 401 {object} models.ErrorResponse "Unauthorized" @Failure 500 {object} models.ErrorResponse "Failed to create order" @Router /orders [post]
func RegisterUser ¶
RegisterUser handles user signup RegisterUser godoc @Summary Register a new user @Description Create a new user in the system with email, password, and optional role @Tags Users @Accept json @Produce json @Param user body models.UserInput true "User registration payload" @Success 200 {object} models.SuccessResponse "User registered successfully" @Failure 400 {object} models.ValidationErrorResponse "Validation errors" @Failure 500 {object} models.ErrorResponse "Failed to create user" @Router /users/register [post]
func UpdateOrderStatus ¶
UpdateOrderStatus allows an admin to update an order status UpdateOrderStatus godoc @Summary Update order status @Description Allows an admin to update the status of an order @Tags Orders @Param id path string true "Order ID" @Param status body models.UpdateOrderStatusInput true "Update order status payload" @Security BearerAuth @Success 200 {object} models.SuccessResponse "Order status updated successfully" @Failure 400 {object} models.ValidationErrorResponse "Invalid order ID or payload" @Failure 401 {object} models.ErrorResponse "Unauthorized" @Failure 404 {object} models.ErrorResponse "Order not found" @Failure 500 {object} models.ErrorResponse "Failed to update order status" @Router /orders/{id}/status [put]
func UpdateProduct ¶
UpdateProduct modifies an existing product (admin only) UpdateProduct godoc @Summary Update a product @Description Allows an admin user to update an existing product by ID @Tags Products @Param id path string true "Product ID" @Param product body models.ProductInput true "Updated product payload" @Security BearerAuth @Success 200 {object} models.SuccessResponse "Product updated successfully" @Failure 400 {object} models.ValidationErrorResponse "Invalid product ID or payload" @Failure 404 {object} models.ErrorResponse "Product not found" @Failure 500 {object} models.ErrorResponse "Failed to update product" @Router /products/{id} [put]
Types ¶
This section is empty.