Files
hugo 8deae3146b feat(shipping-notice): 完成货代发货通知全流程开发与代码重构
- 新增PO号提取、预约ID解析(支持`PR@xxx`格式)工具,完善库存匹配逻辑
- 新增库存映射缓存、匹配/解析结果格式化摘要,优化用户提示
- 修复数据库迁移脚本未检查表存在的问题,避免全新部署失败
- 新增路径工具类统一管理相对路径,优化配置文件处理逻辑
- 归档旧文档,将部署、Dify配置合并到`shipping_notice.md`
- 新增完整单元测试与集成测试覆盖核心流程
- 更新前端国际化与会话管理逻辑,优化界面交互
2026-06-04 15:26:34 +08:00

29 lines
900 B
Python

"""Resolve paths relative to the backend package root (not process cwd)."""
from __future__ import annotations
from pathlib import Path
_BACKEND_DIR = Path(__file__).resolve().parents[1]
def backend_dir() -> Path:
return _BACKEND_DIR
def resolve_backend_relative_path(raw: str | None, default: Path | None = None) -> str:
"""Resolve env paths like ``data/foo`` or legacy ``backend/data/foo``."""
value = (raw or "").strip()
if not value:
if default is None:
raise ValueError("path is required when no default is provided")
return str(default.resolve())
path = Path(value)
if path.is_absolute():
return str(path.resolve())
normalized = value.replace("\\", "/")
if normalized.startswith("backend/"):
return str((_BACKEND_DIR / normalized[len("backend/") :]).resolve())
return str((_BACKEND_DIR / value).resolve())