feedback_service.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. """公开反馈提交业务"""
  2. from typing import Any, Dict, List, Optional
  3. from sqlalchemy.orm import Session
  4. from app.core.response import AppHTTPError
  5. from app.crud import feedback as feedback_crud
  6. def submit_feedback(
  7. db: Session,
  8. *,
  9. fb_type: str,
  10. content: str,
  11. target_name: Optional[str] = None,
  12. target_dept: Optional[str] = None,
  13. target_post: Optional[str] = None,
  14. reporter_name: Optional[str] = None,
  15. reporter_unit: Optional[str] = None,
  16. reporter_post: Optional[str] = None,
  17. reporter_phone: Optional[str] = None,
  18. attachment_urls: Optional[List[str]] = None,
  19. ) -> Dict[str, Any]:
  20. if not (content or "").strip():
  21. raise AppHTTPError(400, "内容不能为空")
  22. if not (fb_type or "").strip():
  23. raise AppHTTPError(400, "反馈类型不能为空")
  24. biz_no = feedback_crud.next_biz_no(db, "FK")
  25. row = feedback_crud.create_feedback(
  26. db,
  27. biz_no=biz_no,
  28. fb_type=fb_type.strip(),
  29. content=content.strip(),
  30. target_name=target_name,
  31. target_dept=target_dept,
  32. target_post=target_post,
  33. reporter_name=reporter_name,
  34. reporter_unit=reporter_unit,
  35. reporter_post=reporter_post,
  36. reporter_phone=reporter_phone,
  37. attachments=attachment_urls,
  38. status="待处理",
  39. )
  40. return {"id": row.id, "bizNo": row.biz_no}