#!/bin/bash

# 启动后端服务脚本

cd "$(dirname "$0")"

echo "🚀 启动后端服务..."
echo ""

# 检查Python环境
if ! command -v python3 &> /dev/null; then
    echo "❌ Python3 未安装"
    exit 1
fi

# 安装依赖（如果需要）
echo "📦 检查依赖..."
python3 -c "import fastapi, uvicorn" 2>/dev/null || {
    echo "正在安装依赖..."
    pip3 install fastapi uvicorn[standard] python-multipart pymysql sqlalchemy python-jose[cryptography] passlib[bcrypt] pydantic pydantic-settings -q
}

# 启动服务
echo "🌐 启动后端服务在端口 8037..."
echo ""

python3 -m uvicorn app.main:app \
    --host 0.0.0.0 \
    --port 8037 \
    --reload \
    --log-level info
