Enhance API documentation and restructure routes for improved clarity

- Updated README.md to include comprehensive Swagger documentation details, highlighting new features and endpoint categories.
- Introduced a new router structure to streamline route registration for admin and public endpoints, enhancing maintainability.
- Updated health check endpoint documentation to reflect comprehensive server status information.
- Enhanced customer and company management routes with improved descriptions and examples in Swagger.
- Refactored customer and user handlers to remove obsolete route registrations, aligning with the new router structure.
- Improved response handling in customer and user services to utilize string IDs consistently.
- Updated validation rules and forms for customer management to support multiple company assignments.
- Enhanced logging practices across services to ensure better traceability and error handling.
This commit is contained in:
n.nakhostin
2025-08-11 18:24:34 +03:30
parent 566fa07574
commit 3e4831c2e7
23 changed files with 3605 additions and 2087 deletions
+33 -29
View File
@@ -1,41 +1,45 @@
package main
// @title Tender Management API
// @version 1.0.0
// @description This is the API documentation for the Tender Management System.
// @termsOfService http://swagger.io/terms/
// @version 2.0.0
// @description This is a comprehensive API for the Tender Management System built with Clean Architecture principles and Domain-Driven Design (DDD) patterns. The API provides endpoints for user management, customer management, company management, and authentication for both web panel administration and mobile application access.
// @termsOfService https://tender-management.com/terms
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io
// @contact.name Tender Management API Support
// @contact.url https://tender-management.com/support
// @contact.email api-support@tender-management.com
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @license.name MIT
// @license.url https://opensource.org/licenses/MIT
// @host localhost:8081
// @BasePath /
// @securityDefinitions.apikey BearerAuth
// @in header
// @name Authorization
// @description Type "Bearer" followed by a space and JWT token.
// @tag.name Users
// @tag.description User management operations including authentication, profile management, and admin operations
// @tag.name Authorization
// @tag.description Authentication operations including login, logout, and token management
// @tag.name Customers-Admin
// @tag.description Customer management operations including authentication, profile management, and admin operations
// @tag.name Customers-Authorization
// @tag.description Customer authentication operations including login, logout, and token management
// @tag.name Companies-Admin
// @tag.description Company management operations for web panel including CRUD, customer assignment, and tag management
// @description Type "Bearer" followed by a space and JWT token. Example: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
// @tag.name Health
// @tag.description Health check operations
// @tag.description System health check operations for monitoring application status and dependencies
// @tag.name Authorization
// @tag.description User authentication and authorization operations including login, logout, token refresh, and password management for web panel administration
// @tag.name Users
// @tag.description Administrative user management operations including CRUD operations, role management, status updates, and profile management for web panel administrators
// @tag.name Customers-Admin
// @tag.description Administrative customer management operations for web panel including CRUD operations, company assignment, verification, status management, and comprehensive filtering with pagination
// @tag.name Customers-Authorization
// @tag.description Customer authentication and authorization operations for mobile application including login, logout, token refresh, and profile access
// @tag.name Companies-Admin
// @tag.description Administrative company management operations for web panel including CRUD operations, tag management, verification, status updates, comprehensive search and filtering, and statistical reporting
// @tag.name Companies-Mobile
// @tag.description Company-related operations for mobile application including company lookup, search, and basic information retrieval
import (
"context"
@@ -47,6 +51,7 @@ import (
"tm/internal/user"
_ "tm/cmd/web/docs" // This is generated by swag
"tm/cmd/web/router"
)
func main() {
@@ -95,8 +100,8 @@ func main() {
// Initialize services with repositories
userService := user.NewUserService(userRepository, logger, userAuthService, userValidator)
customerService := customer.NewCustomerService(customerRepository, logger, customerAuthService)
companyService := company.NewCompanyService(companyRepository, logger)
customerService := customer.NewCustomerService(customerRepository, logger, customerAuthService, companyService)
logger.Info("Services initialized successfully", map[string]interface{}{
"services": []string{"customer", "user", "company"},
@@ -115,9 +120,8 @@ func main() {
e := initHTTPServer(conf, logger)
// Register routes
userHandler.RegisterRoutes(e)
customerHandler.RegisterRoutes(e)
companyHandler.RegisterRoutes(e)
router.RegisterAdminRoutes(e, userHandler, companyHandler, customerHandler)
router.RegisterPublicRoutes(e, customerHandler)
// Start server
serverAddr := fmt.Sprintf("%s:%d", conf.Server.Host, conf.Server.Port)