chore: update

This commit is contained in:
2026-03-11 19:57:34 +01:00
parent f6b3948839
commit 375aa38454
62 changed files with 2714 additions and 1981 deletions
+46 -181
View File
@@ -45,13 +45,15 @@ func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services
}
// ============================================
// 📦 PRODUITS (v1) - PUBLIC (SANS middleware!)
// 📦 PRODUITS & CATÉGORIES (v1) - PUBLIC (SANS middleware!)
// ============================================
productsGroupV1 := router.Group("/api/v1")
{
productsGroupV1.GET("/products", handlers.GetAllProducts)
productsGroupV1.GET("/products/:id", handlers.GetProductByID)
productsGroupV1.GET("/products/category/:category", handlers.GetProductsByCategory)
productsGroupV1.GET("/categories", handlers.GetCategories)
productsGroupV1.GET("/app-settings", handlers.GetPublicSettings)
}
// ============================================
@@ -68,8 +70,8 @@ func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services
cartGroupV1.DELETE("/panier/clear", handlers.ClearBasket) // ✅ CORRIGÉ - Sans :username
// Commandes
cartGroupV1.POST("/checkout", middleware.OrderHoursMiddleware, handlers.ValidateBasket) // ✅ Auto-assign GPS
cartGroupV1.GET("/my-commands", handlers.GetMyCommandsWithTracking) // ✅ Avec suivi
cartGroupV1.POST("/checkout", middleware.OrderHoursMiddleware, middleware.BlockClientIfPenalty, handlers.ValidateBasket) // ✅ Auto-assign GPS
cartGroupV1.GET("/my-commands", handlers.GetMyCommandsWithTracking) // ✅ Avec suivi
// ⭐ NOUVEAUX - SUIVI CLIENT TEMPS RÉEL
cartGroupV1.GET("/commands/:id/eta", handlers.GetOrderETA) // ✅ AJOUTÉ
@@ -102,6 +104,9 @@ func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services
// 👤 PROFIL CLIENT - MODIFICATION PAR LE CLIENT
cartGroupV1.PUT("/profile/update", handlers.UpdateMyProfile) // ✅ Modifier mon profil
// 🎁 PARRAINAGE CLIENT
cartGroupV1.GET("/referral/balance", handlers.GetMyReferralBalance)
}
// ============================================
@@ -133,6 +138,14 @@ func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services
adminGroupV2 := router.Group("/api/v2/admin/protected")
adminGroupV2.Use(middleware.AdminMiddleware)
{
// PUSH TOKEN ADMIN
adminGroupV2.POST("/push-token", handlers.RegisterAdminPushToken)
adminGroupV2.DELETE("/push-token", handlers.UnregisterAdminPushToken)
// 🔔 NOTIFICATIONS ADMIN
adminGroupV2.GET("/notifications", handlers.GetLivreurNotifications)
adminGroupV2.POST("/notifications/read", handlers.MarkLivreurNotificationsRead)
// ============================================
// CLIENT - GESTION
// ============================================
@@ -163,6 +176,12 @@ func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services
adminGroupV2.POST("/products/:id/media", handlers.UploadMedia)
adminGroupV2.DELETE("/products/:id/media/:media_id", handlers.DeleteMedia)
// ============================================
// CATÉGORIES - GESTION ADMIN
// ============================================
adminGroupV2.POST("/categories", handlers.CreateCategory)
adminGroupV2.PUT("/categories/:id", handlers.UpdateCategory)
adminGroupV2.DELETE("/categories/:id", handlers.DeleteCategory)
// ============================================
// COMMANDES - GESTION DE BASE
// ============================================
adminGroupV2.GET("/orders", handlers.GetAllCommands)
@@ -225,6 +244,16 @@ func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services
adminGroupV2.GET("/penalties/all", handlers.GetAllClientsWithPenalties) // Liste clients avec pénalités
adminGroupV2.GET("/penalties/stats", handlers.GetPenaltiesStats)
// ============================================
// ⚙️ PARAMÈTRES GLOBAUX
// ============================================
adminGroupV2.GET("/settings", handlers.GetSettings)
adminGroupV2.PUT("/settings", handlers.UpdateSettings)
// 🎁 PARRAINAGE ADMIN
adminGroupV2.GET("/client/:username/referral", handlers.GetClientReferralAdmin)
adminGroupV2.POST("/client/:username/referral/credit", handlers.CreditClientReferralAdmin)
// ============================================
// ⭐⭐ ALERTES POLICE - GESTION ADMIN
// ============================================
@@ -241,6 +270,20 @@ func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services
cabineGroupV1 := router.Group("/api/v1/cabine")
cabineGroupV1.Use(middleware.CabineMiddleware)
{
// ============================================
// ADDRESSES - GESTION
// ============================================
cabineGroupV1.POST("/add/address", handlers.AddAddress)
cabineGroupV1.DELETE("/delete/address", handlers.DeleteAddress)
cabineGroupV1.GET("/addresses", handlers.GetAllAddress)
// PUSH TOKEN CABINE
cabineGroupV1.POST("/push-token", handlers.RegisterCabinePushToken)
cabineGroupV1.DELETE("/push-token", handlers.UnregisterCabinePushToken)
// 🔔 NOTIFICATIONS CABINE
cabineGroupV1.GET("/notifications", handlers.GetLivreurNotifications)
cabineGroupV1.POST("/notifications/read", handlers.MarkLivreurNotificationsRead)
cabineGroupV1.GET("/commands/:id/items", handlers.ShowItems)
cabineGroupV1.POST("/commands/:id/confirm-reception", handlers.StaffApproveDelivery)
cabineGroupV1.POST("/commands/:id/assign", handlers.AssignDeliveryPerson)
@@ -314,181 +357,3 @@ func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services
livreurGroupV1.DELETE("/push-token", handlers.UnregisterLivreurPushToken)
}
}
// ============================================
// 📝 DOCUMENTATION COMPLÈTE
// ============================================
/*
LISTE COMPLÈTE DES ROUTES:
═══════════════════════════════════════════════════════════════
CLIENT API (v1) - /api/v1
═══════════════════════════════════════════════════════════════
📌 AUTH (PUBLIC)
POST /api/v1/auth/register ✅ Créer compte client
POST /api/v1/auth/login ✅ Login client
POST /api/v1/auth/logout ✅ Logout client
📌 PRODUITS (PUBLIC)
GET /api/v1/products ✅ Tous les produits
GET /api/v1/products/:id ✅ Un produit
GET /api/v1/products/category/:cat ✅ Par catégorie
GET /api/v1/health ✅ Health check
📌 GÉOCODAGE (PUBLIC)
POST /api/v1/geocode ✅ Convertir adresse en GPS
POST /api/v1/validate-address ✅ Valider une adresse
📌 PANIER (AUTH CLIENT) 🔒
POST /api/v1/panier/add ✅ Ajouter au panier
GET /api/v1/panier/:username ✅ Voir panier
DELETE /api/v1/panier/remove ✅ Supprimer du panier
DELETE /api/v1/panier/clear ✅ Vider panier
📌 COMMANDES (AUTH CLIENT) 🔒
POST /api/v1/checkout ✅ Valider panier → AUTO-ASSIGN GPS
GET /api/v1/my-commands ✅ Mes commandes avec suivi
GET /api/v1/commands/:id/eta ⭐ NOUVEAU - ETA de la commande
GET /api/v1/commands/:id/status ⭐ NOUVEAU - Statut temps réel
GET /api/v1/commands/:id/tracking ⭐ NOUVEAU - Timeline détaillée
POST /api/v1/commands/:id/approve ✅ Approuver livraison
POST /api/v1/commands/:id/cancel ⭐ NOUVEAU - Annuler commande
GET /api/v1/my-cancellation-history ⭐ NOUVEAU - Historique annulations
GET /api/v1/my-commands/history ⭐ NOUVEAU - Historique commandes
GET /api/v1/my-commands/history/detailed ⭐ NOUVEAU - Historique détaillé
GET /api/v1/commands/:id/history ⭐ NOUVEAU - Historique d'une commande
📌 PÉNALITÉS (AUTH CLIENT) 🔒
GET /api/v1/penalties ⭐ NOUVEAU - Voir mes pénalités
📌 PROFIL (AUTH CLIENT) 🔒
PUT /api/v1/profile/update ⭐⭐ NOUVEAU - Modifier mon profil
═══════════════════════════════════════════════════════════════
ADMIN API (v2) - /api/v2/admin
═══════════════════════════════════════════════════════════════
📌 AUTH (PUBLIC)
POST /api/v2/admin/auth/register ✅ Créer compte admin
POST /api/v2/admin/auth/login ✅ Login admin
POST /api/v2/admin/auth/logout ✅ Logout admin
📌 GESTION UTILISATEURS (AUTH ADMIN) 🔒
GET /api/v2/admin/protected/all/clients ✅ Liste tous les clients
GET /api/v2/admin/protected/all/users ✅ Liste tous les users
PUT /api/v2/admin/protected/clients/:id ⭐⭐ NOUVEAU - Modifier un client
PUT /api/v2/admin/protected/users/:id ⭐⭐ NOUVEAU - Modifier un user
📌 PRODUITS (AUTH ADMIN) 🔒
GET /api/v2/admin/protected/products ✅ Tous produits
POST /api/v2/admin/protected/products ✅ Créer produit
GET /api/v2/admin/protected/products/:id ✅ Détail produit
PUT /api/v2/admin/protected/products/:id ✅ Modifier produit
DELETE /api/v2/admin/protected/products/:id ✅ Supprimer produit
📌 COMMANDES (AUTH ADMIN) 🔒
GET /api/v2/admin/protected/orders ✅ Toutes commandes
GET /api/v2/admin/protected/orders/:id ✅ Détail commande
PUT /api/v2/admin/protected/orders/:id/address ✅ Modifier adresse
POST /api/v2/admin/protected/orders/:id/force-validate ✅ Forcer validation
GET /api/v2/admin/protected/orders/cancelled ✅ Commandes annulées
GET /api/v2/admin/protected/commands/:id/deliveryman/location ✅ Position livreur pour commande
📌 AUTO-ASSIGNATION GPS (AUTH ADMIN) 🔒 ⭐
POST /api/v2/admin/protected/orders/:id/auto-assign ✅ Assigner 1 commande
POST /api/v2/admin/protected/commands/auto-assign-all ✅ Assigner toutes
📌 RECHERCHE LIVREUR (AUTH ADMIN) 🔒 ⭐
POST /api/v2/admin/protected/delivery/nearest ✅ Livreur le plus proche
POST /api/v2/admin/protected/delivery/distances ✅ Tous livreurs + distances
📌 GESTION QUEUES (AUTH ADMIN) 🔒 ⭐
GET /api/v2/admin/protected/delivery/queues ✅ Toutes les queues
GET /api/v2/admin/protected/delivery/:username/queue ✅ Queue d'un livreur
📌 VISUALISATION (AUTH ADMIN) 🔒 ⭐
GET /api/v2/admin/protected/delivery/heatmap ✅ Heatmap livreurs
📌 GÉOCODAGE (AUTH ADMIN) 🔒
POST /api/v2/admin/protected/geocode ✅ Convertir adresse
POST /api/v2/admin/protected/validate-address ✅ Valider adresse
📌 GESTION LIVREURS (AUTH ADMIN) 🔒
GET /api/v2/admin/protected/delivery-persons ✅ Liste livreurs
GET /api/v2/admin/protected/delivery-persons/:username ✅ Détails d'un livreur
GET /api/v2/admin/protected/delivery-persons/:username/stats ✅ Statistiques livreur
GET /api/v2/admin/protected/delivery-persons/:username/history ✅ Historique livreur
GET /api/v2/admin/protected/delivery-persons/:username/location ⭐ NOUVEAU - Position GPS livreur
PUT /api/v2/admin/protected/delivery-persons/:username/location ✅ Modifier position livreur
PUT /api/v2/admin/protected/delivery-persons/:username/status ✅ Modifier statut livreur
POST /api/v2/admin/protected/delivery-persons/:username/assign/:command_id ✅ Assigner manuellement
DELETE /api/v2/admin/protected/delivery-persons/:username/queue/:command_id ✅ Retirer de la queue
GET /api/v2/admin/protected/delivery-persons/:username/map-links ✅ Liens carte
📌 PÉNALITÉS (AUTH ADMIN) 🔒
POST /api/v2/admin/protected/penalty ✅ Appliquer pénalité
GET /api/v2/admin/protected/client/:username/penalties ✅ Voir pénalités client
POST /api/v2/admin/protected/client/:username/penalties/reset ✅ Reset pénalités
GET /api/v2/admin/protected/penalties/all ✅ Tous clients avec pénalités
GET /api/v2/admin/protected/penalties/stats ✅ Stats pénalités
═══════════════════════════════════════════════════════════════
CABINE API (v1) - /api/v1/cabine
═══════════════════════════════════════════════════════════════
📌 GESTION ITEMS (AUTH CABINE) 🔒
GET /api/v1/cabine/commands/:id/items ✅ Voir items d'une commande
PUT /api/v1/cabine/items/:item_id/status ✅ Changer statut item
GET /api/v1/cabine/commands/cancelled ✅ Commandes annulées
GET /api/v1/cabine/commands/:id/deliveryman/location ✅ Position livreur pour commande
📌 PÉNALITÉS (AUTH CABINE) 🔒
POST /api/v1/cabine/penalty ✅ Appliquer pénalité
GET /api/v1/cabine/client/:username/penalties ✅ Voir pénalités client
POST /api/v1/cabine/client/:username/penalties/reset ✅ Reset pénalités
GET /api/v1/cabine/penalties/all ✅ Tous clients avec pénalités
GET /api/v1/cabine/penalties/stats ✅ Stats pénalités
═══════════════════════════════════════════════════════════════
LIVREUR API (v1) - /api/v1/livreur
═══════════════════════════════════════════════════════════════
📌 LIVRAISONS (AUTH LIVREUR) 🔒
GET /api/v1/livreur/deliveries ✅ Mes livraisons (DONNÉES FILTRÉES)
GET /api/v1/livreur/deliveries/:id ⭐ NOUVEAU - Détail livraison
POST /api/v1/livreur/deliveries/:id/start ✅ Démarrer livraison
PUT /api/v1/livreur/deliveries/:id/status ✅ Changer statut (AVEC GPS)
📌 POSITION GPS (AUTH LIVREUR) 🔒
POST /api/v1/livreur/location/update ✅ Mettre à jour ma position
GET /api/v1/livreur/location ✅ Voir ma position actuelle
📌 STATUT (AUTH LIVREUR) 🔒
POST /api/v1/livreur/status ✅ Changer mon statut
GET /api/v1/livreur/status ✅ Voir mon statut
📌 QUEUE (AUTH LIVREUR) 🔒
GET /api/v1/livreur/queue ✅ Voir ma queue de livraisons
*/
// ============================================
// 🔧 CORRECTIONS APPLIQUÉES
// ============================================
/*
✅ 1. Route ETA ajoutée: GET /api/v1/commands/:id/eta
✅ 2. Route tracking détaillée: GET /api/v1/commands/:id/tracking
✅ 3. Route status temps réel: GET /api/v1/commands/:id/status
✅ 4. Panier clear sans :username (utilise JWT)
✅ 5. GeoService injecté dans le contexte global
✅ 6. Routes livreur pour GPS et statut
✅ 7. Routes admin pour gestion manuelle livreurs
⭐⭐ 8. Routes modification profil CLIENT par le client: PUT /api/v1/profile/update
⭐⭐ 9. Routes modification profil CLIENT par admin: PUT /api/v2/admin/protected/clients/:id
⭐⭐ 10. Routes modification profil USER par admin: PUT /api/v2/admin/protected/users/:id
⭐⭐ 11. Route position GPS livreur par admin: GET /api/v2/admin/protected/delivery-persons/:username/location
*/