fix: 修复数据格式错误
This commit is contained in:
parent
fd7d619a51
commit
4311527356
|
|
@ -9,7 +9,7 @@ export class AppController {
|
|||
constructor(
|
||||
@InjectRepository(TemplateExecutionEntity)
|
||||
private readonly executionRepository: Repository<TemplateExecutionEntity>,
|
||||
) {}
|
||||
) { }
|
||||
@Post('callback')
|
||||
async callback(@Body() body: any): Promise<ApiResponse<string | null>> {
|
||||
console.log(`🚀 [回调] 开始执行回调`);
|
||||
|
|
@ -19,8 +19,8 @@ export class AppController {
|
|||
const res = body.data;
|
||||
// {status: true, data: string[], task_id: string}
|
||||
let resultUrl = ``
|
||||
if (res.status) {
|
||||
const data = res.data;
|
||||
if (body.status) {
|
||||
const data = body.data;
|
||||
if (!data) throw new Error(`结果有误`);
|
||||
if (Array.isArray(data) && data.length > 0) {
|
||||
resultUrl = data[0];
|
||||
|
|
@ -40,8 +40,8 @@ export class AppController {
|
|||
// 更新执行状态
|
||||
const updateData: Partial<TemplateExecutionEntity> = {
|
||||
completedAt: new Date(),
|
||||
executionDuration: execution.startedAt
|
||||
? Date.now() - execution.startedAt.getTime()
|
||||
executionDuration: execution.startedAt
|
||||
? Date.now() - execution.startedAt.getTime()
|
||||
: undefined,
|
||||
};
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ export class AppController {
|
|||
}
|
||||
|
||||
await this.executionRepository.update(execution.id, updateData);
|
||||
|
||||
|
||||
return ResponseUtil.success(resultUrl, '回调处理成功');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue