Files
holy-python/apifox-business-tasks.openapi.json

240 lines
10 KiB
JSON
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.
{
"openapi": "3.0.3",
"info": {
"title": "Holy蟹业务任务接口",
"version": "1.2.0",
"description": "前端调用的业务后端任务接口。继续采集沿用原任务 ID;重新采集创建新任务。"
},
"servers": [
{
"url": "http://127.0.0.1:8000",
"description": "本地业务后端,请在 Apifox 环境中改成实际地址"
}
],
"paths": {
"/api/v1/acceptance-tasks": {
"post": {
"summary": "创建项目验收任务",
"description": "关键词截图取证必须填写 keywords,无需飞书链接;笔记收录必须填写 feishu_links,可选传入仅供本任务使用的 custom_cookie。",
"tags": ["项目验收"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/CreateAcceptanceTask"}
}
}
},
"responses": {"201": {"description": "验收任务创建成功"}}
}
},
"/api/v1/acceptance-devices": {
"post": {
"summary": "添加验收截图设备",
"description": "向 framework-db 设备库新增或重新启用设备,后续周期下发读取最新启用设备。",
"tags": ["项目验收"],
"requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["xhs_account_id"], "properties": {"xhs_account_id": {"type": "string"}, "account_name": {"type": "string"}, "device_code": {"type": "string"}, "phone": {"type": "string"}}}}}},
"responses": {"201": {"description": "设备添加成功"}}
}
},
"/api/v1/acceptance-devices/{account_id}": {
"delete": {
"summary": "删除验收截图设备",
"description": "将设备标记为停用;历史采集数据保留,后续下发不再选择。",
"tags": ["项目验收"],
"parameters": [{"name": "account_id", "in": "path", "required": true, "schema": {"type": "string"}}],
"responses": {"200": {"description": "设备已停用"}, "404": {"description": "设备不存在"}}
}
},
"/api/v1/acceptance-tasks/{task_id}/collect-now": {
"post": {
"summary": "立即采集并下发指令",
"description": "复用原任务配置创建独立的新一轮采集。截图取证会立即请求 Framework 下发设备指令。",
"tags": ["项目验收"],
"parameters": [{"$ref": "#/components/parameters/TaskId"}],
"responses": {"201": {"description": "新一轮验收任务已创建"}}
}
},
"/api/v1/acceptance-tasks/{task_id}/collect-crawler-now": {
"post": {
"summary": "立即启动完整验收采集",
"description": "使用项目搜索词、当前全部可用 Cookie 和全部启用截图设备创建完整采集;批次按 Asia/Shanghai 自然日归属,同日重采仍属于同一日期批次。",
"tags": ["项目验收"],
"parameters": [{"$ref": "#/components/parameters/TaskId"}],
"responses": {"201": {"description": "爬虫采集批次已启动"}}
}
},
"/api/v1/acceptance-tasks/{task_id}": {
"patch": {
"summary": "修改验收项目配置",
"description": "修改根项目名称、搜索关键词和匹配关键词,并同步更新相同 dashboard_batch_key 的数据看板主体和问题选项。",
"tags": ["项目验收"],
"parameters": [{"$ref": "#/components/parameters/TaskId"}],
"requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["name", "keywords", "match_keywords"], "properties": {"name": {"type": "string"}, "keywords": {"type": "array", "items": {"type": "string"}}, "match_keywords": {"type": "array", "items": {"type": "string"}}}}}}},
"responses": {"200": {"description": "项目与数据看板配置同步成功"}}
}
},
"/api/v1/acceptance-tasks/{task_id}/cancel": {
"post": {
"summary": "停止项目验收采集",
"description": "仅停止当前等待中或运行中的采集批次,并阻止后台解析与截图轮询继续反写任务状态;不会修改该项目已设置的周期计划。已经下发到设备的外部指令可能仍会执行。",
"tags": ["项目验收"],
"parameters": [{"$ref": "#/components/parameters/TaskId"}],
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {"reason": {"type": "string"}}
}
}
}
},
"responses": {
"200": {"description": "验收任务已停止"},
"409": {"description": "任务已经进入不可停止的终态"}
}
}
},
"/api/v1/acceptance-tasks/{task_id}/retry-failed-devices": {
"post": {
"summary": "重新采集全部失败截图设备",
"description": "按每个关键词读取最新 XAPI 结果,仅将失败、取消、异常或已完成但无截图的设备精确重新下发。成功设备不会重复执行,新批次继续归入原验收任务。",
"tags": ["项目验收"],
"parameters": [{"$ref": "#/components/parameters/TaskId"}],
"responses": {
"200": {"description": "失败设备重新下发成功"},
"409": {"description": "没有失败设备或任务不支持截图重采"}
}
}
},
"/api/v1/acceptance-tasks/{task_id}/schedule": {
"put": {
"summary": "设置多日周期采集",
"description": "按服务所在时区,在选中的每个星期于开始时间创建新一轮采集;结束时间用于限制过期任务,超过区间后自动顺延到下一次。兼容旧版 weekday 单值。",
"tags": ["项目验收"],
"parameters": [{"$ref": "#/components/parameters/TaskId"}],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["weekdays", "start_time", "end_time"],
"properties": {
"weekdays": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {"type": "integer", "minimum": 1, "maximum": 7},
"description": "可多选;1=周一,7=周日"
},
"start_time": {"type": "string", "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$", "example": "01:00"},
"end_time": {"type": "string", "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$", "example": "04:30"}
}
},
"example": {"weekdays": [1, 3, 5], "start_time": "01:00", "end_time": "04:30"}
}
}
},
"responses": {"200": {"description": "周期设置成功"}}
}
},
"/api/v1/acceptance-tasks/{task_id}/schedule/stop": {
"post": {
"summary": "停止周期采集",
"description": "关闭该任务后续的每周执行,不影响已经开始的采集任务。",
"tags": ["项目验收"],
"parameters": [{"$ref": "#/components/parameters/TaskId"}],
"responses": {"200": {"description": "周期采集已停止"}}
}
},
"/api/v1/tasks/{task_id}/cancel": {
"post": {
"summary": "停止任务",
"tags": ["问一问任务控制"],
"parameters": [{"$ref": "#/components/parameters/TaskId"}],
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {"type": "object", "properties": {"reason": {"type": "string"}}},
"example": {"reason": "用户主动取消"}
}
}
},
"responses": {"200": {"description": "停止请求成功"}}
}
},
"/api/v1/tasks/{task_id}/retry": {
"post": {
"summary": "继续采集(兼容路径)",
"description": "沿用业务任务 ID 和爬虫任务 ID,从 framework 检查点继续。",
"tags": ["问一问任务控制"],
"parameters": [{"$ref": "#/components/parameters/TaskId"}],
"responses": {"200": {"description": "恢复成功"}}
}
},
"/api/v1/tasks/{task_id}/resume": {
"post": {
"summary": "继续采集",
"description": "沿用业务任务 ID 和爬虫任务 ID,从 framework 检查点继续。",
"tags": ["问一问任务控制"],
"parameters": [{"$ref": "#/components/parameters/TaskId"}],
"responses": {"200": {"description": "恢复成功"}}
}
},
"/api/v1/tasks/{task_id}/recollect": {
"post": {
"summary": "重新全量采集",
"description": "复制原任务配置,创建新的业务任务 ID 和爬虫任务 ID,从头执行。",
"tags": ["问一问任务控制"],
"parameters": [{"$ref": "#/components/parameters/TaskId"}],
"responses": {"201": {"description": "新任务创建成功"}}
}
}
},
"components": {
"schemas": {
"CreateAcceptanceTask": {
"type": "object",
"required": ["acceptance_method"],
"properties": {
"name": {"type": "string"},
"acceptance_method": {"type": "string", "enum": ["screenshot", "data-analysis"]},
"feishu_links": {
"type": "array",
"items": {"type": "string", "format": "uri"},
"description": "笔记收录必填;关键词截图取证可为空。"
},
"keywords": {
"type": "array",
"maxItems": 20,
"items": {"type": "string"},
"description": "关键词截图取证至少填写 1 个;笔记收录选填。"
},
"device_count": {"type": "integer", "minimum": 1},
"custom_cookie": {
"type": "string",
"maxLength": 16384,
"writeOnly": true,
"description": "仅用于笔记收录。填写后仅使用该 Cookie;留空时使用 Cookie 池全部可用凭据。不会在任务详情中返回。"
},
"created_by_id": {"type": "string"},
"created_by_name": {"type": "string"}
}
}
},
"parameters": {
"TaskId": {
"name": "task_id",
"in": "path",
"required": true,
"description": "Holy蟹业务任务 ID,例如 HC-20260723-ABCDE",
"schema": {"type": "string"}
}
}
}
}