1. 完整16位产品身份证号显示(不再截断) 2. 日期筛选栏: 今天 | 近7天 | 近30天 | 全部 - 后端 recent-activity 支持 since/until ISO参数 - 默认展示今天动态,可按时间范围切换 3. 操作人兜底: TaskLog无operator_id时用任务assignee_id 4. 未读通知可点击跳转通知页面 + 快捷入口增加通知中心
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
"""Dashboard API"""
|
|
from datetime import datetime
|
|
from fastapi import APIRouter, Depends, Query
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from app.core.database import get_db
|
|
from app.services.dashboard_service import (
|
|
get_dashboard_stats, DashboardStats,
|
|
get_recent_activity, RecentActivity,
|
|
)
|
|
|
|
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)
|
|
|
|
|
|
@router.get("/recent-activity", response_model=list[RecentActivity])
|
|
async def recent_activity(
|
|
limit: int = Query(10, ge=1, le=50),
|
|
since: str | None = Query(None, description="起始日期 ISO格式 如 2026-08-12T00:00:00"),
|
|
until: str | None = Query(None, description="截止日期 ISO格式"),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
"""最近任务动态 — 支持日期范围筛选"""
|
|
since_dt = datetime.fromisoformat(since) if since else None
|
|
until_dt = datetime.fromisoformat(until) if until else None
|
|
return await get_recent_activity(db, limit, since=since_dt, until=until_dt)
|