Improve the frontend and repository layer
This commit is contained in:
@@ -207,6 +207,35 @@ async def delete_supplier(
|
||||
raise HTTPException(status_code=500, detail="Failed to delete supplier")
|
||||
|
||||
|
||||
@router.get(
|
||||
route_builder.build_base_route("suppliers/count"),
|
||||
response_model=dict
|
||||
)
|
||||
async def count_suppliers(
|
||||
tenant_id: str = Path(..., description="Tenant ID"),
|
||||
db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
"""Get count of suppliers for a tenant"""
|
||||
try:
|
||||
service = SupplierService(db)
|
||||
|
||||
# Use search with high limit to get all suppliers
|
||||
search_params = SupplierSearchParams(limit=10000)
|
||||
suppliers = await service.search_suppliers(
|
||||
tenant_id=UUID(tenant_id),
|
||||
search_params=search_params
|
||||
)
|
||||
|
||||
count = len(suppliers)
|
||||
logger.info("Retrieved supplier count", tenant_id=tenant_id, count=count)
|
||||
|
||||
return {"count": count}
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Error counting suppliers", tenant_id=tenant_id, error=str(e))
|
||||
raise HTTPException(status_code=500, detail="Failed to count suppliers")
|
||||
|
||||
|
||||
@router.get(
|
||||
route_builder.build_resource_action_route("suppliers", "supplier_id", "products"),
|
||||
response_model=List[Dict[str, Any]]
|
||||
|
||||
Reference in New Issue
Block a user