1548406f29
Co-authored-by: lowmaster-chen <1119780489@qq.com> Co-authored-by: chenshuobo <1119780489@qq.com> Reviewed-on: #88 Co-authored-by: chenshuobo <chenshuobo@wonderable.ai> Co-committed-by: chenshuobo <chenshuobo@wonderable.ai>
28 lines
900 B
Python
28 lines
900 B
Python
"""admin 数据大盘(只读聚合)。"""
|
|
from __future__ import annotations
|
|
|
|
from datetime import date
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
|
|
from app.admin.deps import AdminDb, get_current_admin
|
|
from app.admin.repositories import stats
|
|
from app.admin.schemas.dashboard import DashboardOverview
|
|
|
|
router = APIRouter(
|
|
prefix="/admin/api/stats",
|
|
tags=["admin-stats"],
|
|
dependencies=[Depends(get_current_admin)],
|
|
)
|
|
|
|
|
|
@router.get("/overview", response_model=DashboardOverview, summary="大盘核心指标")
|
|
def overview(
|
|
db: AdminDb,
|
|
date_from: date | None = Query(None, description="北京时间自然日起始日 YYYY-MM-DD"),
|
|
date_to: date | None = Query(None, description="北京时间自然日结束日 YYYY-MM-DD"),
|
|
) -> DashboardOverview:
|
|
return DashboardOverview.model_validate(
|
|
stats.dashboard_overview(db, date_from=date_from, date_to=date_to)
|
|
)
|