refactor: 优化模板执行API并移除重复控制器
- 简化模板执行流程,移除后端图片审核逻辑,改为前端预审核 - 删除增强版模板控制器(enhanced-template.controller.ts),统一使用标准控制器 - 更新API文档,明确executionId、taskId、auditTaskId的使用场景 - 修复执行进度查询接口,使用executionId作为主要查询参数 - 完善单元测试,确保API变更后功能正常 - 添加CurrentUser装饰器,标准化用户信息获取方式
This commit is contained in:
49
swagger.json
49
swagger.json
@@ -95,7 +95,7 @@
|
||||
},
|
||||
"/api/v1/templates/code/{code}/execute": {
|
||||
"post": {
|
||||
"description": "根据模板代码执行AI生成任务,支持图片和视频生成。执行前会进行图片内容审核。",
|
||||
"description": "\n 根据模板代码执行AI生成任务,支持同步和异步两种审核模式:\n - 同步模式:立即返回审核结果,若通过则开始执行,返回 executionId 和 taskId\n - 异步模式:返回 executionId 和 auditTaskId,等待审核回调完成后开始执行\n \n ID说明:\n - executionId: 数据库执行记录主键,用于查询执行状态\n - taskId: 外部服务(N8N)任务ID,同步模式时返回\n - auditTaskId: 审核服务任务ID,异步模式时返回\n ",
|
||||
"operationId": "TemplateController_executeTemplateByCode",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -125,7 +125,15 @@
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TemplateExecuteResponseDto"
|
||||
"example": {
|
||||
"code": 200,
|
||||
"message": "模板执行已启动",
|
||||
"data": {
|
||||
"executionId": 123,
|
||||
"taskId": "n8n_task_456",
|
||||
"status": "processing"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -803,22 +811,49 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/templates/execution/{taskId}/progress": {
|
||||
"/api/v1/templates/execution/{executionId}/progress": {
|
||||
"get": {
|
||||
"description": "\n 根据 executionId 查询模板执行进度和状态。\n \n 注意:请使用执行接口返回的 executionId 作为查询参数,而不是 taskId 或 auditTaskId。\n \n 返回的状态包括:\n - pending_audit: 图片审核中\n - audit_failed: 图片审核失败\n - processing: 模板执行中\n - completed: 执行完成\n - failed: 执行失败\n ",
|
||||
"operationId": "TemplateController_getExecutionProgress",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "taskId",
|
||||
"name": "executionId",
|
||||
"required": true,
|
||||
"in": "path",
|
||||
"description": "执行记录ID(从执行接口返回的 executionId)",
|
||||
"schema": {
|
||||
"example": 123,
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
"description": "查询成功",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"example": {
|
||||
"code": 200,
|
||||
"message": "获取执行进度成功",
|
||||
"data": {
|
||||
"executionId": 123,
|
||||
"taskId": "n8n_task_456",
|
||||
"auditTaskId": "audit_task_789",
|
||||
"templateId": 1,
|
||||
"templateName": "照片修复模板",
|
||||
"status": "processing",
|
||||
"progress": 50,
|
||||
"inputImageUrl": "https://example.com/input.jpg",
|
||||
"outputUrl": null,
|
||||
"errorMessage": null,
|
||||
"createdAt": "2025-01-01T00:00:00Z",
|
||||
"updatedAt": "2025-01-01T00:05:00Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "请求参数错误",
|
||||
@@ -840,6 +875,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "执行记录不存在"
|
||||
},
|
||||
"500": {
|
||||
"description": "服务器内部错误",
|
||||
"content": {
|
||||
@@ -851,6 +889,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"summary": "查询模板执行进度",
|
||||
"tags": [
|
||||
"AI模板系统"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user