Files
auv/backend/routes/sectors.py
T

26 lines
896 B
Python

"""板块数据路由:行业板块、概念板块"""
from fastapi import APIRouter, Query, HTTPException
from services import eastmoney, mootdx
router = APIRouter()
@router.get("", summary="板块列表")
async def sector_list(
type: str = Query("industry", description="板块类型:industry=行业板块, concept=概念板块"),
):
if type not in ("industry", "concept"):
raise HTTPException(status_code=400, detail="板块类型错误,仅支持 industry/concept")
data = await eastmoney.fetch_sector_list(type)
if data:
return {"data": data, "count": len(data), "type": type}
# 降级:通达信 mootdx(不含实时资金流数据)
md_data = await mootdx.fetch_sector_list(type)
if md_data:
return {"data": md_data, "count": len(md_data), "type": type, "source": "mootdx"}
return {"data": [], "count": 0, "type": type}