from fastapi import APIRouter, Depends from sqlalchemy.orm import Session from app.common.decorators import verify_admin, verify_all from utils.sx_time import sxtimeit from utils.sx_web import web_try import app.crud as crud from app import schemas, get_db router = APIRouter( prefix="/jpt/programme", tags=["programme-可视化编程管理"], ) @router.post("", dependencies=[Depends(verify_admin)]) @web_try() @sxtimeit def create_programme(item: schemas.ProgrammeCreate, db: Session = Depends(get_db)): return crud.create_programme(db, item) @router.put("/start_jupyter", dependencies=[Depends(verify_admin)]) @web_try() @sxtimeit def start_jupyter(item: schemas.ProgrammeId, db: Session = Depends(get_db)): return crud.start_jupyter(db, item) @router.put("/stop_jupyter", dependencies=[Depends(verify_admin)]) @web_try() @sxtimeit def stop_jupyter(item: schemas.ProgrammeId, db: Session = Depends(get_db)): return crud.stop_jupyter(db, item) @router.put("/update_password", dependencies=[Depends(verify_admin)]) @web_try() @sxtimeit def update_jupyter_password(item: schemas.ProgrammeUpdate, db: Session = Depends(get_db)): return crud.update_jupyter_password(db, item) @router.get("", dependencies=[Depends(verify_all)]) @web_try() @sxtimeit def get_programme(db: Session = Depends(get_db)): return crud.get_programme(db)