job_log.py 583 B

12345678910111213141516171819
  1. import time
  2. from typing import List
  3. from app import models, schemas
  4. from sqlalchemy.orm import Session
  5. def create_job_log(db: Session, item: schemas.JobLogCreate):
  6. db_item = models.JobLog(**item.dict(), **{"trigger_code": 2, "handle_code": 2})
  7. db.add(db_item)
  8. db.commit()
  9. db.refresh(db_item)
  10. return db_item
  11. def get_job_logs(db: Session):
  12. res: List[models.JobLog] = db.query(models.JobLog).all()
  13. return res
  14. def get_job_log_once(db: Session, id: int):
  15. res: models.JobLog = db.query(models.JobLog).filter(models.JobLog.id == id).first()
  16. return res