feat: add redeem batch revocation
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user