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