From d2acf1b7026d02f42251954d8b49f2b33b20f58d Mon Sep 17 00:00:00 2001 From: imeepos Date: Thu, 4 Sep 2025 20:19:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新 getExecutionProgress 方法使用 ResponseUtil 统一响应格式 - 添加 Promise> 返回类型声明 - 保持原有功能逻辑,优化响应消息提示 - 确保与项目其他接口响应格式一致 --- src/controllers/template.controller.ts | 45 ++++++++++++-------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/controllers/template.controller.ts b/src/controllers/template.controller.ts index bc0bda0..71c6287 100644 --- a/src/controllers/template.controller.ts +++ b/src/controllers/template.controller.ts @@ -432,7 +432,7 @@ export class TemplateController { * @returns 执行进度信息 */ @Get('execution/:taskId/progress') - async getExecutionProgress(@Param('taskId', ParseIntPipe) taskId: number) { + async getExecutionProgress(@Param('taskId', ParseIntPipe) taskId: number): Promise> { try { const execution = await this.executionRepository.findOne({ where: { id: taskId }, @@ -446,29 +446,26 @@ export class TemplateController { ); } - return { - success: true, - data: { - taskId: execution.id, - templateId: execution.templateId, - templateName: execution.template?.name, - userId: execution.userId, - platform: execution.platform, - type: execution.type, - status: execution.status, - progress: execution.progress, - inputImageUrl: execution.inputImageUrl, - outputUrl: execution.outputUrl, - thumbnailUrl: execution.thumbnailUrl, - errorMessage: execution.errorMessage, - creditCost: execution.creditCost, - startedAt: execution.startedAt, - completedAt: execution.completedAt, - executionDuration: execution.executionDuration, - createdAt: execution.createdAt, - updatedAt: execution.updatedAt, - }, - }; + return ResponseUtil.success({ + taskId: execution.id, + templateId: execution.templateId, + templateName: execution.template?.name, + userId: execution.userId, + platform: execution.platform, + type: execution.type, + status: execution.status, + progress: execution.progress, + inputImageUrl: execution.inputImageUrl, + outputUrl: execution.outputUrl, + thumbnailUrl: execution.thumbnailUrl, + errorMessage: execution.errorMessage, + creditCost: execution.creditCost, + startedAt: execution.startedAt, + completedAt: execution.completedAt, + executionDuration: execution.executionDuration, + createdAt: execution.createdAt, + updatedAt: execution.updatedAt, + }, '获取执行进度成功'); } catch (error) { if (error instanceof HttpException) { throw error;