แก้ api สืบทอดตำแหน่ง

This commit is contained in:
Kittapath 2024-02-13 17:14:54 +07:00
parent 179bd7f2d0
commit 634c82eb5c

View file

@ -1801,6 +1801,9 @@ export class PositionController extends Controller {
orgRevisionIsDraft: true, orgRevisionIsDraft: true,
}, },
}); });
if (!findDraft) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้างที่เผยแพร่");
}
const dataPublish = await this.posMasterRepository.findOne({ const dataPublish = await this.posMasterRepository.findOne({
where: { where: {
@ -1826,22 +1829,22 @@ export class PositionController extends Controller {
); );
} }
const dataPosMaster = await this.posMasterRepository.find({ // const dataPosMaster = await this.posMasterRepository.find({
where: { // where: {
orgRevisionId: findDraft?.id, // orgRevisionId: findDraft?.id,
ancestorDNA: dataPublish.ancestorDNA, // ancestorDNA: dataPublish.ancestorDNA,
}, // },
}); // });
if (!dataPosMaster) { // if (!dataPosMaster) {
throw new HttpError( // throw new HttpError(
HttpStatusCode.NOT_FOUND, // HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลไอดีนี้ใน posMaster (publishPositionId) : " + requestBody.publishPositionId, // "ไม่พบข้อมูลไอดีนี้ใน posMaster (publishPositionId) : " + requestBody.publishPositionId,
); // );
} // }
try { try {
await this.posMasterRepository.update( await this.posMasterRepository.update(
{ orgRevisionId: findDraft?.id, ancestorDNA: dataPublish.ancestorDNA }, { orgRevisionId: findDraft.id, ancestorDNA: dataPublish.ancestorDNA },
{ ancestorDNA: "" }, { ancestorDNA: "" },
); );