26 lines
1.0 KiB
Python
26 lines
1.0 KiB
Python
from fastapi import APIRouter, HTTPException
|
|
from db.repositories.experiment_parameters_repos import ExperimentParametersRepository
|
|
from network.schemas import ExperimentParametersBody
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post('/create')
|
|
async def create_experiment_parameters(data: ExperimentParametersBody):
|
|
try:
|
|
await ExperimentParametersRepository.create_from_pydantic(data)
|
|
return {"message": "Новая запись <ExperimentParameters> успешно добавлена"}
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=f"An error occurred: {str(e)}")
|
|
|
|
@router.get('/all')
|
|
async def get_all_experiment_parameters():
|
|
try:
|
|
result = await ExperimentParametersRepository.get_all()
|
|
|
|
if result:
|
|
return result
|
|
else:
|
|
return {"message": "Нет записей в <ExperimentParameters>, либо произошла непредвиденная ошибка"}
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=f"An error occurred: {str(e)}")
|