diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 3d424cc4..45f05e92 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -619,6 +619,10 @@ export class PositionController extends Controller { posMaster.lastUpdateFullName = request.user.name; await this.posMasterRepository.save(posMaster); + const positions = await this.positionRepository.find({ + where: [{ posMasterId: posMaster.id }], + }); + await this.positionRepository.remove(positions); await this.positionRepository.delete({ posMasterId: posMaster.id }); requestBody.positions.forEach(async (x: any) => { const position = Object.assign(new Position()); @@ -651,13 +655,13 @@ export class PositionController extends Controller { try { const posMaster = await this.posMasterRepository.findOne({ where: { id }, - // relations: ["posType", "posLevel", "posExecutive"], }); if (!posMaster) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } const positions = await this.positionRepository.find({ where: { posMasterId: posMaster.id }, + relations: ["posType", "posLevel", "posExecutive"], }); const formattedData = { id: posMaster.id,