Refactor API documentation and update endpoint tags for clarity

- Updated README.md to reflect changes in endpoint categories, renaming "Customers-Admin" to "Admin-Customers" and "Companies-Admin" to "Admin-Companies" for consistency.
- Modified health check endpoint tags from "Health" to "Admin-Health" to align with the new naming convention.
- Adjusted Swagger documentation to replace outdated tags and ensure accurate representation of the API structure.
- Enhanced user and customer handler documentation to reflect the new "Admin-Authorization" and "Admin-Users" tags, improving clarity in the API documentation.
This commit is contained in:
n.nakhostin
2025-08-11 18:59:31 +03:30
parent 318f3b7878
commit a1db2a9790
12 changed files with 374 additions and 406 deletions
-1
View File
@@ -18,7 +18,6 @@ type CreateCustomerForm struct {
Mobile *string `json:"mobile,omitempty" valid:"optional,length(10|20)"`
// Company customer fields
CompanyName *string `json:"company_name,omitempty" valid:"optional,length(2|200)"`
RegistrationNumber *string `json:"registration_number,omitempty" valid:"optional,length(5|50)"`
TaxID *string `json:"tax_id,omitempty" valid:"optional,length(5|50)"`
Industry *string `json:"industry,omitempty" valid:"optional,length(2|100)"`
+25 -25
View File
@@ -31,7 +31,7 @@ func NewHandler(service Service, userHandler *user.Handler, authService authoriz
// CreateCustomer creates a new customer (Web Panel)
// @Summary Create a new customer
// @Description Create a new customer with comprehensive information including personal details, company information, address, and business details. This endpoint is used by the web panel for full customer registration.
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param customer body CreateCustomerForm true "Customer information including type (individual|company|government), personal details, company info, address, and business details"
@@ -71,7 +71,7 @@ func (h *Handler) CreateCustomer(c echo.Context) error {
// GetCustomerByID retrieves a customer by ID (Web Panel)
// @Summary Get customer by ID
// @Description Retrieve detailed customer information by customer ID
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param id path string true "Customer ID"
@@ -98,7 +98,7 @@ func (h *Handler) GetCustomerByID(c echo.Context) error {
// GetCustomerByIDWithCompanies retrieves a customer by ID with companies (Web Panel)
// @Summary Get customer by ID with companies
// @Description Retrieve detailed customer information by customer ID including assigned companies
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param id path string true "Customer ID"
@@ -125,7 +125,7 @@ func (h *Handler) GetCustomerByIDWithCompanies(c echo.Context) error {
// UpdateCustomer updates a customer (Web Panel)
// @Summary Update customer information
// @Description Update customer information including personal details, company information, address, and business details
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param id path string true "Customer ID"
@@ -171,7 +171,7 @@ func (h *Handler) UpdateCustomer(c echo.Context) error {
// DeleteCustomer deletes a customer (Web Panel)
// @Summary Delete customer
// @Description Soft delete a customer by setting status to inactive
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param id path string true "Customer ID"
@@ -206,7 +206,7 @@ func (h *Handler) DeleteCustomer(c echo.Context) error {
// ListCustomers lists customers with filters and pagination
// @Summary List customers with filters and pagination
// @Description Retrieve a paginated list of customers with advanced filtering options including search, type, status, company, industry, verification status, and compliance status. Supports sorting and pagination.
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param search query string false "Search term to filter customers by name, email, or company name"
@@ -245,7 +245,7 @@ func (h *Handler) ListCustomers(c echo.Context) error {
// ListCustomersWithCompanies lists customers with companies and filters
// @Summary List customers with companies and filters
// @Description Retrieve a paginated list of customers with their assigned companies and advanced filtering options including search, type, status, company, industry, verification status, and compliance status. Supports sorting and pagination.
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param search query string false "Search term to filter customers by name, email, or company name"
@@ -284,7 +284,7 @@ func (h *Handler) ListCustomersWithCompanies(c echo.Context) error {
// UpdateCustomerStatus updates customer status (Web Panel)
// @Summary Update customer status
// @Description Update customer account status (active, inactive, suspended, pending)
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param id path string true "Customer ID"
@@ -325,7 +325,7 @@ func (h *Handler) UpdateCustomerStatus(c echo.Context) error {
// UpdateCustomerVerification updates customer verification status (Web Panel)
// @Summary Update customer verification status
// @Description Update customer verification and compliance status
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param id path string true "Customer ID"
@@ -366,7 +366,7 @@ func (h *Handler) UpdateCustomerVerification(c echo.Context) error {
// VerifyCustomer verifies a customer (Web Panel)
// @Summary Verify customer
// @Description Mark a customer as verified
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param id path string true "Customer ID"
@@ -401,7 +401,7 @@ func (h *Handler) VerifyCustomer(c echo.Context) error {
// SuspendCustomer suspends a customer (Web Panel)
// @Summary Suspend customer
// @Description Suspend a customer account with optional reason
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param id path string true "Customer ID"
@@ -442,7 +442,7 @@ func (h *Handler) SuspendCustomer(c echo.Context) error {
// ActivateCustomer activates a customer (Web Panel)
// @Summary Activate customer
// @Description Activate a suspended customer account
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param id path string true "Customer ID"
@@ -477,7 +477,7 @@ func (h *Handler) ActivateCustomer(c echo.Context) error {
// GetCustomersByCompanyID retrieves customers by company ID (Web Panel)
// @Summary Get customers by company ID
// @Description Retrieve all customers associated with a specific company
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param companyId path string true "Company ID"
@@ -529,7 +529,7 @@ func (h *Handler) GetCustomersByCompanyID(c echo.Context) error {
// GetCustomersByType retrieves customers by type
// @Summary Get customers by type
// @Description Retrieve customers filtered by their type (individual, company, or government). Useful for administrative reporting and management.
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param type path string true "Customer type" Enums(individual, company, government)
@@ -585,7 +585,7 @@ func (h *Handler) GetCustomersByType(c echo.Context) error {
// GetCustomersByStatus retrieves customers by status
// @Summary Get customers by status
// @Description Retrieve customers filtered by their account status (active, inactive, suspended, or pending). Useful for administrative monitoring and management.
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param status path string true "Customer status" Enums(active, inactive, suspended, pending)
@@ -641,7 +641,7 @@ func (h *Handler) GetCustomersByStatus(c echo.Context) error {
// AssignCompaniesToCustomer assigns companies to a customer (Web Panel)
// @Summary Assign companies to a customer
// @Description Assign one or more companies to a specific customer.
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param id path string true "Customer ID"
@@ -682,7 +682,7 @@ func (h *Handler) AssignCompaniesToCustomer(c echo.Context) error {
// RemoveCompaniesFromCustomer removes companies from a customer (Web Panel)
// @Summary Remove companies from a customer
// @Description Remove one or more companies from a specific customer.
// @Tags Customers-Admin
// @Tags Admin-Customers
// @Accept json
// @Produce json
// @Param id path string true "Customer ID"
@@ -723,7 +723,7 @@ func (h *Handler) RemoveCompaniesFromCustomer(c echo.Context) error {
// Login handles customer authentication
// @Summary Customer login
// @Description Authenticate customer with username (email) and password. Returns access token, refresh token, and customer information upon successful authentication.
// @Tags Customers-Authorization
// @Tags Authorization
// @Accept json
// @Produce json
// @Param login body LoginForm true "Login credentials (username/email and password)"
@@ -757,7 +757,7 @@ func (h *Handler) Login(c echo.Context) error {
// RefreshToken handles customer token refresh
// @Summary Refresh customer access token
// @Description Refresh access token using a valid refresh token. This allows customers to maintain their session without re-authentication.
// @Tags Customers-Authorization
// @Tags Authorization
// @Accept json
// @Produce json
// @Param refresh body RefreshTokenForm true "Refresh token for generating new access token"
@@ -788,7 +788,7 @@ func (h *Handler) RefreshToken(c echo.Context) error {
// GetProfile retrieves customer profile information (Mobile)
// @Summary Get customer profile
// @Description Retrieve current customer profile information
// @Tags Customers-Authorization
// @Tags Authorization
// @Accept json
// @Produce json
// @Security BearerAuth
@@ -796,7 +796,7 @@ func (h *Handler) RefreshToken(c echo.Context) error {
// @Failure 401 {object} response.APIResponse "Unauthorized - Invalid or missing token"
// @Failure 404 {object} response.APIResponse "Not found - Customer not found"
// @Failure 500 {object} response.APIResponse "Internal server error"
// @Router /api/v1/ [get]
// @Router /api/v1/profile [get]
func (h *Handler) GetProfile(c echo.Context) error {
// Extract customer ID from JWT token context
customerID, err := GetCustomerIDFromContext(c)
@@ -818,7 +818,7 @@ func (h *Handler) GetProfile(c echo.Context) error {
// GetProfileWithCompanies retrieves customer profile with companies (Mobile)
// @Summary Get customer profile with companies
// @Description Retrieve current customer profile information along with their assigned companies.
// @Tags Customers-Authorization
// @Tags Authorization
// @Accept json
// @Produce json
// @Security BearerAuth
@@ -826,7 +826,7 @@ func (h *Handler) GetProfile(c echo.Context) error {
// @Failure 401 {object} response.APIResponse "Unauthorized - Invalid or missing token"
// @Failure 404 {object} response.APIResponse "Not found - Customer not found"
// @Failure 500 {object} response.APIResponse "Internal server error"
// @Router /api/v1/with-companies [get]
// @Router /api/v1/profile/with-companies [get]
func (h *Handler) GetProfileWithCompanies(c echo.Context) error {
// Extract customer ID from JWT token context
customerID, err := GetCustomerIDFromContext(c)
@@ -848,14 +848,14 @@ func (h *Handler) GetProfileWithCompanies(c echo.Context) error {
// Logout handles customer logout (Mobile)
// @Summary Customer logout
// @Description Logout customer and invalidate access token
// @Tags Customers-Authorization
// @Tags Authorization
// @Accept json
// @Produce json
// @Security BearerAuth
// @Success 200 {object} response.APIResponse "Logout successful"
// @Failure 401 {object} response.APIResponse "Unauthorized - Invalid or missing token"
// @Failure 500 {object} response.APIResponse "Internal server error"
// @Router /api/v1/logout [delete]
// @Router /api/v1/profile/logout [delete]
func (h *Handler) Logout(c echo.Context) error {
// Extract customer ID from JWT token context
customerID, err := GetCustomerIDFromContext(c)
-8
View File
@@ -81,14 +81,6 @@ func (s *customerService) CreateCustomer(ctx context.Context, form *CreateCustom
return nil, errors.New("customer with this email already exists")
}
// Check if company name already exists (for company customers)
if form.Type == string(CustomerTypeCompany) && form.CompanyName != nil {
existingCustomer, _ = s.repository.GetByCompanyName(ctx, *form.CompanyName)
if existingCustomer != nil {
return nil, errors.New("company with this name already exists")
}
}
// Check if registration number already exists (for company customers)
if form.Type == string(CustomerTypeCompany) && form.RegistrationNumber != nil {
existingCustomer, _ = s.repository.GetByRegistrationNumber(ctx, *form.RegistrationNumber)