From eac620fb1512a3283fb27bae58b7eae456ae8aee Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 8 Jan 2025 16:46:22 +0700 Subject: [PATCH] no message --- src/controllers/ProfileController.ts | 75 +++++++++++++++------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 792a924b..d8fde6d6 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -1307,25 +1307,26 @@ export class ProfileController extends Controller { if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง"); let condition: any = { - orgRootId: posMaster.orgRootId || "", + orgRootId: posMaster.orgRootId, id: Not(posMaster.current_holderId || ""), }; let conditionNow: any = { - orgRootId: posMaster.orgRootId || "", - orgChild1Id: posMaster.orgChild1Id || "", - orgChild2Id: posMaster.orgChild2Id || "", - orgChild3Id: posMaster.orgChild3Id || "", - orgChild4Id: posMaster.orgChild4Id || "", - id: Not(posMaster.current_holderId || ""), + orgRootId: posMaster.orgRootId, + orgChild1Id: posMaster.orgChild1Id, + orgChild2Id: posMaster.orgChild2Id, + orgChild3Id: posMaster.orgChild3Id, + orgChild4Id: posMaster.orgChild4Id, + id: Not(posMaster.current_holderId), }; - if (posMaster.orgChild2Id == null) { - condition.orgChild1Id = ""; + if (posMaster.orgChild1Id == null) { + } else if (posMaster.orgChild2Id == null) { + condition.orgChild1Id = null; } else if (posMaster.orgChild3Id == null) { - condition.orgChild2Id = ""; + condition.orgChild2Id = null; } else if (posMaster.orgChild4Id == null) { - condition.orgChild3Id = ""; + condition.orgChild3Id = null; } else { - condition.orgChild4Id = ""; + condition.orgChild4Id = null; } if (body.isDirector == true) { condition.isDirector = true; @@ -1422,25 +1423,26 @@ export class ProfileController extends Controller { if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง"); let condition: any = { - orgRootId: posMaster.orgRootId || "", + orgRootId: posMaster.orgRootId, id: Not(posMaster.current_holderId || ""), }; let conditionNow: any = { - orgRootId: posMaster.orgRootId || "", - orgChild1Id: posMaster.orgChild1Id || "", - orgChild2Id: posMaster.orgChild2Id || "", - orgChild3Id: posMaster.orgChild3Id || "", - orgChild4Id: posMaster.orgChild4Id || "", - id: Not(posMaster.current_holderId || ""), + orgRootId: posMaster.orgRootId, + orgChild1Id: posMaster.orgChild1Id, + orgChild2Id: posMaster.orgChild2Id, + orgChild3Id: posMaster.orgChild3Id, + orgChild4Id: posMaster.orgChild4Id, + id: Not(posMaster.current_holderId), }; - if (posMaster.orgChild2Id == null) { - condition.orgChild1Id = ""; + if (posMaster.orgChild1Id == null) { + } else if (posMaster.orgChild2Id == null) { + condition.orgChild1Id = null; } else if (posMaster.orgChild3Id == null) { - condition.orgChild2Id = ""; + condition.orgChild2Id = null; } else if (posMaster.orgChild4Id == null) { - condition.orgChild3Id = ""; + condition.orgChild3Id = null; } else { - condition.orgChild4Id = ""; + condition.orgChild4Id = null; } if (body.isDirector == true) { condition.isDirector = true; @@ -1512,25 +1514,26 @@ export class ProfileController extends Controller { if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง"); let condition: any = { - orgRootId: posMaster.orgRootId || "", + orgRootId: posMaster.orgRootId, id: Not(posMaster.current_holderId || ""), }; let conditionNow: any = { - orgRootId: posMaster.orgRootId || "", - orgChild1Id: posMaster.orgChild1Id || "", - orgChild2Id: posMaster.orgChild2Id || "", - orgChild3Id: posMaster.orgChild3Id || "", - orgChild4Id: posMaster.orgChild4Id || "", - id: Not(posMaster.current_holderId || ""), + orgRootId: posMaster.orgRootId, + orgChild1Id: posMaster.orgChild1Id, + orgChild2Id: posMaster.orgChild2Id, + orgChild3Id: posMaster.orgChild3Id, + orgChild4Id: posMaster.orgChild4Id, + id: Not(posMaster.current_holderId), }; - if (posMaster.orgChild2Id == null) { - condition.orgChild1Id = ""; + if (posMaster.orgChild1Id == null) { + } else if (posMaster.orgChild2Id == null) { + condition.orgChild1Id = null; } else if (posMaster.orgChild3Id == null) { - condition.orgChild2Id = ""; + condition.orgChild2Id = null; } else if (posMaster.orgChild4Id == null) { - condition.orgChild3Id = ""; + condition.orgChild3Id = null; } else { - condition.orgChild4Id = ""; + condition.orgChild4Id = null; } if (body.isDirector == true) { condition.isDirector = true;