Files
TradeMate Dev 23a31f7c00 feat: silent wechat login, marketing tab optimization, admin page foundation
- Add silent WeChat login for MP/browser environments
- Fix Python 3.6 compatibility (remove typing.Annotated usage)
- Marketing page: tab-based content generation with category support
- Translate page: add auto-detect language default
- Homepage: add TTS playback, announcement ticker, remove redundant quick-actions
- Fix FAB button overlap with custom tabbar on customers/quotation pages
- Make openai/anthropic imports lazy for Python 3.6 compat
2026-05-14 00:30:48 +08:00

34 lines
1.1 KiB
Python

from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.ext.asyncio import AsyncSession
from app.database import get_db
from app.services.silent_pattern import SilentPatternService
from app.api.v1.deps import get_current_user_id
router = APIRouter()
@router.get("/risk-analysis")
async def get_silent_risk_analysis(
user_id: str = Depends(get_current_user_id),
db: AsyncSession = Depends(get_db),
):
service = SilentPatternService(db)
risks = await service.analyze_silent_risk(user_id)
return {
"items": risks,
"total": len(risks),
"high_risk": len([r for r in risks if r["risk_level"] == "high"]),
"medium_risk": len([r for r in risks if r["risk_level"] == "medium"]),
}
@router.get("/{customer_id}/suggestions")
async def get_followup_suggestions(
customer_id: str,
user_id: str = Depends(get_current_user_id),
db: AsyncSession = Depends(get_db),
):
service = SilentPatternService(db)
suggestions = await service.get_suggestions(user_id, customer_id)
return {"customer_id": customer_id, "suggestions": suggestions}