แก้ลบคำสั่ง
This commit is contained in:
parent
eabd1c4ac7
commit
de0e2a9643
1 changed files with 24 additions and 20 deletions
|
|
@ -598,6 +598,7 @@ export class CommandController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับสำเนาคำสั่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับสำเนาคำสั่ง");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.commandSendCCRepository.delete({ commandSendId: commandSendId });
|
||||||
await this.commandSendRepository.delete(commandSendId);
|
await this.commandSendRepository.delete(commandSendId);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -638,14 +639,13 @@ export class CommandController extends Controller {
|
||||||
});
|
});
|
||||||
const commandSends = await this.commandSendRepository.find({
|
const commandSends = await this.commandSendRepository.find({
|
||||||
where: { commandId: id },
|
where: { commandId: id },
|
||||||
});
|
relations: ["commandSendCCs"],
|
||||||
const commandSendCCs = await this.commandSendCCRepository.find({
|
|
||||||
where: { commandSendId: In(commandSends.map((x) => x.id)) },
|
|
||||||
});
|
});
|
||||||
commandRecives.map((x: any) => {
|
commandRecives.map((x: any) => {
|
||||||
delete x.id;
|
delete x.id;
|
||||||
return {
|
return {
|
||||||
...x,
|
...x,
|
||||||
|
commandId: copy.id,
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
|
|
@ -654,12 +654,14 @@ export class CommandController extends Controller {
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
await this.commandRepository.save(commandRecives);
|
await this.commandReciveRepository.save(commandRecives);
|
||||||
|
|
||||||
commandSends.map((x: any) => {
|
commandSends.map(async (x: any) => {
|
||||||
delete x.id;
|
delete x.id;
|
||||||
return {
|
let commandSend = {
|
||||||
...x,
|
...x,
|
||||||
|
commandSendCCs: [],
|
||||||
|
commandId: copy.id,
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
|
|
@ -667,22 +669,24 @@ export class CommandController extends Controller {
|
||||||
lastUpdateFullName: request.user.name,
|
lastUpdateFullName: request.user.name,
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
});
|
await this.commandSendRepository.save(commandSend);
|
||||||
await this.commandRepository.save(commandSends);
|
|
||||||
|
|
||||||
commandSendCCs.map((x: any) => {
|
let commandSendCC = await x.commandSendCCs.map((y: any) => {
|
||||||
delete x.id;
|
delete y.id;
|
||||||
return {
|
return {
|
||||||
...x,
|
...y,
|
||||||
createdUserId: request.user.sub,
|
commandSendId: commandSend.id,
|
||||||
createdFullName: request.user.name,
|
createdUserId: request.user.sub,
|
||||||
createdAt: new Date(),
|
createdFullName: request.user.name,
|
||||||
lastUpdateUserId: request.user.sub,
|
createdAt: new Date(),
|
||||||
lastUpdateFullName: request.user.name,
|
lastUpdateUserId: request.user.sub,
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdateFullName: request.user.name,
|
||||||
};
|
lastUpdatedAt: new Date(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
await this.commandSendCCRepository.save(commandSendCC);
|
||||||
});
|
});
|
||||||
await this.commandRepository.save(commandSendCCs);
|
|
||||||
return new HttpSuccess(copy.id);
|
return new HttpSuccess(copy.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue