status_timestamp.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from sqlalchemy.orm import Session
  2. from app.crud.base import CRUDBase
  3. from app.models.devices.status_timestamp import BlowyFeedbackTime, HighSpeedTime
  4. from app.schemas.device.status_timestamp import (
  5. BlowyFeedbackTimeCreate,
  6. BlowyFeedbackTimeUpdate,
  7. HighSpeedTimeCreate,
  8. HighSpeedTimeUpdate,
  9. )
  10. class CRUDBlowyFeedbackTime(
  11. CRUDBase[
  12. BlowyFeedbackTime,
  13. BlowyFeedbackTimeCreate,
  14. BlowyFeedbackTimeUpdate,
  15. ]
  16. ):
  17. def get_time_by_device(
  18. self, db: Session, device_id: str
  19. ) -> BlowyFeedbackTime | None:
  20. return (
  21. db.query(self.model)
  22. .filter(BlowyFeedbackTime.device_id == device_id)
  23. .first()
  24. )
  25. class CRUDHighSpeedTime(
  26. CRUDBase[HighSpeedTime, HighSpeedTimeCreate, HighSpeedTimeUpdate]
  27. ):
  28. def get_time_by_device(
  29. self, db: Session, device_id: str
  30. ) -> HighSpeedTime | None:
  31. return db.query(self.model).filter(HighSpeedTime.device_id == device_id).first()
  32. blowy_feedback_time = CRUDBlowyFeedbackTime(BlowyFeedbackTime)
  33. high_speed_time = CRUDHighSpeedTime(HighSpeedTime)