programme.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from fastapi import APIRouter, Depends
  2. from sqlalchemy.orm import Session
  3. from app.common.decorators import verify_admin, verify_all
  4. from utils.sx_time import sxtimeit
  5. from utils.sx_web import web_try
  6. import app.crud as crud
  7. from app import schemas, get_db
  8. router = APIRouter(
  9. prefix="/jpt/programme",
  10. tags=["programme-可视化编程管理"],
  11. )
  12. @router.post("", dependencies=[Depends(verify_admin)])
  13. @web_try()
  14. @sxtimeit
  15. def create_programme(item: schemas.ProgrammeCreate, db: Session = Depends(get_db)):
  16. return crud.create_programme(db, item)
  17. @router.put("/start_jupyter", dependencies=[Depends(verify_admin)])
  18. @web_try()
  19. @sxtimeit
  20. def start_jupyter(item: schemas.ProgrammeId, db: Session = Depends(get_db)):
  21. return crud.start_jupyter(db, item)
  22. @router.put("/stop_jupyter", dependencies=[Depends(verify_admin)])
  23. @web_try()
  24. @sxtimeit
  25. def stop_jupyter(item: schemas.ProgrammeId, db: Session = Depends(get_db)):
  26. return crud.stop_jupyter(db, item)
  27. @router.put("/update_password", dependencies=[Depends(verify_admin)])
  28. @web_try()
  29. @sxtimeit
  30. def update_jupyter_password(item: schemas.ProgrammeUpdate, db: Session = Depends(get_db)):
  31. return crud.update_jupyter_password(db, item)
  32. @router.get("", dependencies=[Depends(verify_all)])
  33. @web_try()
  34. @sxtimeit
  35. def get_programme(db: Session = Depends(get_db)):
  36. return crud.get_programme(db)