from fastapi import APIRouter, HTTPException from db.repositories.recycling_parameters_repos import RecyclingParametersRepository from network.schemas import RecyclingParametersBody router = APIRouter() @router.post('/create') async def create_recycling_parameters(data: RecyclingParametersBody): try: await RecyclingParametersRepository.create_from_pydantic(data) return {"message": "Новая запись успешно добавлена"} except Exception as e: raise HTTPException(status_code=500, detail=f"An error occurred: {str(e)}") @router.get('/all') async def get_all_recycling_parameters(): try: result = await RecyclingParametersRepository.get_all() if result: return result else: return {"message": "Нет записей в , либо произошла непредвиденная ошибка"} except Exception as e: raise HTTPException(status_code=500, detail=f"An error occurred: {str(e)}")