chore: fix
This commit is contained in:
@@ -952,16 +952,23 @@ func ResetClientPointAdmin(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
ResetCancellationsPoints bool `json:"reset_cancellations_points"`
|
||||
Pool int `json:"pool"` // 0=pool principal, 1=pool secondaire, -1=tous (défaut)
|
||||
}
|
||||
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
req.ResetCancellationsPoints = false
|
||||
req.Pool = -1 // défaut : reset total
|
||||
if err := c.ShouldBindJSON(&req); err == nil {
|
||||
// valeur reçue correctement
|
||||
}
|
||||
|
||||
database := c.MustGet("database").(*db.Database)
|
||||
|
||||
err := database.ResetClientPoint(username, req.ResetCancellationsPoints)
|
||||
extraPoolKey := ""
|
||||
if req.Pool >= 2 {
|
||||
if settings, err := database.GetSettings(); err == nil && req.Pool < len(settings.PointsPools) {
|
||||
extraPoolKey = settings.PointsPools[req.Pool].Key
|
||||
}
|
||||
}
|
||||
|
||||
err := database.ResetClientPoint(username, req.Pool, extraPoolKey)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": "Erreur lors de la réinitialisation",
|
||||
|
||||
Reference in New Issue
Block a user