#!/bin/bash

# 测试日志格式脚本
# 用于演示新的emoji日志格式

echo "🧪 测试后端日志格式"
echo "================================"
echo ""

BASE_URL="http://localhost:8080"

echo "1️⃣ 测试健康检查 (GET 200)"
curl -s "$BASE_URL/health" > /dev/null
sleep 1

echo "2️⃣ 测试登录 (POST 200)"
curl -s -X POST "$BASE_URL/api/v1/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"account":"test@example.com","password":"Test@123"}' > /dev/null
sleep 1

echo "3️⃣ 测试404错误 (GET 404)"
curl -s "$BASE_URL/api/v1/not-found" > /dev/null
sleep 1

echo "4️⃣ 测试OPTIONS预检 (OPTIONS 204)"
curl -s -X OPTIONS "$BASE_URL/api/v1/user/profile" \
  -H "Origin: http://localhost:3001" > /dev/null
sleep 1

echo "5️⃣ 测试未授权 (GET 401)"
curl -s "$BASE_URL/api/v1/user/profile" > /dev/null
sleep 1

echo ""
echo "✅ 测试完成！"
echo "📋 查看日志："
echo "   tail -20 logs/app.log"
echo ""
echo "🎨 格式化查看（需要安装jq）："
echo "   tail -20 logs/app.log | jq '.'"
