Skip to content

Commit

Permalink
insert_client.py
Browse files Browse the repository at this point in the history
  • Loading branch information
WSL0809 committed Apr 17, 2024
1 parent 778c30c commit de95afc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/insert_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ def update_client_and_room(db, insert_client_recv: InsertClientRecv):
)

try:
room_status = db.execute(check_room_status_sql, {"room": insert_client_recv.room}).fetchone()[0]
if room_status == occupied:
raise HTTPException(status_code=400, detail="room occupied")
if insert_client_recv.room is not None:
room_status = db.execute(check_room_status_sql, {"room": insert_client_recv.room}).fetchone()[0]
if room_status == occupied:
raise HTTPException(status_code=400, detail="room occupied")
except SQLAlchemyError as e:
db.rollback()
raise HTTPException(status_code=400, detail=f"检查房间{insert_client_recv.room}是否存在,ERROR: {e}")
Expand Down

0 comments on commit de95afc

Please sign in to comment.