This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from src.db.models.tysc import Vendor
|
||||
from src.db.session import SessionDep
|
||||
@@ -20,3 +20,14 @@ def get_all_vendors(db: SessionDep) -> List[VendorResponse]:
|
||||
response = to_response(vendor)
|
||||
results.append(response)
|
||||
return results
|
||||
|
||||
@router.get("/vendors/{vendor_id}", response_model=VendorResponse)
|
||||
def get_vendor(vendor_id: str, db: SessionDep) -> VendorResponse:
|
||||
"""
|
||||
retrieve vendor by id as json response.
|
||||
"""
|
||||
vendor = db.get(Vendor, vendor_id)
|
||||
if vendor is None:
|
||||
raise HTTPException(status_code=404, detail="Vendor could not be found")
|
||||
response = to_response(vendor)
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user