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