#!/usr/bin/env python3
"""
直接测试网关
"""

import requests
import time
from config.settings import settings

# 先登录获取Token
login_data = {
    "username": settings.TEST_USERNAME,
    "password": settings.TEST_PASSWORD
}

print("1. 登录...")
response = requests.post(f"{settings.API_BASE_URL}/api/auth/login", json=login_data)
print(f"状态码: {response.status_code}")
print(f"响应: {response.text[:200]}...")

if response.status_code == 200:
    token = response.json().get('token')
    print(f"\nToken: {token[:50]}...")
    
    # 测试用户管理API
    print("\n2. 测试用户管理API...")
    headers = {
        "Authorization": f"Bearer {token}"
    }
    
    response2 = requests.get(f"{settings.API_BASE_URL}/api/users/page?page=0&size=10", headers=headers)
    print(f"状态码: {response2.status_code}")
    print(f"响应: {response2.text[:200]}...")
    
    # 测试用户统计API
    print("\n3. 测试用户统计API...")
    response3 = requests.get(f"{settings.API_BASE_URL}/api/users/count", headers=headers)
    print(f"状态码: {response3.status_code}")
    print(f"响应: {response3.text[:200]}...")
