chore: fix prices

This commit is contained in:
2026-03-02 03:28:45 +01:00
parent e7a6dc2230
commit 6c8af9acd4
10 changed files with 266 additions and 41 deletions
+48
View File
@@ -9,6 +9,54 @@ import (
"github.com/gin-gonic/gin"
)
// RegisterPushToken enregistre le push token Expo d'un client
// POST /api/v1/push-token
func RegisterPushToken(c *gin.Context) {
clientID := c.GetInt("client_id")
if clientID == 0 {
c.JSON(http.StatusUnauthorized, gin.H{"error": "Non authentifié"})
return
}
var req struct {
PushToken string `json:"push_token" binding:"required"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "push_token requis"})
return
}
database := c.MustGet("database").(*db.Database)
if err := database.SaveClientPushToken(clientID, req.PushToken); err != nil {
log.Printf("❌ [PUSH_TOKEN] Erreur sauvegarde token pour client %d: %v", clientID, err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "Erreur enregistrement push token"})
return
}
log.Printf("✅ [PUSH_TOKEN] Token enregistré pour client %d", clientID)
c.JSON(http.StatusOK, gin.H{"success": true})
}
// UnregisterPushToken supprime le push token d'un client (au logout)
// DELETE /api/v1/push-token
func UnregisterPushToken(c *gin.Context) {
clientID := c.GetInt("client_id")
if clientID == 0 {
c.JSON(http.StatusUnauthorized, gin.H{"error": "Non authentifié"})
return
}
database := c.MustGet("database").(*db.Database)
if err := database.DeleteClientPushToken(clientID); err != nil {
log.Printf("❌ [PUSH_TOKEN] Erreur suppression token pour client %d: %v", clientID, err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "Erreur suppression push token"})
return
}
log.Printf("✅ [PUSH_TOKEN] Token supprimé pour client %d", clientID)
c.JSON(http.StatusOK, gin.H{"success": true})
}
// GetClientNotifications retourne les notifications du client connecté
// GET /api/v1/notifications
func GetClientNotifications(c *gin.Context) {