package
0.0.0-20241220125157-d639d14c3ded
Repository: https://github.com/raihan1405/go-restapi.git
Documentation: pkg.go.dev

# Functions

AddProduct godoc @Summary Add a new product @Description Add a new product with the provided details @Tags product @Accept json @Produce json @Param product body validators.AddProductInput true "Product details" @Success 200 {object} models.Product @Failure 400 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/products [post].
AddToCart godoc @Summary Add a product to cart @Description Add a product to the user's cart @Tags cart @Accept json @Produce json @Param cart body validators.AddToCartInput true "Cart item details" @Success 200 {object} models.CartItem @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/cart [post].
ApproveMultipleInvoices memungkinkan operator untuk menyetujui beberapa pesanan sekaligus.
CreateInvoice godoc @Summary Create an invoice from the user's cart @Description Create an invoice from all selected items in the user's cart @Tags invoice @Accept json @Produce json @Success 201 {object} models.Invoice @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/invoice [post].
EditProduct godoc @Summary Edit an existing product @Description Edit an existing product with the provided details @Tags product @Accept json @Produce json @Param id path int true "Product ID" @Param product body validators.EditProductInput true "Product details" @Success 200 {object} models.Product @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/products/{id} [put].
No description provided by the author
No description provided by the author
GetAllInvoices godoc @Summary Get all invoices for the logged-in user @Description Get a list of all invoices associated with the logged-in user @Tags invoice @Produce json @Success 200 {array} models.Invoice @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/invoices [get] GetAllInvoices godoc @Summary Get all invoices for the logged-in user @Description Get a list of all invoices associated with the logged-in user @Tags invoice @Produce json @Success 200 {array} models.Invoice @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/invoices [get] GetAllInvoices godoc @Summary Get all invoices for the logged-in user @Description Get a list of all invoices associated with the logged-in user @Tags invoice @Produce json @Success 200 {array} models.Invoice @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/invoices [get].
No description provided by the author
GetAllInvoicesForOperator godoc @Summary Get all invoices from all users (for operator) @Description Get a list of all invoices for all users @Tags invoice @Produce json @Success 200 {array} models.Invoice @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/operator/invoices [get] GetAllInvoices godoc @Summary Get all invoices for all users (operator access) @Description Get a list of all invoices associated with all users (accessible by operator) @Tags invoice @Produce json @Success 200 {array} models.Invoice @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/invoices [get].
GetAllProducts godoc @Summary Get all products @Description Get a list of all products @Tags product @Produce json @Success 200 {array} models.Product @Failure 500 {object} map[string]interface{} @Router /api/products [get].
No description provided by the author
GetCart godoc @Summary Get all items in the cart @Description Get a list of all items in the user's cart @Tags cart @Produce json @Success 200 {array} models.CartItem @Failure 500 {object} ErrorResponse @Router /api/cart [get].
GetUser godoc @Summary Get authenticated user details @Description Get details of the authenticated user based on the JWT token @Tags user @Produce json @Success 200 {object} models.User @Failure 401 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Router /api/user [get].
No description provided by the author
Login godoc @Summary Log in a user @Description Log in a user with the provided credentials and return user data @Tags auth @Accept json @Produce json @Param login body validators.LoginInput true "User login details" @Success 200 {object} LoginResponse @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/login [post].
LoginAdmin godoc @Summary Log in an admin @Description Log in an admin with the provided Admin ID and return admin data @Tags auth @Accept json @Produce json @Param login body validators.AdminLoginInput true "Admin login details" @Success 200 {object} LoginAdminResponse @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/admin/login [post].
LoginOperator godoc @Summary Log in an operator @Description Log in an operator with the provided Operator ID and return operator data @Tags auth @Accept json @Produce json @Param login body validators.OperatorLoginInput true "Operator login details" @Success 200 {object} LoginOperatorResponse @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/operator/login [post].
No description provided by the author
No description provided by the author
Logout godoc @Summary Log out the authenticated user @Description Log out the authenticated user by clearing the JWT cookie @Tags auth @Produce json @Success 200 {object} map[string]interface{} @Router /api/logout [post].
OperatorDashboard godoc @Summary Get operator dashboard @Description Get dashboard data for the authenticated operator @Tags operator @Produce json @Success 200 {object} models.Operator @Failure 401 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Router /api/operator/dashboard [get].
Register godoc @Summary Register a new user @Description Register a new user with the provided details @Tags auth @Accept json @Produce json @Param register body validators.RegisterInput true "User registration details" @Success 200 {object} models.User @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/register [post].
No description provided by the author
RemoveFromCart godoc @Summary Remove an item from the cart @Description Remove an item from the user's cart by ID @Tags cart @Param id path int true "Cart Item ID" @Success 200 {object} SuccessResponse @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/cart/{id} [delete].
UpdateCartItem godoc @Summary Update an item in the cart @Description Update the quantity of an item in the user's cart @Tags cart @Accept json @Produce json @Param id path int true "Cart Item ID" @Param cart body validators.UpdateCartItemInput true "Updated cart item details" @Success 200 {object} models.CartItem @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/cart/{id} [put].
UpdatePassword godoc @Summary Update user password @Description Update user password with the provided old and new passwords @Tags user @Accept json @Produce json @Param update body validators.UpdatePasswordInput true "User update password details" @Success 200 {object} map[string]interface{} @Failure 400 {object} ErrorResponse @Failure 401 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Router /api/user/password [put].
UpdateProfile godoc @Summary Update user details @Description Update user details with the provided information @Tags user @Accept json @Produce json @Param update body validators.UpdateUserInput true "User update details" @Success 200 {object} models.User @Failure 400 {object} ErrorResponse @Failure 401 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Router /api/user [put].
No description provided by the author

# Structs

No description provided by the author
Definisikan struktur respons kesalahan.
LoginAdminResponse defines the structure of a successful login response for admin.
LoginOperatorResponse defines the structure of a successful login response for operator.
Definisikan struktur respons sukses.
No description provided by the author
SuccessResponse digunakan untuk mengembalikan pesan sukses.