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,
|
2026-08-12 13:40:08 +08:00
|
|
|
get_wip_tasks, WipTask,
|
2026-08-12 13:25:49 +08:00
|
|
|
)
|
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
|
|
|
|
|
|
|
|
|
2026-08-12 13:40:08 +08:00
|
|
|
@router.get("/wip-tasks", response_model=list[WipTask])
|
|
|
|
|
async def wip_tasks(
|
|
|
|
|
limit: int = Query(20, ge=1, le=100),
|
2026-08-12 13:25:49 +08:00
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
2026-08-12 13:40:08 +08:00
|
|
|
"""在制品看板 — 当前所有 PENDING/WIP 任务,按滞留时间排序"""
|
|
|
|
|
return await get_wip_tasks(db, limit)
|