"""统计路由：资产总览与续费倒计时"""

from typing import List

from fastapi import APIRouter, Depends, Query
from sqlmodel import Session

from app.database import get_session
from app.schemas.asset import AssetRead
from app.services import asset_service

router = APIRouter(prefix="/api/stats", tags=["stats"])


@router.get("/overview", summary="资产总览")
def overview(session: Session = Depends(get_session)) -> dict:
    return asset_service.get_overview(session)


@router.get("/expiring", response_model=List[AssetRead], summary="续费倒计时")
def expiring(
    days: int = Query(default=30, ge=1, le=365, description="统计未来 N 天内到期"),
    session: Session = Depends(get_session),
):
    return asset_service.get_expiring(session, days)
