แก้ลบคำสั่ง
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, "ไม่พบข้อมูลผู้ได้รับสำเนาคำสั่ง");
|
||||
}
|
||||
|
||||
await this.commandSendCCRepository.delete({ commandSendId: commandSendId });
|
||||
await this.commandSendRepository.delete(commandSendId);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -638,14 +639,13 @@ export class CommandController extends Controller {
|
|||
});
|
||||
const commandSends = await this.commandSendRepository.find({
|
||||
where: { commandId: id },
|
||||
});
|
||||
const commandSendCCs = await this.commandSendCCRepository.find({
|
||||
where: { commandSendId: In(commandSends.map((x) => x.id)) },
|
||||
relations: ["commandSendCCs"],
|
||||
});
|
||||
commandRecives.map((x: any) => {
|
||||
delete x.id;
|
||||
return {
|
||||
...x,
|
||||
commandId: copy.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
createdAt: new Date(),
|
||||
|
|
@ -654,12 +654,14 @@ export class CommandController extends Controller {
|
|||
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;
|
||||
return {
|
||||
let commandSend = {
|
||||
...x,
|
||||
commandSendCCs: [],
|
||||
commandId: copy.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
createdAt: new Date(),
|
||||
|
|
@ -667,22 +669,24 @@ export class CommandController extends Controller {
|
|||
lastUpdateFullName: request.user.name,
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
});
|
||||
await this.commandRepository.save(commandSends);
|
||||
await this.commandSendRepository.save(commandSend);
|
||||
|
||||
commandSendCCs.map((x: any) => {
|
||||
delete x.id;
|
||||
return {
|
||||
...x,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
let commandSendCC = await x.commandSendCCs.map((y: any) => {
|
||||
delete y.id;
|
||||
return {
|
||||
...y,
|
||||
commandSendId: commandSend.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
});
|
||||
await this.commandSendCCRepository.save(commandSendCC);
|
||||
});
|
||||
await this.commandRepository.save(commandSendCCs);
|
||||
|
||||
return new HttpSuccess(copy.id);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue