Files
shanxia2.0/backend/app/core/attachment_biz.py
T
2026-06-06 19:44:18 +08:00

22 lines
904 B
Python

"""附件上传 bizType 与 MinIO 目录映射(对齐原 CRM oss 上传语义)"""
from __future__ import annotations
# bizType → MinIO 相对目录(folder 未传时使用)
BIZ_TYPE_DEFAULT_FOLDER: dict[str, str] = {
"crm_contract_attachment": "crm/contract",
"crm_contract_price_letter": "crm/contract/price-letter",
"crm_contract_file": "crm/contract",
"crm_quote_attachment": "crm/quote",
"crm_customer_follow_attachment": "crm/customer/follow",
"crm_opportunity_follow_attachment": "crm/opportunity/follow",
"crm_clue_follow_attachment": "crm/clue/follow",
}
def resolve_upload_folder(*, folder: str = "", biz_type: str = "") -> str:
"""优先使用显式 folder;否则按 bizType 映射默认目录。"""
explicit = (folder or "").strip()
if explicit:
return explicit
return BIZ_TYPE_DEFAULT_FOLDER.get((biz_type or "").strip(), "")