refactor(api): simplify client and article search endpoints

This commit is contained in:
Fanilo-Nantenaina 2025-12-17 12:35:29 +03:00
parent 737e340679
commit 421f4d24dc

7
api.py
View file

@ -1151,9 +1151,7 @@ app.include_router(auth_router)
async def rechercher_clients(query: Optional[str] = Query(None)): async def rechercher_clients(query: Optional[str] = Query(None)):
try: try:
clients = sage_client.lister_clients(filtre=query or "") clients = sage_client.lister_clients(filtre=query or "")
clients_data = [ClientDetails(**c) for c in clients] return [ClientDetails(**c) for c in clients]
return {"success": True, "data": clients_data}
except Exception as e: except Exception as e:
logger.error(f"Erreur recherche clients: {e}") logger.error(f"Erreur recherche clients: {e}")
raise HTTPException(500, str(e)) raise HTTPException(500, str(e))
@ -1232,8 +1230,7 @@ async def ajouter_client(
async def rechercher_articles(query: Optional[str] = Query(None)): async def rechercher_articles(query: Optional[str] = Query(None)):
try: try:
articles = sage_client.lister_articles(filtre=query or "") articles = sage_client.lister_articles(filtre=query or "")
articles_data = [ArticleResponse(**a) for a in articles] return [ArticleResponse(**a) for a in articles]
return {"success": True, "data": articles_data}
except Exception as e: except Exception as e:
logger.error(f"Erreur recherche articles: {e}") logger.error(f"Erreur recherche articles: {e}")
raise HTTPException(500, str(e)) raise HTTPException(500, str(e))