Files
shanxia2.0/backend/app/core/attachment_biz.py
T
2026-06-23 23:30:57 +08:00

27 lines
1.1 KiB
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",
"db_inventory_site_feedback": "db/inventory_site",
"pl_transport_feedback": "pl/transport_feedback",
}
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(), "")