chore: add new features for cabine

This commit is contained in:
2026-02-26 19:57:01 +01:00
parent 0fb4bd8a89
commit f91d4276cc
8 changed files with 467 additions and 323 deletions
+34 -2
View File
@@ -935,9 +935,41 @@ func GetPenaltiesStats(c *gin.Context) {
})
}
func ResetClientPointAdmin(c *gin.Context) {
userRole := c.GetString("role")
if userRole != "admin" && userRole != "cabine" {
c.JSON(http.StatusForbidden, gin.H{"error": "Accès refusé"})
return
}
username := c.Param("username")
if username == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "Username requis"})
return
}
var req struct {
ResetCancellationsPoints bool `json:"reset_cancellations_points"`
}
if err := c.ShouldBindJSON(&req); err != nil {
req.ResetCancellationsPoints = false
}
database := c.MustGet("database").(*db.Database)
err := database.ResetClientPoint(username, req.ResetCancellationsPoints)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"error": "Erreur lors de la réinitialisation",
"details": err.Error(),
})
return
}
c.JSON(http.StatusOK, gin.H{"message": "Points réinitialisés"})
}
// ResetClientPenaltiesAdmin réinitialise les pénalités d'un client (Admin seulement)
// POST /api/v2/admin/protected/client/:username/penalties/reset
// Body: {"reset_cancellations_count": false}
func ResetClientPenaltiesAdmin(c *gin.Context) {
userRole := c.GetString("role")
if userRole != "admin" && userRole != "cabine" {