471 lines
24 KiB
Go
471 lines
24 KiB
Go
// ============================================
|
|
// routes/routes.go - VERSION CORRIGÉE COMPLÈTE
|
|
// ============================================
|
|
|
|
package routes
|
|
|
|
import (
|
|
"gestion/db"
|
|
"gestion/handlers"
|
|
"gestion/middleware"
|
|
"gestion/services"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services.GeoService) {
|
|
|
|
// ============================================
|
|
// 🔐 MIDDLEWARE GLOBAL
|
|
// ============================================
|
|
router.Use(func(c *gin.Context) {
|
|
c.Set("database", database)
|
|
c.Set("geoService", geoService)
|
|
})
|
|
|
|
// ============================================
|
|
// 📋 PATTERN v1: CLIENT API
|
|
// ============================================
|
|
|
|
// ============================================
|
|
// 👤 AUTH ROUTES (v1) - PUBLIC
|
|
// ============================================
|
|
authGroupV1 := router.Group("/api/v1/auth")
|
|
{
|
|
authGroupV1.POST("/register", handlers.RegisterClient)
|
|
authGroupV1.POST("/login", handlers.LoginClient)
|
|
authGroupV1.POST("/logout", handlers.LogoutClient)
|
|
}
|
|
|
|
// Route change-password (auth client requise)
|
|
authProtectedV1 := router.Group("/api/v1/auth")
|
|
authProtectedV1.Use(middleware.ClientMiddleware)
|
|
{
|
|
authProtectedV1.PUT("/change-password", handlers.ChangePassword)
|
|
}
|
|
|
|
// ============================================
|
|
// 📦 PRODUITS (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)
|
|
}
|
|
|
|
// ============================================
|
|
// 🛒 PANIER (v1) - AVEC CLIENT MIDDLEWARE + SESSION
|
|
// ============================================
|
|
cartGroupV1 := router.Group("/api/v1")
|
|
cartGroupV1.Use(middleware.ClientMiddleware)
|
|
cartGroupV1.Use(middleware.ClientSessionMiddleware)
|
|
{
|
|
// Panier
|
|
cartGroupV1.POST("/panier/add", handlers.AddProductsBasket)
|
|
cartGroupV1.GET("/panier/:username", handlers.GetAllBaskets)
|
|
cartGroupV1.DELETE("/panier/remove", handlers.DeleteProductFromBasket)
|
|
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
|
|
|
|
// ⭐ NOUVEAUX - SUIVI CLIENT TEMPS RÉEL
|
|
cartGroupV1.GET("/commands/:id/eta", handlers.GetOrderETA) // ✅ AJOUTÉ
|
|
cartGroupV1.GET("/commands/:id/status", handlers.GetCommandStatus) // ✅ AJOUTÉ
|
|
cartGroupV1.GET("/commands/:id/tracking", handlers.GetCommandTracking) // ✅ AJOUTÉ
|
|
cartGroupV1.GET("/commands/:id", handlers.GetCommandByID)
|
|
cartGroupV1.GET("/commands/:id/items", handlers.GetCommandItemsWithDetails)
|
|
// Approbation livraison
|
|
cartGroupV1.POST("/commands/:id/approve", handlers.ApproveDelivery)
|
|
// ⭐ NOUVEAU - HISTORIQUE DES COMMANDES TERMINÉES
|
|
cartGroupV1.GET("/my-commands/history/detailed", handlers.GetMyCompletedOrdersWithItems)
|
|
cartGroupV1.GET("/commands/:id/history", handlers.GetOrderHistory)
|
|
// ⭐ NOUVEAU - ANNULATION DE COMMANDE (CLIENT)
|
|
cartGroupV1.POST("/commands/:id/cancel", handlers.CancelCommandByClient)
|
|
cartGroupV1.GET("/my-cancellation-history", handlers.GetMyCancellationHistory)
|
|
|
|
// ⭐ NOUVEAU - HISTORIQUE DES COMMANDES TERMINÉES
|
|
cartGroupV1.GET("/my-commands/history", handlers.GetClientCommandsHistory)
|
|
// ⭐⭐ PÉNALITÉS CLIENT
|
|
cartGroupV1.GET("/penalties", handlers.GetMyPenalties) // Voir mes pénalités
|
|
|
|
// 🔔 NOTIFICATIONS CLIENT
|
|
cartGroupV1.GET("/notifications", handlers.GetClientNotifications)
|
|
cartGroupV1.POST("/notifications/read", handlers.MarkNotificationsRead)
|
|
|
|
// 👤 PROFIL CLIENT - MODIFICATION PAR LE CLIENT
|
|
cartGroupV1.PUT("/profile/update", handlers.UpdateMyProfile) // ✅ Modifier mon profil
|
|
}
|
|
|
|
// ============================================
|
|
// 🌍 GÉOCODAGE PUBLIC (v1)
|
|
// ============================================
|
|
geoGroupV1 := router.Group("/api/v1")
|
|
{
|
|
geoGroupV1.POST("/geocode", handlers.GeocodeAddress)
|
|
geoGroupV1.POST("/validate-address", handlers.ValidateAddress)
|
|
}
|
|
|
|
// ============================================
|
|
// 📋 PATTERN v2: ADMIN API
|
|
// ============================================
|
|
|
|
// ============================================
|
|
// 👤 ADMIN AUTH (v2) - PUBLIC
|
|
// ============================================
|
|
adminAuthGroupV2 := router.Group("/api/v2/admin/auth")
|
|
{
|
|
adminAuthGroupV2.POST("/register", handlers.RegisterAdmin)
|
|
adminAuthGroupV2.POST("/login", handlers.LoginAdmin)
|
|
adminAuthGroupV2.POST("/logout", handlers.LogoutAdmin)
|
|
}
|
|
|
|
// ============================================
|
|
// 🔒 ADMIN PROTECTED (v2) - AVEC ADMIN MIDDLEWARE
|
|
// ============================================
|
|
adminGroupV2 := router.Group("/api/v2/admin/protected")
|
|
adminGroupV2.Use(middleware.AdminMiddleware)
|
|
{
|
|
// ============================================
|
|
// CLIENT - GESTION
|
|
// ============================================
|
|
adminGroupV2.GET("/all/clients", handlers.GetAllClients)
|
|
adminGroupV2.GET("/all/users", handlers.GetAllUsers)
|
|
// ⭐⭐ MODIFICATION DE PROFILS PAR ADMIN
|
|
adminGroupV2.PUT("/clients/:id", handlers.UpdateClientByAdmin) // ✅ Modifier un client
|
|
adminGroupV2.PUT("/users/:id", handlers.UpdateUserByAdmin) // ✅ Modifier un user
|
|
adminGroupV2.DELETE("/clients/:id", handlers.DeleteClient)
|
|
adminGroupV2.DELETE("/users/:id", handlers.DeleteUser)
|
|
adminGroupV2.POST("/users", handlers.CreateUser)
|
|
// Get location livreur
|
|
adminGroupV2.GET("/commands/:id/deliveryman/location", handlers.GetDeliverymanLocationForCommand)
|
|
// ============================================
|
|
// ADDRESSES - GESTION
|
|
// ============================================
|
|
adminGroupV2.POST("/add/address", handlers.AddAddress)
|
|
adminGroupV2.DELETE("/delete/address", handlers.DeleteAddress)
|
|
adminGroupV2.GET("/addresses", handlers.GetAllAddress)
|
|
// ============================================
|
|
// PRODUITS - GESTION
|
|
// ============================================
|
|
adminGroupV2.POST("/products", handlers.CreateProduct)
|
|
adminGroupV2.GET("/products", handlers.GetAllProducts)
|
|
adminGroupV2.GET("/products/:id", handlers.GetProductByID)
|
|
adminGroupV2.PUT("/products/update/:id", handlers.UpdateProduct)
|
|
adminGroupV2.DELETE("/products/:id", handlers.DeleteProduct)
|
|
adminGroupV2.POST("/products/:id/media", handlers.UploadMedia)
|
|
adminGroupV2.DELETE("/products/:id/media/:media_id", handlers.DeleteMedia)
|
|
// ============================================
|
|
// COMMANDES - GESTION DE BASE
|
|
// ============================================
|
|
adminGroupV2.GET("/orders", handlers.GetAllCommands)
|
|
adminGroupV2.GET("/orders/:id", handlers.GetCommandByID)
|
|
adminGroupV2.PUT("/orders/:id/address", handlers.UpdateCommandAddress)
|
|
adminGroupV2.POST("/orders/:id/force-validate", handlers.ValidateDelivery)
|
|
|
|
// ============================================
|
|
// ⭐ AUTO-ASSIGNATION GPS - ROUTES CRITIQUES
|
|
// ============================================
|
|
adminGroupV2.POST("/orders/:id/auto-assign", handlers.AutoAssignNearestDeliveryPerson)
|
|
adminGroupV2.POST("/orders/auto-assign-all", handlers.AutoAssignAllPendingCommands)
|
|
|
|
// ============================================
|
|
// RECHERCHE DU LIVREUR LE PLUS PROCHE
|
|
// ============================================
|
|
adminGroupV2.POST("/delivery/nearest", handlers.FindNearestDeliveryPerson)
|
|
adminGroupV2.POST("/delivery/distances", handlers.GetAllDeliveryDistances)
|
|
|
|
// ============================================
|
|
// GESTION DES QUEUES DES LIVREURS
|
|
// ============================================
|
|
adminGroupV2.GET("/delivery/queues", handlers.GetAllDeliveryQueues)
|
|
adminGroupV2.GET("/delivery/:username/queue", handlers.GetDeliverymanQueue)
|
|
|
|
// ============================================
|
|
// GÉOCODAGE (Admin uniquement)
|
|
// ============================================
|
|
adminGroupV2.POST("/validate-address", handlers.ValidateAddress)
|
|
adminGroupV2.POST("/geocode", handlers.GeocodeAddress)
|
|
|
|
// ============================================
|
|
// GESTION LIVREURS
|
|
// ============================================
|
|
adminGroupV2.GET("/delivery-persons", handlers.GetAvailableDeliveryPersons)
|
|
adminGroupV2.GET("/delivery-persons/:username", handlers.GetDeliveryPersonDetails)
|
|
adminGroupV2.POST("/delivery-persons/:username/assign/:command_id", handlers.AssignDeliveryPerson)
|
|
adminGroupV2.PUT("/delivery-persons/:username/status", handlers.UpdateDeliveryPersonStatusAdmin)
|
|
adminGroupV2.GET("/delivery-persons/:username/stats", handlers.GetDeliveryPersonStats)
|
|
adminGroupV2.GET("/delivery-persons/:username/history", handlers.GetDeliveryPersonHistory)
|
|
adminGroupV2.GET("/delivery-persons/:username/location", handlers.GetDeliveryPersonLocation) // ⭐ AJOUTÉ
|
|
adminGroupV2.PUT("/delivery-persons/update/:username/location", handlers.UpdateDeliveryPersonLocationAdmin)
|
|
adminGroupV2.DELETE("/delivery-persons/:username/queue/:command_id", handlers.RemoveCommandFromQueue)
|
|
adminGroupV2.GET("/delivery-persons/:username/map-links", handlers.GetDeliveryPersonMapLinks)
|
|
// Commandes annulées
|
|
adminGroupV2.GET("/orders/cancelled", handlers.GetAllCancelledOrders)
|
|
// ============================================
|
|
// ⭐⭐ PÉNALITÉS - GESTION ADMIN
|
|
// ============================================
|
|
adminGroupV2.POST("/penalty", handlers.ApplyClientPenalty) // Appliquer pénalité
|
|
adminGroupV2.GET("/client/:username/penalties", handlers.GetClientPenaltiesAdmin) // Voir pénalités client
|
|
adminGroupV2.POST("/client/:username/penalties/reset", handlers.ResetClientPenaltiesAdmin) // Reset pénalités
|
|
adminGroupV2.GET("/penalties/all", handlers.GetAllClientsWithPenalties) // Liste clients avec pénalités
|
|
adminGroupV2.GET("/penalties/stats", handlers.GetPenaltiesStats)
|
|
|
|
// ============================================
|
|
// ⭐⭐ ALERTES POLICE - GESTION ADMIN
|
|
// ============================================
|
|
adminGroupV2.GET("/alerts/:id", handlers.GetAlert) // Détails d'une alerte
|
|
adminGroupV2.DELETE("/delete/alerts/:id", handlers.DeleteAlert) // Supprimer une alerte
|
|
adminGroupV2.GET("/alerts", handlers.GetActiveAlerts) // ⭐ AJOUTÉ - Toutes les alertes actives
|
|
adminGroupV2.GET("/all/alerts", handlers.GetAllAlerts)
|
|
|
|
}
|
|
|
|
// ============================================
|
|
// 👨💼 CABINE ROUTES (v1) - AVEC CABINE MIDDLEWARE
|
|
// ============================================
|
|
cabineGroupV1 := router.Group("/api/v1/cabine")
|
|
cabineGroupV1.Use(middleware.CabineMiddleware)
|
|
{
|
|
cabineGroupV1.GET("/commands/:id/items", handlers.ShowItems)
|
|
cabineGroupV1.PUT("/items/:item_id/status", handlers.UpdateItemStatus)
|
|
cabineGroupV1.GET("/commands/:id/deliveryman/location", handlers.GetDeliverymanLocationForCommand)
|
|
cabineGroupV1.GET("/all/deliveryman", handlers.GetAllDeliveryMen)
|
|
cabineGroupV1.DELETE("/commands/:id", handlers.DeleteCommandByCabine)
|
|
// ⭐ NOUVEAU - ANNULATION PAR CABINE
|
|
cabineGroupV1.GET("/commands/cancelled", handlers.GetAllCancelledOrders)
|
|
cabineGroupV1.GET("/client/:username/penalties", handlers.GetClientPenaltiesAdmin) // Voir pénalités client
|
|
cabineGroupV1.POST("/client/:username/penalties/reset", handlers.ResetClientPenaltiesAdmin) // Reset pénalités
|
|
cabineGroupV1.POST("/client/:username/point/reset", handlers.ResetClientPointAdmin)
|
|
cabineGroupV1.GET("/penalties/all", handlers.GetAllClientsWithPenalties) // Liste clients avec pénalités
|
|
cabineGroupV1.GET("/penalties/stats", handlers.GetPenaltiesStats)
|
|
|
|
// ============================================
|
|
// ⭐⭐ ALERTES POLICE - CONSULTATION CABINE
|
|
// ============================================
|
|
cabineGroupV1.GET("/alerts/:id", handlers.GetAlert) // Détails d'une alerte
|
|
cabineGroupV1.GET("/alerts", handlers.GetActiveAlerts) // ⭐ AJOUTÉ - Toutes les alertes actives
|
|
cabineGroupV1.GET("/all/alerts", handlers.GetAllAlerts)
|
|
}
|
|
|
|
// ============================================
|
|
// 👨🚚 LIVREUR ROUTES (v1) - AVEC LIVREUR MIDDLEWARE
|
|
// ============================================
|
|
livreurGroupV1 := router.Group("/api/v1/livreur")
|
|
livreurGroupV1.Use(middleware.LivreurMiddleware)
|
|
{
|
|
// ============================================
|
|
// LIVRAISONS
|
|
// ============================================
|
|
livreurGroupV1.GET("/deliveries", handlers.GetMyDeliveries) // ✅ Données filtrées
|
|
livreurGroupV1.GET("/deliveries/:id", handlers.GetDeliveryDetails) // ✅ Détail filtré
|
|
livreurGroupV1.POST("/deliveries/:id/start", handlers.StartDelivery)
|
|
livreurGroupV1.PUT("/deliveries/:id/status", handlers.UpdateDeliveryStatus) // ✅ Avec GPS
|
|
|
|
// ============================================
|
|
// POSITION GPS
|
|
// ============================================
|
|
livreurGroupV1.POST("/location/update", handlers.UpdateLivreurLocation)
|
|
livreurGroupV1.GET("/location", handlers.GetMyLocation)
|
|
|
|
// ============================================
|
|
// STATUT LIVREUR
|
|
// ============================================
|
|
livreurGroupV1.POST("/update/status", handlers.UpdateDeliveryPersonStatus)
|
|
livreurGroupV1.GET("/status", handlers.GetMyStatus)
|
|
|
|
// ============================================
|
|
// QUEUE PERSONNELLE
|
|
// ============================================
|
|
livreurGroupV1.GET("/queue", handlers.GetMyQueue)
|
|
|
|
// ============================================
|
|
// ALERTES POLICE
|
|
// ============================================
|
|
livreurGroupV1.POST("/alert", handlers.AlertPolice) // ⭐ AJOUTÉ - Créer une alerte
|
|
livreurGroupV1.DELETE("/alert/:id", handlers.EndAlert) // Mettre fin à une alerte
|
|
livreurGroupV1.GET("/alerts", handlers.GetMyAlerts) // Voir mes alertes
|
|
livreurGroupV1.GET("/alert/:id", handlers.GetAlert) // Détail d'une alerte
|
|
}
|
|
}
|
|
|
|
// ============================================
|
|
// 📝 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
|
|
*/
|