fix: 统一执行进度查询接口响应格式

- 更新 getExecutionProgress 方法使用 ResponseUtil 统一响应格式
- 添加 Promise<ApiResponse<any>> 返回类型声明
- 保持原有功能逻辑,优化响应消息提示
- 确保与项目其他接口响应格式一致
This commit is contained in:
imeepos 2025-09-04 20:19:33 +08:00
parent 6622488a74
commit d2acf1b702
1 changed files with 21 additions and 24 deletions

View File

@ -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<ApiResponse<any>> {
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;