#!/bin/bash

# 测试创建道具卡的脚本

# 登录获取token（假设有默认管理员账号）
echo "尝试登录获取token..."
LOGIN_RESPONSE=$(curl -s -X POST http://localhost:9991/api/admin/login \
  -H "Content-Type: application/json" \
  -d '{
    "username": "admin",
    "password": "21232f297a57a5a743894a0e4a801fc3"
  }')

echo "登录响应: $LOGIN_RESPONSE"

# 提取token（如果登录成功）
TOKEN=$(echo $LOGIN_RESPONSE | grep -o '"token":"[^"]*"' | cut -d'"' -f4)

if [ -n "$TOKEN" ]; then
  echo "获取到token: $TOKEN"
  
  # 创建测试道具卡
  echo "创建测试道具卡..."
  CREATE_RESPONSE=$(curl -s -X POST http://localhost:9991/api/admin/system_item_cards \
    -H "Content-Type: application/json" \
    -H "Authorization: $TOKEN" \
    -d '{
      "name": "测试抽奖卡",
      "card_type": 1,
      "scope_type": 1,
      "price": 100,
      "effect_type": 1,
      "reward_multiplier_x1000": 2000,
      "boost_rate_x1000": 0,
      "stacking_strategy": 1,
      "max_effect_value_x100