Files
syops/backend/app/api/workspace_shipping_notice.py
T
hugo 2d7bdecc43 feat(shipping-notice): 新增货代发货通知全流程业务功能
- 新增后端完整业务支持:数据库模型、API接口、核心服务与RPA对接逻辑
- 新增前端工作台页面、路由适配与多语言国际化
- 新增Dify自定义工具OpenAPI规范、Agent配置脚本与部署文档
- 新增发货Excel模板生成脚本与默认模板
- 修复测试配置文件中的环境变量命名错误
- 更新本地开发环境变量配置
2026-06-01 21:22:22 +08:00

61 lines
2.0 KiB
Python

from __future__ import annotations
from flask import Blueprint, jsonify, request, send_file
from pathlib import Path
from app.auth_jwt import get_current_user
from app.services.shipping_notice.query_service import (
get_case_for_user,
list_cases_for_user,
serialize_case_detail,
)
workspace_shipping_notice_bp = Blueprint("workspace_shipping_notice", __name__)
def _require_user():
user = get_current_user()
if not user:
return None, (jsonify({"error": "Unauthorized"}), 401)
return user, None
@workspace_shipping_notice_bp.route("/shipping-cases", methods=["GET"])
def workspace_shipping_cases():
user, err = _require_user()
if err:
return err
process_status = str(request.args.get("process_status") or "").strip() or None
limit = int(request.args.get("limit") or 100)
return jsonify(list_cases_for_user(user.id, process_status=process_status, limit=limit))
@workspace_shipping_notice_bp.route("/shipping-cases/<case_no>", methods=["GET"])
def workspace_shipping_case_detail(case_no: str):
user, err = _require_user()
if err:
return err
case = get_case_for_user(case_no, user.id)
if not case:
return jsonify({"error": "Not found"}), 404
return jsonify(serialize_case_detail(case))
@workspace_shipping_notice_bp.route("/shipping-cases/<case_no>/export", methods=["GET"])
def workspace_shipping_case_export(case_no: str):
user, err = _require_user()
if err:
return err
case = get_case_for_user(case_no, user.id)
if not case or not case.export_file_path:
return jsonify({"error": "export file not found"}), 404
path = Path(case.export_file_path)
if not path.is_file():
return jsonify({"error": "export file missing on disk"}), 404
return send_file(
path,
as_attachment=True,
download_name=case.export_file_name or path.name,
mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
)