fix: 统一执行进度查询接口响应格式
- 更新 getExecutionProgress 方法使用 ResponseUtil 统一响应格式 - 添加 Promise<ApiResponse<any>> 返回类型声明 - 保持原有功能逻辑,优化响应消息提示 - 确保与项目其他接口响应格式一致
This commit is contained in:
parent
6622488a74
commit
d2acf1b702
|
|
@ -432,7 +432,7 @@ export class TemplateController {
|
||||||
* @returns 执行进度信息
|
* @returns 执行进度信息
|
||||||
*/
|
*/
|
||||||
@Get('execution/:taskId/progress')
|
@Get('execution/:taskId/progress')
|
||||||
async getExecutionProgress(@Param('taskId', ParseIntPipe) taskId: number) {
|
async getExecutionProgress(@Param('taskId', ParseIntPipe) taskId: number): Promise<ApiResponse<any>> {
|
||||||
try {
|
try {
|
||||||
const execution = await this.executionRepository.findOne({
|
const execution = await this.executionRepository.findOne({
|
||||||
where: { id: taskId },
|
where: { id: taskId },
|
||||||
|
|
@ -446,29 +446,26 @@ export class TemplateController {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return ResponseUtil.success({
|
||||||
success: true,
|
taskId: execution.id,
|
||||||
data: {
|
templateId: execution.templateId,
|
||||||
taskId: execution.id,
|
templateName: execution.template?.name,
|
||||||
templateId: execution.templateId,
|
userId: execution.userId,
|
||||||
templateName: execution.template?.name,
|
platform: execution.platform,
|
||||||
userId: execution.userId,
|
type: execution.type,
|
||||||
platform: execution.platform,
|
status: execution.status,
|
||||||
type: execution.type,
|
progress: execution.progress,
|
||||||
status: execution.status,
|
inputImageUrl: execution.inputImageUrl,
|
||||||
progress: execution.progress,
|
outputUrl: execution.outputUrl,
|
||||||
inputImageUrl: execution.inputImageUrl,
|
thumbnailUrl: execution.thumbnailUrl,
|
||||||
outputUrl: execution.outputUrl,
|
errorMessage: execution.errorMessage,
|
||||||
thumbnailUrl: execution.thumbnailUrl,
|
creditCost: execution.creditCost,
|
||||||
errorMessage: execution.errorMessage,
|
startedAt: execution.startedAt,
|
||||||
creditCost: execution.creditCost,
|
completedAt: execution.completedAt,
|
||||||
startedAt: execution.startedAt,
|
executionDuration: execution.executionDuration,
|
||||||
completedAt: execution.completedAt,
|
createdAt: execution.createdAt,
|
||||||
executionDuration: execution.executionDuration,
|
updatedAt: execution.updatedAt,
|
||||||
createdAt: execution.createdAt,
|
}, '获取执行进度成功');
|
||||||
updatedAt: execution.updatedAt,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof HttpException) {
|
if (error instanceof HttpException) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue