Files
shanxia2.0/backend/app/core/attachment_biz.py
T
2026-06-07 00:40:01 +08:00

25 lines
1013 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",
"advance": "bx/advance",
"reimburse_apply": "bx/reimburse",
"advance_issue": "bx/advance-issue",
}
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(), "")