# ticket_create.dspy - 客户建单(R1) # 入参: title, description, category?, priority?, attachments?(JSON数组字符串) 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() attachments = None att_raw = (params_kw.get('attachments') or '').strip() if att_raw: try: attachments = json.loads(att_raw) if not isinstance(attachments, list): attachments = None except Exception: attachments = None 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)