d2736d1ef6
- AI routing rules now stored in system_configs DB table instead of hardcoded config - Multi-model support via name|model composite key for same-provider routing - UnifiedPayService with HMAC-SHA256 gateway integration (alipay/wechat) - Admin payment panel: list, stats, search, filter, refund - WeChat mini-program CI/CD via miniprogram-ci (v1.0.9) - Translation quota extended to LLM provider tier - SearchService with DB-driven provider config (bing/google_cse/searxng) - Footer cleanup across admin/workspace/uni-app - Private key excluded from git tracking
64 lines
2.1 KiB
Python
64 lines
2.1 KiB
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from typing import Optional, Dict, Any
|
|
from pydantic import BaseModel
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from app.database import get_db
|
|
from app.services.discovery import DiscoveryService
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
class SearchRequest(BaseModel):
|
|
product_description: str
|
|
target_market: str = "US"
|
|
|
|
|
|
class AnalyzeRequest(BaseModel):
|
|
company_url: str
|
|
product_description: str
|
|
|
|
|
|
class OutreachRequest(BaseModel):
|
|
company: Dict[str, Any]
|
|
product: Dict[str, Any]
|
|
|
|
|
|
@router.post("/search")
|
|
async def search_leads(req: SearchRequest, db: AsyncSession = Depends(get_db)):
|
|
if not req.product_description.strip():
|
|
raise HTTPException(status_code=400, detail="请填写产品描述")
|
|
svc = DiscoveryService(db=db)
|
|
try:
|
|
result = await svc.search(req.product_description, req.target_market)
|
|
return {"success": True, "data": result}
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=f"搜索失败: {str(e)}")
|
|
|
|
|
|
@router.post("/analyze")
|
|
async def analyze_company(req: AnalyzeRequest):
|
|
if not req.company_url.strip():
|
|
raise HTTPException(status_code=400, detail="请填写公司网址")
|
|
if not req.product_description.strip():
|
|
raise HTTPException(status_code=400, detail="请填写产品描述")
|
|
svc = DiscoveryService()
|
|
try:
|
|
result = await svc.analyze(req.company_url, req.product_description)
|
|
return {"success": True, "data": result}
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=f"分析失败: {str(e)}")
|
|
|
|
|
|
@router.post("/outreach")
|
|
async def generate_outreach(req: OutreachRequest):
|
|
if not req.company.get("name"):
|
|
raise HTTPException(status_code=400, detail="请填写公司名称")
|
|
if not req.product.get("name"):
|
|
raise HTTPException(status_code=400, detail="请填写产品名称")
|
|
svc = DiscoveryService()
|
|
try:
|
|
result = await svc.outreach(req.company, req.product)
|
|
return {"success": True, "data": result}
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=f"生成失败: {str(e)}")
|