Compare commits

...

2 Commits

Author SHA1 Message Date
imeepos d2acf1b702 fix: 统一执行进度查询接口响应格式
- 更新 getExecutionProgress 方法使用 ResponseUtil 统一响应格式
- 添加 Promise<ApiResponse<any>> 返回类型声明
- 保持原有功能逻辑,优化响应消息提示
- 确保与项目其他接口响应格式一致
2025-09-04 20:19:33 +08:00
imeepos 6622488a74 fix: 修复 taskId 字段映射错误
- 将 taskId 字段映射改为 task_id,匹配实际的数据库字段名
- 解决 'Unknown column execution.taskId' 查询错误
- 确保所有字段映射与数据库表结构一致
2025-09-04 20:15:32 +08:00
2 changed files with 38 additions and 41 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;

View File

@ -51,11 +51,11 @@ export class TemplateExecutionEntity {
id: number;
/** 模板ID - 关联的N8N模板ID标识使用的模板配置 */
@Column({ name: 'template_id' })
@Column({ name: 'templateId' })
templateId: number;
/** 用户ID - 发起执行任务的用户标识 */
@Column({ name: 'user_id' })
@Column({ name: 'userId' })
userId: string;
/** 任务ID - 外部系统(如N8N)返回的任务标识符,用于回调时匹配任务 */
@ -75,15 +75,15 @@ export class TemplateExecutionEntity {
prompt: string;
/** 输入图片URL - 作为参考或处理基础的输入图片地址(可选) */
@Column({ name: 'input_image_url', length: 500, nullable: true })
@Column({ name: 'inputImageUrl', length: 500, nullable: true })
inputImageUrl: string;
/** 输出内容URL - 生成完成后的图片或视频文件地址 */
@Column({ name: 'output_url', length: 500, nullable: true })
@Column({ name: 'outputUrl', length: 500, nullable: true })
outputUrl: string;
/** 缩略图URL - 生成内容的预览缩略图地址,用于快速预览 */
@Column({ name: 'thumbnail_url', length: 500, nullable: true })
@Column({ name: 'thumbnailUrl', length: 500, nullable: true })
thumbnailUrl: string;
/** 执行状态 - 当前任务的处理状态 */
@ -99,51 +99,51 @@ export class TemplateExecutionEntity {
progress: number;
/** 错误信息 - 任务失败时的详细错误描述 */
@Column({ name: 'error_message', type: 'text', nullable: true })
@Column({ name: 'errorMessage', type: 'text', nullable: true })
errorMessage: string;
/** 执行结果 - AI模型返回的完整结果数据包含生成参数和元信息 */
@Column({ name: 'execution_result', type: 'json', nullable: true })
@Column({ name: 'executionResult', type: 'json', nullable: true })
executionResult: any;
/** 积分消耗 - 本次执行实际消耗的用户积分数量 */
@Column({ name: 'credit_cost', default: 0 })
@Column({ name: 'creditCost', default: 0 })
creditCost: number;
/** 积分交易ID - 关联的积分消费记录ID用于财务对账和退款处理 */
@Column({ name: 'credit_transaction_id', length: 100, nullable: true })
@Column({ name: 'creditTransactionId', length: 100, nullable: true })
creditTransactionId: string;
/** 输入参数 - 用户提供的完整输入参数,包含提示词、样式、尺寸等配置 */
@Column({ name: 'input_params', type: 'json', nullable: true })
@Column({ name: 'inputParams', type: 'json', nullable: true })
inputParams: any;
/** 执行配置 - 模板执行的技术配置,包含模型参数、生成选项等 */
@Column({ name: 'execution_config', type: 'json', nullable: true })
@Column({ name: 'executionConfig', type: 'json', nullable: true })
executionConfig: any;
/** 开始执行时间 - 任务实际开始处理的时间戳 */
@Column({ name: 'started_at', nullable: true })
@Column({ name: 'startedAt', nullable: true })
startedAt: Date;
/** 完成时间 - 任务执行完成(成功或失败)的时间戳 */
@Column({ name: 'completed_at', nullable: true })
@Column({ name: 'completedAt', nullable: true })
completedAt: Date;
/** 执行时长 - 任务的实际处理时间(毫秒),用于性能分析和优化 */
@Column({ name: 'execution_duration', nullable: true })
@Column({ name: 'executionDuration', nullable: true })
executionDuration: number;
/** 创建时间 - 执行记录的创建时间戳 */
@CreateDateColumn({ name: 'created_at' })
@CreateDateColumn({ name: 'createdAt' })
createdAt: Date;
/** 更新时间 - 记录最后修改时间,用于状态变更追踪 */
@UpdateDateColumn({ name: 'updated_at' })
@UpdateDateColumn({ name: 'updatedAt' })
updatedAt: Date;
/** 模板关系 - 与N8N模板实体的多对一关系 */
@ManyToOne(() => N8nTemplateEntity)
@JoinColumn({ name: 'template_id' })
@JoinColumn({ name: 'templateId' })
template: N8nTemplateEntity;
}