programme.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from fastapi import APIRouter, Depends
  2. from sqlalchemy.orm import Session
  3. from app.common.security.auth import verify_project_admin, verify_users
  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("")
  13. @web_try()
  14. @sxtimeit
  15. def create_programme(item: schemas.ProgrammeCreate, token_data: schemas.TokenData = Depends(verify_project_admin), db: Session = Depends(get_db)):
  16. return crud.create_programme(db, item)
  17. @router.put("/start_jupyter")
  18. @web_try()
  19. @sxtimeit
  20. def start_jupyter(item: schemas.ProgrammeId, token_data: schemas.TokenData = Depends(verify_project_admin), db: Session = Depends(get_db)):
  21. return crud.start_jupyter(db, item)
  22. @router.put("/stop_jupyter")
  23. @web_try()
  24. @sxtimeit
  25. def stop_jupyter(item: schemas.ProgrammeId, token_data: schemas.TokenData = Depends(verify_project_admin), db: Session = Depends(get_db)):
  26. return crud.stop_jupyter(db, item)
  27. @router.put("/update_password")
  28. @web_try()
  29. @sxtimeit
  30. def update_jupyter_password(item: schemas.ProgrammeUpdate, token_data: schemas.TokenData = Depends(verify_project_admin), db: Session = Depends(get_db)):
  31. return crud.update_jupyter_password(db, item)
  32. @router.get("")
  33. @web_try()
  34. @sxtimeit
  35. def get_programme(token_data: schemas.TokenData = Depends(verify_users), db: Session = Depends(get_db)):
  36. return crud.get_programme(db)