ticket/wwwroot/api/ticket_create.dspy

27 lines
1.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ticket_create.dspy - 客户建单R1
# 入参: title, description, category?, priority?, attachments?(multipart 文件字段,可多个)
user_id = await get_user()
if not user_id:
return json.dumps({"success": False, "error": "请先登录"}, ensure_ascii=False)
org_id = await get_userorgid()
title = (params_kw.get('title') or '').strip()
description = (params_kw.get('description') or '').strip()
category = (params_kw.get('category') or 'other').strip()
priority = (params_kw.get('priority') or 'normal').strip()
# 附件Form(uitype=file,multiple) 走 FormData multipartahserver 已把文件落
# FileStorageparams_kw['attachments'] 为 webpath 字符串(单文件)或 list多文件
# 旧 JSON 数组字符串契约由 core.normalize_attachments 兼容。
attachments = params_kw.get('attachments')
ok, result = await create_ticket(user_id, org_id, title, description,
category=category, priority=priority,
attachments=attachments)
if ok:
return json.dumps({"success": True, "message": "工单已提交,智能助手正在处理",
"data": result}, ensure_ascii=False)
code, msg = result
return json.dumps({"success": False, "error": msg, "code": code}, ensure_ascii=False)