23a31f7c00
- 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
34 lines
894 B
Python
34 lines
894 B
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from pydantic import BaseModel
|
|
from app.database import get_db
|
|
from app.models.feedback import Feedback
|
|
from app.api.v1.deps import get_current_user_id
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
class FeedbackRequest(BaseModel):
|
|
category: str = "general"
|
|
content: str
|
|
contact: str = ""
|
|
|
|
|
|
@router.post("")
|
|
async def submit_feedback(
|
|
data: FeedbackRequest,
|
|
user_id: str = Depends(get_current_user_id),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
if not data.content.strip():
|
|
raise HTTPException(status_code=400, detail="Content is required")
|
|
|
|
fb = Feedback(
|
|
user_id=user_id,
|
|
category=data.category,
|
|
content=data.content.strip(),
|
|
contact=data.contact.strip(),
|
|
)
|
|
db.add(fb)
|
|
await db.flush()
|
|
return {"status": "ok", "id": str(fb.id)} |