attachment_biz.py 1.1 KB

1234567891011121314151617181920212223242526
  1. """附件上传 bizType 与 MinIO 目录映射(对齐原 CRM oss 上传语义)"""
  2. from __future__ import annotations
  3. # bizType → MinIO 相对目录(folder 未传时使用)
  4. BIZ_TYPE_DEFAULT_FOLDER: dict[str, str] = {
  5. "crm_contract_attachment": "crm/contract",
  6. "crm_contract_price_letter": "crm/contract/price-letter",
  7. "crm_contract_file": "crm/contract",
  8. "crm_quote_attachment": "crm/quote",
  9. "crm_customer_follow_attachment": "crm/customer/follow",
  10. "crm_opportunity_follow_attachment": "crm/opportunity/follow",
  11. "crm_clue_follow_attachment": "crm/clue/follow",
  12. "advance": "bx/advance",
  13. "reimburse_apply": "bx/reimburse",
  14. "advance_issue": "bx/advance-issue",
  15. "db_inventory_site_feedback": "db/inventory_site",
  16. "pl_transport_feedback": "pl/transport_feedback",
  17. }
  18. def resolve_upload_folder(*, folder: str = "", biz_type: str = "") -> str:
  19. """优先使用显式 folder;否则按 bizType 映射默认目录。"""
  20. explicit = (folder or "").strip()
  21. if explicit:
  22. return explicit
  23. return BIZ_TYPE_DEFAULT_FOLDER.get((biz_type or "").strip(), "")