From 90100e3460351b26be6904a2252df716536c98b2 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 27 Sep 2024 17:14:15 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=97=E0=B8=B3?= =?UTF-8?q?=E0=B8=AA=E0=B8=B3=E0=B9=80=E0=B8=99=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 59 +++------------------------- 1 file changed, 6 insertions(+), 53 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index e4c6382c..8c2604b9 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -625,7 +625,13 @@ export class CommandController extends Controller { } const copy = new Command(); Object.assign(copy, { ...command, ...requestBody, id: undefined }); + const _null: any = null; copy.status = "NEW"; + copy.commandAffectDate = _null; + copy.commandExcecuteDate = _null; + copy.isSignature = _null; + copy.isDraft = _null; + copy.isSign = _null; copy.createdUserId = request.user.sub; copy.createdFullName = request.user.name; copy.createdAt = new Date(); @@ -634,59 +640,6 @@ export class CommandController extends Controller { copy.lastUpdatedAt = new Date(); await this.commandRepository.save(copy); - const commandRecives = await this.commandReciveRepository.find({ - where: { commandId: id }, - }); - const commandSends = await this.commandSendRepository.find({ - where: { commandId: 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(), - lastUpdateUserId: request.user.sub, - lastUpdateFullName: request.user.name, - lastUpdatedAt: new Date(), - }; - }); - await this.commandReciveRepository.save(commandRecives); - - commandSends.map(async (x: any) => { - delete x.id; - let commandSend = { - ...x, - commandSendCCs: [], - commandId: copy.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.commandSendRepository.save(commandSend); - - 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); - }); - return new HttpSuccess(copy.id); }