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:
+8
-1
@@ -36,7 +36,14 @@ search:
|
||||
password: ""
|
||||
index_prefix: "tender_"
|
||||
|
||||
auth:
|
||||
user_authorization:
|
||||
jwt:
|
||||
access_secret: "your-super-secret-access-token-key-here-make-it-long-and-secure"
|
||||
refresh_secret: "your-super-secret-refresh-token-key-here-make-it-long-and-secure"
|
||||
access_expires_in: 3600 # 1 hour in seconds
|
||||
refresh_expires_in: 2592000 # 30 days in seconds
|
||||
|
||||
customer_authorization:
|
||||
jwt:
|
||||
access_secret: "your-super-secret-access-token-key-here-make-it-long-and-secure"
|
||||
refresh_secret: "your-super-secret-refresh-token-key-here-make-it-long-and-secure"
|
||||
|
||||
+1761
-19
File diff suppressed because it is too large
Load Diff
+1760
-19
File diff suppressed because it is too large
Load Diff
+1158
-19
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -13,7 +13,7 @@ import (
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} HealthResponse
|
||||
// @Router /health [get]
|
||||
// @Router /admin/v1/health [get]
|
||||
func healthHandler(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, HealthResponse{
|
||||
Status: "healthy",
|
||||
|
||||
+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