sql_app: Added function to get room info (temp, people ...)

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2022-05-23 21:04:19 +03:00
parent 36123b1090
commit f4b0e886cc
2 changed files with 7 additions and 0 deletions

View File

@ -39,6 +39,9 @@ def get_access_log_for_door_by_door_mac(db: Session, bluetooth_mac : str):
def get_access_log_for_user_by_id(db: Session, id : str): def get_access_log_for_user_by_id(db: Session, id : str):
return db.query(models.DoorAccessLog).filter(models.DoorAccessLog.user_id == id).all() return db.query(models.DoorAccessLog).filter(models.DoorAccessLog.user_id == id).all()
def get_room_data_now(db: Session):
return db.query(models.RoomSensorData)[-1]
def create_user(db: Session, user: schemas.UserCreate): def create_user(db: Session, user: schemas.UserCreate):
key = crypto.gen_new_key(user.password) key = crypto.gen_new_key(user.password)
salt = key[1] salt = key[1]

View File

@ -189,6 +189,10 @@ def get_iot_access_list_for_user(db: Session = Depends(get_db), current_user: sc
user = crud.get_user_by_username(db, current_user.username) user = crud.get_user_by_username(db, current_user.username)
return user.authorized_devices return user.authorized_devices
@app.get("/admin/roominfo/now/", tags=['Admin'])
def get_room_data(db: Session = Depends(get_db)):
return crud.get_room_data_now(db)
@app.post("/users/open", tags=['Users']) @app.post("/users/open", tags=['Users'])
def issue_open_door_command(command: schemas.OpenDoorRequestTime, def issue_open_door_command(command: schemas.OpenDoorRequestTime,
db: Session = Depends(get_db), db: Session = Depends(get_db),