From 634c82eb5c29595cee6d76207e4f056ca01ca2d2 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 13 Feb 2024 17:14:54 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20api=20=E0=B8=AA?= =?UTF-8?q?=E0=B8=B7=E0=B8=9A=E0=B8=97=E0=B8=AD=E0=B8=94=E0=B8=95=E0=B8=B3?= =?UTF-8?q?=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/PositionController.ts | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index f01e9a02..90773a6a 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -1801,6 +1801,9 @@ export class PositionController extends Controller { orgRevisionIsDraft: true, }, }); + if (!findDraft) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้างที่เผยแพร่"); + } const dataPublish = await this.posMasterRepository.findOne({ where: { @@ -1826,22 +1829,22 @@ export class PositionController extends Controller { ); } - const dataPosMaster = await this.posMasterRepository.find({ - where: { - orgRevisionId: findDraft?.id, - ancestorDNA: dataPublish.ancestorDNA, - }, - }); - if (!dataPosMaster) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลไอดีนี้ใน posMaster (publishPositionId) : " + requestBody.publishPositionId, - ); - } + // const dataPosMaster = await this.posMasterRepository.find({ + // where: { + // orgRevisionId: findDraft?.id, + // ancestorDNA: dataPublish.ancestorDNA, + // }, + // }); + // if (!dataPosMaster) { + // throw new HttpError( + // HttpStatusCode.NOT_FOUND, + // "ไม่พบข้อมูลไอดีนี้ใน posMaster (publishPositionId) : " + requestBody.publishPositionId, + // ); + // } try { await this.posMasterRepository.update( - { orgRevisionId: findDraft?.id, ancestorDNA: dataPublish.ancestorDNA }, + { orgRevisionId: findDraft.id, ancestorDNA: dataPublish.ancestorDNA }, { ancestorDNA: "" }, );