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: "" }, );