from fastapi import APIRouter, Depends from fastapi_pagination import paginate, Params from sqlalchemy.orm import Session from app import schemas, get_db, crud from utils import web_try, sxtimeit router_af_task = APIRouter( prefix="/af/af_task", tags=["airflow_task-作业管理"], ) @router_af_task.get("/") @web_try() @sxtimeit def get_tasks(params: Params = Depends(), db: Session = Depends(get_db)): return paginate(crud.get_airflow_tasks(db), params) @router_af_task.get("/getOnce/{id}") @web_try() @sxtimeit def get_task_once(id: int, db: Session = Depends(get_db)): return crud.get_airflow_task_once(db, id) @router_af_task.put("/{item_id}") @web_try() @sxtimeit def update_task(item_id: int, update_item: schemas.AirflowTaskUpdate, db: Session = Depends(get_db)): return crud.update_airflow_task(db=db, item_id=item_id, update_item=update_item) @router_af_task.post("/") @web_try() @sxtimeit def add_task(item: schemas.AirflowTaskCreate, db: Session = Depends(get_db)): return crud.create_airflow_task(db, item)