diff --git a/app/api/v2/endpoints/chest/router.py b/app/api/v2/endpoints/chest/router.py index 3148499..aedc7fa 100644 --- a/app/api/v2/endpoints/chest/router.py +++ b/app/api/v2/endpoints/chest/router.py @@ -117,6 +117,22 @@ def get_chest_items(chest_id: int, db: Session = Depends(get_db)): chest.items = kistenItems return chest +@router.get('/items/all', + response_model=List[ChestItemJoinedSchema], + tags=['chest-items']) +def get_all_chest_items(db: Session = Depends(get_db)): + # Get all chests + all_chests = [] + chests = chest_crud.get_all_chests(db) + logging.info('Get: All chests: {}'.format(chests)) + # Get all items for each chest + for chest in chests: + kistenItems = chest_crud.get_joined_items_by_chest_id(chest.id, db) + logging.info('Get: Items in chest {}: {}'.format(chest.id, kistenItems)) + chest.items = kistenItems + all_chests.append(chest) + return all_chests + @router.post('/{chest_id}/items', response_model=ChestItemQuantityCreateSchema, status_code=status.HTTP_201_CREATED, tags=['chest-items']) def add_item_to_chest(chest_id: int, item: ChestItemQuantityCreateSchema, db: Session = Depends(get_db)): @@ -168,4 +184,4 @@ def update_item_quantity_in_chest(chest_id: int, updated_quantity: ChestItemQuan chest_crud.update_item_in_chest(chest_id, updated_quantity.item_id, updated_quantity.anzahl, db) logging.info('Item {} in chest {} updated'.format(updated_quantity.item_id, chest_id)) - return updated_quantity \ No newline at end of file + return updated_quantity