2026-08-04 17:09:47 +08:00
|
|
|
"""Dashboard API"""
|
2026-08-12 13:25:49 +08:00
|
|
|
from fastapi import APIRouter, Depends, Query
|
2026-08-04 17:09:47 +08:00
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
|
from app.core.database import get_db
|
2026-08-12 13:25:49 +08:00
|
|
|
from app.services.dashboard_service import (
|
|
|
|
|
get_dashboard_stats, DashboardStats,
|
|
|
|
|
get_recent_activity, RecentActivity,
|
|
|
|
|
)
|
2026-08-04 17:09:47 +08:00
|
|
|
|
|
|
|
|
router = APIRouter(prefix="/dashboard", tags=["管理看板"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/stats", response_model=DashboardStats)
|
|
|
|
|
async def dashboard_stats(db: AsyncSession = Depends(get_db)):
|
|
|
|
|
return await get_dashboard_stats(db)
|
2026-08-12 13:25:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/recent-activity", response_model=list[RecentActivity])
|
|
|
|
|
async def recent_activity(
|
|
|
|
|
limit: int = Query(10, ge=1, le=50),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
"""最近任务动态 — 看板活动时间线"""
|
|
|
|
|
return await get_recent_activity(db, limit)
|