fix: route ordering customer/{id}/health before /{id}; CustomerHealthService for health-overview; keywords/competitor Header decorator; onboarding product_info dict; marketing template fallback; frontend style-switching tabs

This commit is contained in:
TradeMate Dev
2026-05-15 09:17:26 +08:00
parent 566f59f0e4
commit ac51716097
177 changed files with 348071 additions and 33 deletions
+22 -24
View File
@@ -57,6 +57,28 @@ async def get_all_health_scores(
return {"items": await service.get_all_health_scores(user_id)}
@router.get("/{customer_id}/health")
async def get_customer_health(
customer_id: str,
user_id: str = Depends(get_current_user_id),
db: AsyncSession = Depends(get_db),
):
service = CustomerHealthService(db)
return await service.get_customer_health(user_id, customer_id)
@router.get("/{customer_id}/conversation")
async def get_conversation(
customer_id: str,
page: int = 1,
size: int = 20,
user_id: str = Depends(get_current_user_id),
db: AsyncSession = Depends(get_db),
):
service = CustomerService(db)
return await service.get_conversation(user_id, customer_id, page, size)
@router.get("/{customer_id}")
async def get_customer(
customer_id: str,
@@ -165,27 +187,3 @@ async def export_customers(
headers={"Content-Disposition": "attachment; filename=customers.csv"},
)
@router.get("/{customer_id}/health")
async def get_customer_health(
customer_id: str,
user_id: str = Depends(get_current_user_id),
db: AsyncSession = Depends(get_db),
):
service = CustomerHealthService(db)
health = await service.get_customer_health(user_id, customer_id)
if not health:
raise HTTPException(status_code=404, detail="Customer not found")
return health
@router.get("/{customer_id}/conversation")
async def get_conversation(
customer_id: str,
page: int = Query(1, ge=1),
size: int = Query(50, ge=1, le=200),
user_id: str = Depends(get_current_user_id),
db: AsyncSession = Depends(get_db),
):
service = CustomerService(db)
return await service.get_conversation(user_id, customer_id, page, size)