()
| 21 | print(f"✅ 创建文件: {filepath}") |
| 22 | |
| 23 | def main(): |
| 24 | print("🚀 开始创建黄金市场分析系统项目...") |
| 25 | print("=" * 60) |
| 26 | |
| 27 | # 1. 创建目录结构 |
| 28 | directories = [ |
| 29 | "app", |
| 30 | "app/models", |
| 31 | "app/schemas", |
| 32 | "app/routers", |
| 33 | "app/agents", |
| 34 | "app/services", |
| 35 | "app/utils", |
| 36 | "app/tasks", |
| 37 | ] |
| 38 | |
| 39 | for dir_path in directories: |
| 40 | full_path = BACKEND_DIR / dir_path |
| 41 | full_path.mkdir(parents=True, exist_ok=True) |
| 42 | print(f"✅ 创建目录: {dir_path}") |
| 43 | |
| 44 | print("\n" + "=" * 60) |
| 45 | print("📝 创建核心文件...") |
| 46 | print("=" * 60) |
| 47 | |
| 48 | # 2. 创建 __init__.py 文件 |
| 49 | init_files = [ |
| 50 | "app/__init__.py", |
| 51 | "app/models/__init__.py", |
| 52 | "app/schemas/__init__.py", |
| 53 | "app/routers/__init__.py", |
| 54 | "app/agents/__init__.py", |
| 55 | "app/services/__init__.py", |
| 56 | "app/utils/__init__.py", |
| 57 | "app/tasks/__init__.py", |
| 58 | ] |
| 59 | |
| 60 | for file_path in init_files: |
| 61 | create_file(BACKEND_DIR / file_path, '"""黄金市场分析系统"""') |
| 62 | |
| 63 | # 3. 创建主应用文件 |
| 64 | create_file( |
| 65 | BACKEND_DIR / "app/main.py", |
| 66 | '''"""FastAPI 主应用入口""" |
| 67 | import os |
| 68 | from contextlib import asynccontextmanager |
| 69 | from fastapi import FastAPI |
| 70 | from fastapi.middleware.cors import CORSMiddleware |
| 71 | from loguru import logger |
| 72 | |
| 73 | from app.config import settings |
| 74 | from app.database import engine, Base |
| 75 | from app.routers import gold_prices, analysis, news, predictions |
| 76 | from app.scheduler import init_scheduler, shutdown_scheduler |
| 77 | |
| 78 | |
| 79 | @asynccontextmanager |
| 80 | async def lifespan(app: FastAPI): |
no test coverage detected