21 lines
712 B
Python
21 lines
712 B
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from sqlalchemy.orm import Session
|
|
from database import get_db
|
|
from schema.workspace_schema import DataQuery
|
|
from dao.workspace_dao import execute_query, overview
|
|
|
|
router = APIRouter(prefix="/workspace", tags=["前端工作台"])
|
|
|
|
|
|
@router.post("/query", summary="各模块列表、筛选和统计(只读)")
|
|
def query(data: DataQuery, db: Session = Depends(get_db)):
|
|
try:
|
|
return execute_query(db, data)
|
|
except ValueError as error:
|
|
raise HTTPException(status_code=422, detail=str(error)) from None
|
|
|
|
|
|
@router.get("/overview", summary="工作台实时概览")
|
|
def get_overview(db: Session = Depends(get_db)):
|
|
return overview(db)
|