feat: add redeem batch revocation

This commit is contained in:
OpenClaw Agent
2026-09-17 02:20:11 +08:00
parent 8b31956c6d
commit c4aa30e564
2 changed files with 10 additions and 0 deletions
+1
View File
@@ -54,6 +54,7 @@ func main() {
admin.PUT("/users/:id", a.adminUpdateUser)
admin.GET("/redeem", a.adminListRedeemBatches)
admin.POST("/redeem", a.adminCreateRedeemBatch)
admin.POST("/redeem/:id/revoke", a.adminRevokeRedeemBatch)
admin.GET("/settings", a.getSettings)
admin.PUT("/settings", a.putSettings)
admin.POST("/webdav/test", a.testWebDAV)
+9
View File
@@ -129,6 +129,15 @@ func (a *App) redeem(c *gin.Context) {
c.JSON(200, gin.H{"credits": amount})
}
func (a *App) adminRevokeRedeemBatch(c *gin.Context) {
id := c.Param("id")
if err := a.db.Model(&RedeemCode{}).Where("batch_id = ? AND status = ?", id, "unused").Update("status", "revoked").Error; err != nil {
c.JSON(500, gin.H{"error": err.Error()})
return
}
c.JSON(200, gin.H{"ok": true})
}
func (a *App) adminListRedeemBatches(c *gin.Context) {
var batches []RedeemBatch
if err := a.db.Order("id desc").Limit(100).Find(&batches).Error; err != nil {