From 376ab804db3059de0861820b113be4cadfb1625d Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 13 Sep 2024 15:45:15 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=AA=E0=B8=B4?= =?UTF-8?q?=E0=B8=97=E0=B8=98=E0=B8=B4=E0=B9=8C=20=E0=B8=AA=E0=B8=81?= =?UTF-8?q?=E0=B8=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrgChild1Controller.ts | 44 ++++++++++++++++---------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/controllers/OrgChild1Controller.ts b/src/controllers/OrgChild1Controller.ts index 7c1f0634..14f0663b 100644 --- a/src/controllers/OrgChild1Controller.ts +++ b/src/controllers/OrgChild1Controller.ts @@ -105,14 +105,20 @@ export class OrgChild1Controller { } if (requestBody.isOfficer == true) { - await Promise.all( - rootIdExits.orgChild1s - .filter((x: OrgChild1) => x.isOfficer == true) - .map(async (item: OrgChild1) => { - item.isOfficer = false; - await this.child1Repository.save(item); - }), - ); + const orgRevision = await this.orgRevisionRepository.findOne({ + where: { id: rootIdExits.orgRevisionId }, + relations: ["orgChild1s"], + }); + if (orgRevision != null) { + await Promise.all( + orgRevision.orgChild1s + .filter((x: OrgChild1) => x.isOfficer == true) + .map(async (item: OrgChild1) => { + item.isOfficer = false; + await this.child1Repository.save(item); + }), + ); + } } const revisionIdExits = await this.orgRevisionRepository.findOne({ @@ -214,14 +220,20 @@ export class OrgChild1Controller { } if (requestBody.isOfficer == true) { - await Promise.all( - rootIdExits.orgChild1s - .filter((x: OrgChild1) => x.isOfficer == true) - .map(async (item: OrgChild1) => { - item.isOfficer = false; - await this.child1Repository.save(item); - }), - ); + const orgRevision = await this.orgRevisionRepository.findOne({ + where: { id: rootIdExits.orgRevisionId }, + relations: ["orgChild1s"], + }); + if (orgRevision != null) { + await Promise.all( + orgRevision.orgChild1s + .filter((x: OrgChild1) => x.isOfficer == true) + .map(async (item: OrgChild1) => { + item.isOfficer = false; + await this.child1Repository.save(item); + }), + ); + } } const revisionIdExits = await this.orgRevisionRepository.findOne({