|
|
|
@ -32,3 +32,21 @@ def get_equipments(skip: int = 0, limit: int = 10, db: Session = Depends(get_db)
|
|
|
|
|
def get_equipment(equipment_id: int, db: Session = Depends(get_db)): |
|
|
|
|
equipment = crud.get_equipment(db=db, equipment_id=equipment_id) |
|
|
|
|
return equipment |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/devices", response_model=list[schemas.Device]) |
|
|
|
|
def get_devices(skip: int = 0, limit: int = 10, db: Session = Depends(get_db)): |
|
|
|
|
devices = crud.get_devices(db, skip=skip, limit=limit) |
|
|
|
|
return devices |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/devices/{device_id}", response_model=schemas.Device) |
|
|
|
|
def get_device(device_id: int, db: Session = Depends(get_db)): |
|
|
|
|
device = crud.get_device(db=db, device_id=device_id) |
|
|
|
|
return device |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/devices", response_model=schemas.Device) |
|
|
|
|
def create_device(device: schemas.DeviceCreate, db: Session = Depends(get_db)): |
|
|
|
|
db_device = crud.create_device(db=db, device=device) |
|
|
|
|
return db_device |
|
|
|
|