package main

import (
	"fmt"
	"log"

	"bindbox-game/internal/repository/mysql"
)

func main() {
	// 1. 初始化配置 (configs 包的 init 函数会自动加载)
	// configs.Init()

	// 2. 连接数据库
	repo, err := mysql.New()
	if err != nil {
		log.Fatalf("Failed to connect to database: %v", err)
	}

	db := repo.GetDbW()

	fmt.Println("Starting inventory reset...")

	// 3. 执行重置操作：将所有奖品的剩余库存 (quantity) 重置为初始库存 (original_qty)
	result := db.Exec("UPDATE activity_reward_settings SET quantity = original_qty WHERE quantity != original_qty")
	if result.Error != nil {
		log.Fatalf("Failed to reset inventory: %v", result.Error)
	}

	fmt.Printf("Successfully repaired inventory data.\nRows affected: %d\n", result.RowsAffected)
}
