Implement customer management domain with authorization and API enhancements
- Introduced a new customer management domain, including entities, services, handlers, and forms for customer operations. - Added JWT-based user authorization settings in the configuration file for both user and customer management. - Updated API endpoints to reflect the new structure, including changes to health check and user management routes. - Enhanced Swagger documentation to include new customer-related endpoints and authorization details. - Refactored the Makefile to include a target for generating API documentation. - Removed obsolete documentation files to streamline the project structure.
This commit is contained in:
+15
-4
@@ -13,7 +13,6 @@ package main
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
// @host localhost:8081
|
||||
// @BasePath /admin/v1
|
||||
|
||||
// @securityDefinitions.apikey BearerAuth
|
||||
// @in header
|
||||
@@ -26,6 +25,12 @@ package main
|
||||
// @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 Health
|
||||
// @tag.description Health check operations
|
||||
|
||||
@@ -34,6 +39,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
"tm/internal/customer"
|
||||
"tm/internal/user"
|
||||
|
||||
_ "tm/cmd/web/docs" // This is generated by swag
|
||||
@@ -68,10 +74,12 @@ func main() {
|
||||
}()
|
||||
|
||||
// Initialize authorization service
|
||||
authService := initAuthorizationService(conf.Auth.JWT, redisClient, logger)
|
||||
userAuthService := initAuthorizationService(conf.UserAuthorization.JWT, redisClient, logger)
|
||||
customerAuthService := initAuthorizationService(conf.CustomerAuthorization.JWT, redisClient, logger)
|
||||
|
||||
// Initialize repositories with MongoDB connection manager
|
||||
userRepository := user.NewUserRepository(mongoManager, logger)
|
||||
customerRepository := customer.NewCustomerRepository(mongoManager, logger)
|
||||
|
||||
logger.Info("Repositories initialized successfully", map[string]interface{}{
|
||||
"repositories": []string{"customer", "user"},
|
||||
@@ -81,14 +89,16 @@ func main() {
|
||||
userValidator := user.NewValidationService()
|
||||
|
||||
// Initialize services with repositories
|
||||
userService := user.NewUserService(userRepository, logger, authService, userValidator)
|
||||
userService := user.NewUserService(userRepository, logger, userAuthService, userValidator)
|
||||
customerService := customer.NewCustomerService(customerRepository, logger, customerAuthService)
|
||||
|
||||
logger.Info("Services initialized successfully", map[string]interface{}{
|
||||
"services": []string{"customer", "user"},
|
||||
})
|
||||
|
||||
// Initialize handlers with services
|
||||
userHandler := user.NewUserHandler(userService, logger, userValidator, authService)
|
||||
userHandler := user.NewUserHandler(userService, logger, userValidator, userAuthService)
|
||||
customerHandler := customer.NewHandler(customerService, userHandler, customerAuthService, logger)
|
||||
|
||||
logger.Info("Handlers initialized successfully", map[string]interface{}{
|
||||
"handlers": []string{"customer", "user"},
|
||||
@@ -99,6 +109,7 @@ func main() {
|
||||
|
||||
// Register routes
|
||||
userHandler.RegisterRoutes(e)
|
||||
customerHandler.RegisterRoutes(e)
|
||||
|
||||
// Start server
|
||||
serverAddr := fmt.Sprintf("%s:%d", conf.Server.Host, conf.Server.Port)
|
||||
|
||||
Reference in New Issue
Block a user