chore: add new features for cabine
This commit is contained in:
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user