diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 66f401af..12da3cec 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -2920,20 +2920,20 @@ export class OrganizationDotnetController extends Controller { ?.orgRoot != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; - const Oc = + const Oc = item.current_holders.length == 0 - ? null - : body.node == 4 && item.current_holders[0].orgChild4 != null - ? `${item.current_holders[0].orgChild4.orgChild4Name}/${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` - : body.node == 3 && item.current_holders[0].orgChild3 != null - ? `${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` - : body.node == 2 && item.current_holders[0].orgChild2 != null - ? `${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` - : body.node == 1 && item.current_holders[0].orgChild1 != null - ? `${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` - : body.node == 0 && item.current_holders[0].orgRoot != null - ? `${item.current_holders[0].orgRoot.orgRootName}` - : null; + ? null + : body.node == 4 && item.current_holders[0].orgChild4 != null + ? `${item.current_holders[0].orgChild4.orgChild4Name}/${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` + : body.node == 3 && item.current_holders[0].orgChild3 != null + ? `${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` + : body.node == 2 && item.current_holders[0].orgChild2 != null + ? `${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` + : body.node == 1 && item.current_holders[0].orgChild1 != null + ? `${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` + : body.node == 0 && item.current_holders[0].orgRoot != null + ? `${item.current_holders[0].orgRoot.orgRootName}` + : null; return { id: item.id, prefix: item.prefix, @@ -2944,7 +2944,7 @@ export class OrganizationDotnetController extends Controller { position: item.position, positionLevel: item.posLevel?.posLevelName ?? null, positionType: item.posType?.posTypeName ?? null, - oc: Oc + oc: Oc, }; }), ); @@ -3063,20 +3063,20 @@ export class OrganizationDotnetController extends Controller { ?.orgRoot != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; - const Oc = + const Oc = item.current_holders.length == 0 - ? null - : body.node == 4 && item.current_holders[0].orgChild4 != null - ? `${item.current_holders[0].orgChild4.orgChild4Name}/${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` - : body.node == 3 && item.current_holders[0].orgChild3 != null - ? `${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` - : body.node == 2 && item.current_holders[0].orgChild2 != null - ? `${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` - : body.node == 1 && item.current_holders[0].orgChild1 != null - ? `${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` - : body.node == 0 && item.current_holders[0].orgRoot != null - ? `${item.current_holders[0].orgRoot.orgRootName}` - : null; + ? null + : body.node == 4 && item.current_holders[0].orgChild4 != null + ? `${item.current_holders[0].orgChild4.orgChild4Name}/${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` + : body.node == 3 && item.current_holders[0].orgChild3 != null + ? `${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` + : body.node == 2 && item.current_holders[0].orgChild2 != null + ? `${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` + : body.node == 1 && item.current_holders[0].orgChild1 != null + ? `${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` + : body.node == 0 && item.current_holders[0].orgRoot != null + ? `${item.current_holders[0].orgRoot.orgRootName}` + : null; return { id: item.id, prefix: item.prefix, @@ -3088,7 +3088,7 @@ export class OrganizationDotnetController extends Controller { position: item.position, positionLevel: item.posLevel?.posLevelName ?? null, positionType: item.posType?.posTypeName ?? null, - oc: Oc + oc: Oc, }; }), ); @@ -3191,4 +3191,25 @@ export class OrganizationDotnetController extends Controller { return new HttpSuccess(); } + + /** + * 2. API ข้อมูลหน่วยงานตามโครงสร้าง + * + * @summary 2. API ข้อมูลหน่วยงานตามโครงสร้าง + * + * @param {string} id Id หน่วยงาน + */ + @Get("email/{id}") + async GetEmailById(@Path() id: string) { + const profile = await this.profileRepo.findOne({ + where: { id: id }, + }); + if (profile != null) return new HttpSuccess(profile.email); + const profileEmp = await this.profileEmpRepo.findOne({ + where: { id: id }, + }); + if (profileEmp != null) return new HttpSuccess(profileEmp.email); + + return new HttpSuccess(null); + } }