Perbaikan pembacaan data base

This commit is contained in:
2025-08-18 08:45:49 +07:00
parent a7d6005649
commit 6192a64f0a
23 changed files with 1833 additions and 743 deletions

View File

@@ -1,6 +1,7 @@
package v1
import (
retribusiHandlers "api-service/internal/handlers/retribusi"
"net/http"
"api-service/internal/config"
@@ -12,7 +13,6 @@ import (
ginSwagger "github.com/swaggo/gin-swagger"
authHandlers "api-service/internal/handlers/auth"
componentHandlers "api-service/internal/handlers/component"
)
// RegisterRoutes registers all API routes for version 1
@@ -35,10 +35,6 @@ func RegisterRoutes(cfg *config.Config) *gin.Engine {
v1 := router.Group("/api/v1")
{
// Public routes (no authentication required)
// Health endpoints
healthHandler := componentHandlers.NewHealthHandler()
v1.GET("/health", healthHandler.GetHealth)
v1.GET("/", healthHandler.HelloWorld)
// Authentication routes
authHandler := authHandlers.NewAuthHandler(authService)
@@ -53,25 +49,19 @@ func RegisterRoutes(cfg *config.Config) *gin.Engine {
v1.POST("/token/generate", tokenHandler.GenerateToken)
v1.POST("/token/generate-direct", tokenHandler.GenerateTokenDirect)
// Retribusi endpoints
retribusiHandler := retribusiHandlers.NewRetribusiHandler()
v1.GET("/retribusis", retribusiHandler.GetRetribusi)
v1.GET("/retribusi/:id", retribusiHandler.GetRetribusiByID)
v1.POST("/retribusis", retribusiHandler.CreateRetribusi)
v1.PUT("/retribusi/:id", retribusiHandler.UpdateRetribusi)
v1.DELETE("/retribusi/:id", retribusiHandler.DeleteRetribusi)
// Protected routes (require authentication)
protected := v1.Group("/")
protected.Use(middleware.JWTAuthMiddleware(authService))
{
// Product endpoints
productHandler := componentHandlers.NewProductHandler()
protected.GET("/products", productHandler.GetProduct)
protected.GET("/products/:id", productHandler.GetProductByID)
protected.POST("/products", productHandler.CreateProduct)
protected.PUT("/products/:id", productHandler.UpdateProduct)
protected.DELETE("/products/:id", productHandler.DeleteProduct)
// Example endpoints
exampleHandler := componentHandlers.NewExampleHandler()
protected.GET("/example", exampleHandler.GetExample)
protected.POST("/example", exampleHandler.PostExample)
// WebSocket endpoint
protected.GET("/websocket", WebSocketHandler)
protected.GET("/webservice", WebServiceHandler)