Files
PolyWeather/web/routers/scan.py
T
2569718930@qq.com 37494a7192 @
将 web/routes.py 拆分为模块化 router + service 架构

    - 新增 web/app_factory.py 集中注册 7 个域名 router
    - 新增 web/routers/ 薄壳路由层(auth/city/system/scan/ops/payments/analytics)
    - 新增 web/services/ 业务函数下沉(每域独立 service 文件)
    - web/routes.py 缩减为 city_runtime 的兼容重导出 facade
    - analysis_service.py/app.py 适配新入口并清理冗余导入

    Scope-risk: LOW — 全量 170 测试通过,router 注册顺序与原路由一致
    Tested: python -m pytest -q (170 passed), ruff check . (All checks passed)
@
2026-05-14 20:01:26 +08:00

57 lines
1.5 KiB
Python

"""Market scan and scan AI API routes."""
from fastapi import APIRouter, Request
from web.services.scan_api import (
get_scan_city_ai_forecast_payload,
get_scan_city_ai_stream_response,
get_scan_terminal_ai_payload,
get_scan_terminal_payload,
)
router = APIRouter(tags=["scan"])
@router.get("/api/scan/terminal")
async def scan_terminal(
request: Request,
scan_mode: str = "tradable",
min_price: float = 0.05,
max_price: float = 0.95,
min_edge_pct: float = 2.0,
min_liquidity: float = 500.0,
high_liquidity_only: bool = False,
market_type: str = "maxtemp",
time_range: str = "today",
limit: int = 25,
force_refresh: bool = False,
):
return await get_scan_terminal_payload(
request,
scan_mode=scan_mode,
min_price=min_price,
max_price=max_price,
min_edge_pct=min_edge_pct,
min_liquidity=min_liquidity,
high_liquidity_only=high_liquidity_only,
market_type=market_type,
time_range=time_range,
limit=limit,
force_refresh=force_refresh,
)
@router.post("/api/scan/terminal/ai")
async def scan_terminal_ai(request: Request):
return await get_scan_terminal_ai_payload(request)
@router.post("/api/scan/terminal/ai-city")
async def scan_terminal_ai_city(request: Request):
return await get_scan_city_ai_forecast_payload(request)
@router.post("/api/scan/terminal/ai-city/stream")
async def scan_terminal_ai_city_stream(request: Request):
return await get_scan_city_ai_stream_response(request)