🐛 Fix activating badges

This commit is contained in:
2025-03-02 21:04:24 +08:00
parent bc31a94c98
commit 53d856c7a7
4 changed files with 7 additions and 6 deletions

View File

@ -18,11 +18,11 @@ func ActiveBadge(badge models.Badge) error {
accountId := badge.AccountID
tx := database.C.Begin()
if err := tx.Model(&badge).Where("account_id = ?", accountId).Update("is_active", false).Error; err != nil {
if err := tx.Model(&models.Badge{}).Where("account_id = ?", accountId).Update("is_active", false).Error; err != nil {
tx.Rollback()
return err
}
if err := tx.Model(&badge).Where("id = ?", badge.ID).Update("is_active", true).Error; err != nil {
if err := tx.Model(&models.Badge{}).Where("id = ?", badge.ID).Update("is_active", true).Error; err != nil {
tx.Rollback()
return err
}