Agridatalog / app /api /bbch.py
Agridatalogia's picture
Initial commit: AllTech Crop Science AI
6f9f2ac
Raw
History Blame Contribute Delete
770 Bytes
from fastapi import APIRouter , Query
from app.services.bbch_service import get_all_stages , get_stage_by_code , get_crop_list
from app.schemas.bbch import BBCHCategory , BBCHStage
from typing import List , Optional
router = APIRouter()
@router.get("/bbch/stages" , response_model=List[BBCHStage])
async def get_stages(crop_type: Optional[str] = Query(None , description="Filter by crop")):
return get_all_stages(crop_type)
@router.get("/bbch/stages/{code}" , response_model=Optional[BBCHStage])
async def get_stage(code: str, crop_type: Optional[str] = Query(None, description="Crop type")):
return get_stage_by_code(code , crop_type)
@router.get("/bbch/crops" , response_model=List[str])
async def get_crops():
return get_crop_list()