diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 04d29f06..5a84f3bc 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -1,45 +1,44 @@ import { + Body, Controller, + Get, + Path, Post, Put, + Request, + Response, Route, Security, - Tags, - Body, - Path, - Request, SuccessResponse, - Response, - Get, + Tags, } from "tsoa"; -import { AppDataSource } from "../database/data-source"; -import HttpSuccess from "../interfaces/http-success"; -import HttpStatus from "../interfaces/http-status"; -import HttpError from "../interfaces/http-error"; -import { RequestWithUser } from "../middlewares/user"; -import { Profile } from "../entities/Profile"; import { And, Between, Brackets, In, IsNull, LessThanOrEqual, Not } from "typeorm"; -import { OrgRevision } from "../entities/OrgRevision"; -import { OrgRoot } from "../entities/OrgRoot"; +import { AppDataSource } from "../database/data-source"; +import { Assign } from "../entities/Assign"; +import { EmployeePosDict } from "../entities/EmployeePosDict"; +import { EmployeePosMaster } from "../entities/EmployeePosMaster"; import { OrgChild1 } from "../entities/OrgChild1"; import { OrgChild2 } from "../entities/OrgChild2"; import { OrgChild3 } from "../entities/OrgChild3"; import { OrgChild4 } from "../entities/OrgChild4"; -import { ProfileEmployee } from "../entities/ProfileEmployee"; +import { OrgRevision } from "../entities/OrgRevision"; +import { OrgRoot } from "../entities/OrgRoot"; import { Position } from "../entities/Position"; -import { Insignia } from "../entities/Insignia"; -import { CreateProfileInsignia, ProfileInsignia } from "../entities/ProfileInsignia"; import { PosMaster } from "../entities/PosMaster"; -import { EmployeePosMaster } from "../entities/EmployeePosMaster"; -import { EmployeePosDict } from "../entities/EmployeePosDict"; -import { calculateRetireLaw } from "../interfaces/utils"; -import Extension from "../interfaces/extension"; -import { PosMasterHistory } from "../entities/PosMasterHistory"; -import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory"; import { PosMasterAssign } from "../entities/PosMasterAssign"; -import { Assign } from "../entities/Assign"; -import { ProfileSalary } from "../entities/ProfileSalary"; +import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory"; +import { PosMasterHistory } from "../entities/PosMasterHistory"; +import { Profile } from "../entities/Profile"; import { ProfileEducation } from "../entities/ProfileEducation"; +import { ProfileEmployee } from "../entities/ProfileEmployee"; +import { CreateProfileInsignia, ProfileInsignia } from "../entities/ProfileInsignia"; +import { ProfileSalary } from "../entities/ProfileSalary"; +import Extension from "../interfaces/extension"; +import HttpError from "../interfaces/http-error"; +import HttpStatus from "../interfaces/http-status"; +import HttpSuccess from "../interfaces/http-success"; +import { calculateRetireLaw } from "../interfaces/utils"; +import { RequestWithUser } from "../middlewares/user"; @Route("api/v1/org/dotnet") @Tags("Dotnet") @Security("bearerAuth") @@ -60,12 +59,9 @@ export class OrganizationDotnetController extends Controller { private positionRepository = AppDataSource.getRepository(Position); private posMasterRepository = AppDataSource.getRepository(PosMaster); private posMasterHistoryRepository = AppDataSource.getRepository(PosMasterHistory); - private posMasterEmployeeHistoryRepository = - AppDataSource.getRepository(PosMasterEmployeeHistory); private empPosMasterRepository = AppDataSource.getRepository(EmployeePosMaster); private insigniaRepo = AppDataSource.getRepository(ProfileInsignia); private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict); - private posMasterAssignRepo = AppDataSource.getRepository(PosMasterAssign); private assignRepository = AppDataSource.getRepository(Assign); private salaryRepo = AppDataSource.getRepository(ProfileSalary); private educationRepo = AppDataSource.getRepository(ProfileEducation); @@ -105,10 +101,40 @@ export class OrganizationDotnetController extends Controller { node?: number | null; page: number; pageSize: number; + selectedNodeId?: string | null; + selectedNode?: number | null; }, ) { let condition = "1=1"; let conditionParams = {}; + + let selectedNodeCondition = "1=1"; + let selectedNodeConditionParams = {}; + + if (body.selectedNodeId && body.selectedNode != null) { + switch (body.selectedNode) { + case 0: + selectedNodeCondition = "orgRoot.ancestorDNA = :selectedNodeId"; + break; + case 1: + selectedNodeCondition = "orgChild1.ancestorDNA = :selectedNodeId"; + break; + case 2: + selectedNodeCondition = "orgChild2.ancestorDNA = :selectedNodeId"; + break; + case 3: + selectedNodeCondition = "orgChild3.ancestorDNA = :selectedNodeId"; + break; + case 4: + selectedNodeCondition = "orgChild4.ancestorDNA = :selectedNodeId"; + break; + default: + selectedNodeCondition = "1=1"; + break; + } + selectedNodeConditionParams = { selectedNodeId: body.selectedNodeId }; + } + if (body.role === "CHILD") { switch (body.node) { case 0: @@ -214,6 +240,7 @@ export class OrganizationDotnetController extends Controller { }), ) .andWhere(condition, conditionParams) + .andWhere(selectedNodeCondition, selectedNodeConditionParams) .select([ "profile.id", "profile.citizenId", @@ -405,26 +432,24 @@ export class OrganizationDotnetController extends Controller { } /** - * API Get ProfileId - * - * @summary Get ProfileId - * - */ + * API Get ProfileId + * + * @summary Get ProfileId + * + */ @Get("get-profileId") - async getProfileInbox( - @Request() request: { user: Record }, - ) { - let profile: any + async getProfileInbox(@Request() request: { user: Record }) { + let profile: any; //OFF profile = await this.profileRepo.findOne({ where: { keycloak: request.user.sub }, - select: { id: true } + select: { id: true }, }); //EMP if (!profile) { profile = await this.profileEmpRepo.findOne({ where: { keycloak: request.user.sub }, - select: { id: true } + select: { id: true }, }); if (!profile) { if (request.user.role.includes("SUPER_ADMIN")) { @@ -435,8 +460,8 @@ export class OrganizationDotnetController extends Controller { } } const result = { - profileId: profile ? profile.id : null - } + profileId: profile ? profile.id : null, + }; return new HttpSuccess(result); } @@ -1045,10 +1070,10 @@ export class OrganizationDotnetController extends Controller { let positionLeaveName = profile.posType != null && - profile.posLevel != null && - (profile.posType.posTypeName == "บริหาร" || profile.posType.posTypeName == "อำนวยการ") + profile.posLevel != null && + (profile.posType.posTypeName == "บริหาร" || profile.posType.posTypeName == "อำนวยการ") ? `${profile.posType?.posTypeName ?? ""}${profile.posLevel?.posLevelName ?? ""}` - : profile.posLevel?.posLevelName ?? null; + : (profile.posLevel?.posLevelName ?? null); const _profileCurrent = profile?.current_holders?.find( (x) => x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, @@ -1236,9 +1261,10 @@ export class OrganizationDotnetController extends Controller { profileInsignia: profile.profileInsignias.length > 0 ? profile.profileInsignias[0] : null, profileType: "OFFICER", positionLeaveName: positionLeaveName, - posExecutiveName: position == null || position.posExecutive == null - ? null - : position.posExecutive.posExecutiveName, + posExecutiveName: + position == null || position.posExecutive == null + ? null + : position.posExecutive.posExecutiveName, oc: oc, }; @@ -1248,8 +1274,8 @@ export class OrganizationDotnetController extends Controller { @Get("keycloak/{keycloakId}") async GetProfileByKeycloakIdAsync(@Path() keycloakId: string) { /* ========================= - * 1. Load profile - * ========================= */ + * 1. Load profile + * ========================= */ const profile = await this.profileRepo.findOne({ where: { keycloak: keycloakId }, relations: { @@ -1297,7 +1323,7 @@ export class OrganizationDotnetController extends Controller { }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); const currentHolder = profile.current_holders?.find( - x => + (x) => x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); @@ -1346,8 +1372,7 @@ export class OrganizationDotnetController extends Controller { .getOne(); if (pos?.current_holder) { - commanderFullname = - `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`; + commanderFullname = `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`; commanderPositionName = pos.current_holder.position; commanderId = pos.current_holder.id; commanderKeycloak = pos.current_holder.keycloak; @@ -1381,11 +1406,10 @@ export class OrganizationDotnetController extends Controller { const positionLeaveName = profile.posType && - profile.posLevel && - (profile.posType.posTypeName === "บริหาร" || - profile.posType.posTypeName === "อำนวยการ") + profile.posLevel && + (profile.posType.posTypeName === "บริหาร" || profile.posType.posTypeName === "อำนวยการ") ? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}` - : profile.posLevel?.posLevelName ?? null; + : (profile.posLevel?.posLevelName ?? null); const mapProfile = { id: profile.id, @@ -1471,12 +1495,11 @@ export class OrganizationDotnetController extends Controller { } /* ========================================= - * 2. current holder - * ========================================= */ + * 2. current holder + * ========================================= */ const currentHolder = profile.current_holders?.find( - x => - x.orgRevision?.orgRevisionIsDraft === false && - x.orgRevision?.orgRevisionIsCurrent === true, + (x) => + x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); const org = { @@ -1488,8 +1511,8 @@ export class OrganizationDotnetController extends Controller { }; /* ================================================= - * 3. หา commander - * ================================================= */ + * 3. หา commander + * ================================================= */ let commanderFullname = ""; let commanderPositionName = ""; let commanderId = ""; @@ -1526,16 +1549,15 @@ export class OrganizationDotnetController extends Controller { .getOne(); if (pos?.current_holder) { - commanderFullname = - `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`; + commanderFullname = `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`; commanderPositionName = pos.current_holder.position; commanderId = pos.current_holder.id; commanderKeycloak = pos.current_holder.keycloak; } /* ========================================= - * 4. salary / insignia (เอาแค่ล่าสุด) - * ========================================= */ + * 4. salary / insignia (เอาแค่ล่าสุด) + * ========================================= */ const [latestSalary, latestInsignia] = await Promise.all([ this.salaryRepo.findOne({ where: { profileId: profile.id }, @@ -1548,8 +1570,8 @@ export class OrganizationDotnetController extends Controller { ]); /* ========================================= - * 5. position executive - * ========================================= */ + * 5. position executive + * ========================================= */ const position = await this.positionRepository.findOne({ where: { positionIsSelected: true, @@ -1563,8 +1585,8 @@ export class OrganizationDotnetController extends Controller { }); /* ========================================= - * 6. OC name - * ========================================= */ + * 6. OC name + * ========================================= */ let oc = ""; if (currentHolder) { if (!currentHolder.orgChild1Id) { @@ -1581,19 +1603,18 @@ export class OrganizationDotnetController extends Controller { } /* ========================================= - * 7. position level name - * ========================================= */ + * 7. position level name + * ========================================= */ const positionLeaveName = profile.posType && - profile.posLevel && - (profile.posType.posTypeName === "บริหาร" || - profile.posType.posTypeName === "อำนวยการ") + profile.posLevel && + (profile.posType.posTypeName === "บริหาร" || profile.posType.posTypeName === "อำนวยการ") ? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}` - : profile.posLevel?.posLevelName ?? null; + : (profile.posLevel?.posLevelName ?? null); /* ========================================= - * 8. map response - * ========================================= */ + * 8. map response + * ========================================= */ const mapProfile = { id: profile.id, avatar: profile.avatar, @@ -1681,8 +1702,8 @@ export class OrganizationDotnetController extends Controller { @Get("by-keycloak/{keycloakId}") async NewGetProfileByKeycloakIdAsync(@Path() keycloakId: string) { /* ========================= - * 1. Load profile - * ========================= */ + * 1. Load profile + * ========================= */ const profile = await this.profileRepo.findOne({ where: { keycloak: keycloakId }, relations: { @@ -1718,7 +1739,7 @@ export class OrganizationDotnetController extends Controller { }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); const currentHolder = profile.current_holders?.find( - x => + (x) => x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); @@ -1772,9 +1793,10 @@ export class OrganizationDotnetController extends Controller { mouthSalaryAmount: profile.mouthSalaryAmount, posType: profile.posType?.posTypeName ?? null, - posLevel: profile.posType?.posTypeShortName == null && profile.posLevel?.posLevelName == null - ? null - : `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`, + posLevel: + profile.posType?.posTypeShortName == null && profile.posLevel?.posLevelName == null + ? null + : `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`, oc, root: currentHolder?.orgRoot?.orgRootName ?? null, @@ -1798,17 +1820,16 @@ export class OrganizationDotnetController extends Controller { } /* ========================================= - * 2. current holder - * ========================================= */ + * 2. current holder + * ========================================= */ const currentHolder = profile.current_holders?.find( - x => - x.orgRevision?.orgRevisionIsDraft === false && - x.orgRevision?.orgRevisionIsCurrent === true, + (x) => + x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); /* ========================================= - * 5. position executive - * ========================================= */ + * 5. position executive + * ========================================= */ const position = await this.positionRepository.findOne({ where: { positionIsSelected: true, @@ -1822,8 +1843,8 @@ export class OrganizationDotnetController extends Controller { }); /* ========================================= - * 6. OC name - * ========================================= */ + * 6. OC name + * ========================================= */ let oc = ""; if (currentHolder) { if (!currentHolder.orgChild1Id) { @@ -1840,19 +1861,18 @@ export class OrganizationDotnetController extends Controller { } /* ========================================= - * 7. position level name - * ========================================= */ + * 7. position level name + * ========================================= */ const positionLeaveName = profile.posType && - profile.posLevel && - (profile.posType.posTypeName === "บริหาร" || - profile.posType.posTypeName === "อำนวยการ") + profile.posLevel && + (profile.posType.posTypeName === "บริหาร" || profile.posType.posTypeName === "อำนวยการ") ? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}` - : profile.posLevel?.posLevelName ?? null; + : (profile.posLevel?.posLevelName ?? null); /* ========================================= - * 8. map response - * ========================================= */ + * 8. map response + * ========================================= */ const mapProfile = { profileType: "OFFICER", id: profile.id, @@ -1916,8 +1936,8 @@ export class OrganizationDotnetController extends Controller { @Get("by-keycloak2/{keycloakId}") async NewGetProfileByKeycloak2IdAsync(@Path() keycloakId: string) { /* ========================= - * 1. Load profile - * ========================= */ + * 1. Load profile + * ========================= */ const profile = await this.profileRepo.findOne({ where: { keycloak: keycloakId }, relations: { @@ -1961,7 +1981,7 @@ export class OrganizationDotnetController extends Controller { }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); const currentHolder = profile.current_holders?.find( - x => + (x) => x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); @@ -1997,8 +2017,7 @@ export class OrganizationDotnetController extends Controller { .getOne(); if (pos?.current_holder) { - commanderFullname = - `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`; + commanderFullname = `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`; commanderPositionName = pos.current_holder.position; commanderId = pos.current_holder.id; } @@ -2052,9 +2071,10 @@ export class OrganizationDotnetController extends Controller { mouthSalaryAmount: profile.mouthSalaryAmount, posType: profile.posType?.posTypeName ?? null, - posLevel: profile.posType?.posTypeShortName == null && profile.posLevel?.posLevelName == null - ? null - : `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`, + posLevel: + profile.posType?.posTypeShortName == null && profile.posLevel?.posLevelName == null + ? null + : `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`, oc, currentAddress: profile.currentAddress, @@ -2088,17 +2108,16 @@ export class OrganizationDotnetController extends Controller { } /* ========================================= - * 2. current holder - * ========================================= */ + * 2. current holder + * ========================================= */ const currentHolder = profile.current_holders?.find( - x => - x.orgRevision?.orgRevisionIsDraft === false && - x.orgRevision?.orgRevisionIsCurrent === true, + (x) => + x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); /* ================================================= - * 3. หา commander - * ================================================= */ + * 3. หา commander + * ================================================= */ const pos = await this.posMasterRepository .createQueryBuilder("pos") .leftJoinAndSelect("pos.current_holder", "holder") @@ -2129,16 +2148,15 @@ export class OrganizationDotnetController extends Controller { ) .getOne(); - if (pos?.current_holder) { - commanderFullname = - `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`; + if (pos?.current_holder) { + commanderFullname = `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`; commanderPositionName = pos.current_holder.position; commanderId = pos.current_holder.id; } /* ========================================= - * 5. position executive - * ========================================= */ + * 5. position executive + * ========================================= */ const position = await this.positionRepository.findOne({ where: { positionIsSelected: true, @@ -2152,8 +2170,8 @@ export class OrganizationDotnetController extends Controller { }); /* ========================================= - * 6. OC name - * ========================================= */ + * 6. OC name + * ========================================= */ let oc = ""; if (currentHolder) { if (!currentHolder.orgChild1Id) { @@ -2170,19 +2188,18 @@ export class OrganizationDotnetController extends Controller { } /* ========================================= - * 7. position level name - * ========================================= */ + * 7. position level name + * ========================================= */ const positionLeaveName = profile.posType && - profile.posLevel && - (profile.posType.posTypeName === "บริหาร" || - profile.posType.posTypeName === "อำนวยการ") + profile.posLevel && + (profile.posType.posTypeName === "บริหาร" || profile.posType.posTypeName === "อำนวยการ") ? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}` - : profile.posLevel?.posLevelName ?? null; + : (profile.posLevel?.posLevelName ?? null); /* ========================================= - * 8. map response - * ========================================= */ + * 8. map response + * ========================================= */ const mapProfile = { profileType: "OFFICER", id: profile.id, @@ -2221,7 +2238,7 @@ export class OrganizationDotnetController extends Controller { posExecutiveName: position?.posExecutive?.posExecutiveName ?? null, positionLeaveName, oc, - + currentAddress: profile.currentAddress, currentSubDistrict: profile.currentSubDistrict?.name ?? null, currentDistrict: profile.currentDistrict?.name ?? null, @@ -2253,17 +2270,17 @@ export class OrganizationDotnetController extends Controller { } /** - * API Get Profile For Logs - * - * @summary API Get Profile For Logs - * - * @param {string} keycloakId keycloakId profile - */ + * API Get Profile For Logs + * + * @summary API Get Profile For Logs + * + * @param {string} keycloakId keycloakId profile + */ @Get("user-logs/{keycloakId}") async UserLogs(@Path() keycloakId: string) { /* ========================= - * 1. Load profile - * ========================= */ + * 1. Load profile + * ========================= */ const profile = await this.profileRepo.findOne({ where: { keycloak: keycloakId }, relations: { @@ -2287,7 +2304,7 @@ export class OrganizationDotnetController extends Controller { }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); const currentHolder = profile.current_holders?.find( - x => + (x) => x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); @@ -2307,17 +2324,16 @@ export class OrganizationDotnetController extends Controller { } /* ========================================= - * 2. current holder - * ========================================= */ + * 2. current holder + * ========================================= */ const currentHolder = profile.current_holders?.find( - x => - x.orgRevision?.orgRevisionIsDraft === false && - x.orgRevision?.orgRevisionIsCurrent === true, + (x) => + x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); /* ========================================= - * 8. map response - * ========================================= */ + * 8. map response + * ========================================= */ const mapProfile = { profileId: profile.id, keycloak: profile.keycloak, @@ -3749,26 +3765,26 @@ export class OrganizationDotnetController extends Controller { profile.current_holders.length == 0 ? null : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + null && + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgRoot != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; @@ -4059,26 +4075,26 @@ export class OrganizationDotnetController extends Controller { profile.current_holders.length == 0 ? null : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + null && + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgRoot != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; return { @@ -4180,7 +4196,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("find/employee/position") async GetProfileByPositionEmpAsync( - @Request() req: RequestWithUser, @Body() body: { empPosId: string[]; @@ -4280,26 +4295,26 @@ export class OrganizationDotnetController extends Controller { profile.current_holders.length == 0 ? null : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + null && + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgRoot != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; return { @@ -4547,7 +4562,7 @@ export class OrganizationDotnetController extends Controller { const root = profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot; @@ -4601,8 +4616,8 @@ export class OrganizationDotnetController extends Controller { orgChild2: true, orgChild3: true, orgChild4: true, - } - } + }, + }, }); if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); @@ -4619,41 +4634,41 @@ export class OrganizationDotnetController extends Controller { const posMaster = profile.current_holders == null || - profile.current_holders.length == 0 || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) == null + profile.current_holders.length == 0 || + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id); const root = profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot; const child1 = profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1; const child2 = profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2; const child3 = profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3; const child4 = profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4; @@ -4879,9 +4894,7 @@ export class OrganizationDotnetController extends Controller { // }), // ); const profile_ = profile.map((item: Profile) => { - const holder = item.current_holders?.find( - (x) => x.orgRevisionId === findRevision?.id, - ); + const holder = item.current_holders?.find((x) => x.orgRevisionId === findRevision?.id); const rootName = holder?.orgRoot?.orgRootName ?? null; @@ -5003,30 +5016,30 @@ export class OrganizationDotnetController extends Controller { item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot - ?.orgRootName; + ?.orgRootName; const shortName = item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgRoot != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; @@ -5101,7 +5114,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("keycloak-all-officer") async PostProfileWithKeycloakAllOfficer( - @Request() req: RequestWithUser, @Body() body: { node: number; @@ -5210,25 +5222,25 @@ export class OrganizationDotnetController extends Controller { item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.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 = @@ -5272,7 +5284,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("keycloak-all-officer/date") async PostProfileWithKeycloakAllOfficerDate( - @Request() req: RequestWithUser, @Body() body: { node: number; @@ -5389,25 +5400,25 @@ export class OrganizationDotnetController extends Controller { item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.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 = @@ -5451,7 +5462,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("none-validate-keycloak-all-officer") async PostProfileWithNoneValidateKeycloakAllOfficer( - @Request() req: RequestWithUser, @Body() body: { node: number; @@ -5559,25 +5569,25 @@ export class OrganizationDotnetController extends Controller { item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.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 = @@ -5621,7 +5631,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("find-node-name") async findNodeName( - @Request() req: RequestWithUser, @Body() body: { node: number; @@ -5730,7 +5739,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("officer-by-admin-role") async GetOfficersByAdminRole( - @Request() req: RequestWithUser, @Body() body: { node: number; @@ -5785,8 +5793,7 @@ export class OrganizationDotnetController extends Controller { typeCondition = {}; break; } - } - else if (body.role === "BROTHER") { + } else if (body.role === "BROTHER") { switch (body.node) { case 0: typeCondition = { @@ -5827,7 +5834,7 @@ export class OrganizationDotnetController extends Controller { typeCondition = {}; break; } - } + } // else if (body.role === "PARENT") { // typeCondition = { // orgRoot: { @@ -5992,25 +5999,25 @@ export class OrganizationDotnetController extends Controller { item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.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 = @@ -6069,7 +6076,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("keycloak-all-employee") async PostProfileWithKeycloakAllEmployee( - @Request() req: RequestWithUser, @Body() body: { node: number; @@ -6158,25 +6164,25 @@ export class OrganizationDotnetController extends Controller { item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.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 = @@ -6223,7 +6229,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("none-validate-keycloak-all-employee") async PostProfileWithNoneValidateKeycloakAllEmployee( - @Request() req: RequestWithUser, @Body() body: { node: number; @@ -6312,25 +6317,25 @@ export class OrganizationDotnetController extends Controller { item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.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 = @@ -6377,7 +6382,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("employee-by-admin-role") async GetEmployeesByAdminRole( - @Request() req: RequestWithUser, @Body() body: { node: number; @@ -6434,8 +6438,7 @@ export class OrganizationDotnetController extends Controller { typeCondition = {}; break; } - } - else if (body.role === "BROTHER") { + } else if (body.role === "BROTHER") { switch (body.node) { case 0: typeCondition = { @@ -6476,7 +6479,7 @@ export class OrganizationDotnetController extends Controller { typeCondition = {}; break; } - } + } // else if (body.role === "PARENT") { // typeCondition = { // orgRoot: { @@ -6641,25 +6644,25 @@ export class OrganizationDotnetController extends Controller { item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.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 = @@ -7164,16 +7167,16 @@ export class OrganizationDotnetController extends Controller { currentAddress: profile && profile.currentAddress ? profile.currentAddress + - (profile.currentSubDistrict && profile.currentSubDistrict.name - ? " ตำบล/แขวง " + profile.currentSubDistrict.name - : "") + - (profile.currentDistrict && profile.currentDistrict.name - ? " อำเภอ/เขต " + profile.currentDistrict.name - : "") + - (profile.currentProvince && profile.currentProvince.name - ? " จังหวัด " + profile.currentProvince.name - : "") + - profile.currentZipCode + (profile.currentSubDistrict && profile.currentSubDistrict.name + ? " ตำบล/แขวง " + profile.currentSubDistrict.name + : "") + + (profile.currentDistrict && profile.currentDistrict.name + ? " อำเภอ/เขต " + profile.currentDistrict.name + : "") + + (profile.currentProvince && profile.currentProvince.name + ? " จังหวัด " + profile.currentProvince.name + : "") + + profile.currentZipCode : "-", oc: oc ?? "-", root: @@ -7209,26 +7212,26 @@ export class OrganizationDotnetController extends Controller { positions: _position && _position.length > 0 ? _position.slice(0, -1).map((x: any, idx: number) => ({ - positionName: x.positionName, - dateStart: x.commandDateAffect ?? null, - dateEnd: _position[idx + 1]?.commandDateAffect ?? null, - positionType: x.positionType, - positionLevel: x.positionLevel, - orgRoot: x.orgRoot, - orgChild1: x.orgChild1, - orgChild2: x.orgChild2, - orgChild3: x.orgChild3, - orgChild4: x.orgChild4, - })) + positionName: x.positionName, + dateStart: x.commandDateAffect ?? null, + dateEnd: _position[idx + 1]?.commandDateAffect ?? null, + positionType: x.positionType, + positionLevel: x.positionLevel, + orgRoot: x.orgRoot, + orgChild1: x.orgChild1, + orgChild2: x.orgChild2, + orgChild3: x.orgChild3, + orgChild4: x.orgChild4, + })) : [], educations: profile.profileEducations && profile.profileEducations.length > 0 ? profile.profileEducations.map((x) => ({ - educationLevel: x.educationLevel, - institute: x.institute ?? "-", - country: x.country ?? "-", - finishDate: x.finishDate, - })) + educationLevel: x.educationLevel, + institute: x.institute ?? "-", + country: x.country ?? "-", + finishDate: x.finishDate, + })) : [], }; return new HttpSuccess(mapEmpProfile); @@ -7278,16 +7281,16 @@ export class OrganizationDotnetController extends Controller { currentAddress: profile && profile.currentAddress ? profile.currentAddress + - (profile.currentSubDistrict && profile.currentSubDistrict.name - ? " ตำบล/แขวง " + profile.currentSubDistrict.name - : "") + - (profile.currentDistrict && profile.currentDistrict.name - ? " อำเภอ/เขต " + profile.currentDistrict.name - : "") + - (profile.currentProvince && profile.currentProvince.name - ? " จังหวัด " + profile.currentProvince.name - : "") + - profile.currentZipCode + (profile.currentSubDistrict && profile.currentSubDistrict.name + ? " ตำบล/แขวง " + profile.currentSubDistrict.name + : "") + + (profile.currentDistrict && profile.currentDistrict.name + ? " อำเภอ/เขต " + profile.currentDistrict.name + : "") + + (profile.currentProvince && profile.currentProvince.name + ? " จังหวัด " + profile.currentProvince.name + : "") + + profile.currentZipCode : "-", oc: oc ?? "-", root: @@ -7323,26 +7326,26 @@ export class OrganizationDotnetController extends Controller { positions: _position && _position.length > 0 ? _position.slice(0, -1).map((x: any, idx: number) => ({ - positionName: x.positionName, - dateStart: x.commandDateAffect ?? null, - dateEnd: _position[idx + 1]?.commandDateAffect ?? null, - positionType: x.positionType, - positionLevel: x.positionLevel, - orgRoot: x.orgRoot, - orgChild1: x.orgChild1, - orgChild2: x.orgChild2, - orgChild3: x.orgChild3, - orgChild4: x.orgChild4, - })) + positionName: x.positionName, + dateStart: x.commandDateAffect ?? null, + dateEnd: _position[idx + 1]?.commandDateAffect ?? null, + positionType: x.positionType, + positionLevel: x.positionLevel, + orgRoot: x.orgRoot, + orgChild1: x.orgChild1, + orgChild2: x.orgChild2, + orgChild3: x.orgChild3, + orgChild4: x.orgChild4, + })) : [], educations: profile.profileEducations && profile.profileEducations.length > 0 ? profile.profileEducations.map((x) => ({ - educationLevel: x.educationLevel, - institute: x.institute ?? "-", - country: x.country ?? "-", - finishDate: x.finishDate, - })) + educationLevel: x.educationLevel, + institute: x.institute ?? "-", + country: x.country ?? "-", + finishDate: x.finishDate, + })) : [], }; return new HttpSuccess(mapProfile); @@ -7350,10 +7353,7 @@ export class OrganizationDotnetController extends Controller { @Post("profile-leave/keycloak") async GetProfileLeaveReportByKeycloakIdAsync( - @Body() body: { - keycloakId: string, - report?: string - } + @Body() body: { keycloakId: string; report?: string }, ) { const profile = await this.profileRepo.findOne({ relations: { @@ -7396,14 +7396,14 @@ export class OrganizationDotnetController extends Controller { }, where: { keycloak: body.keycloakId, - } + }, }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); /* ========================================= - * current holder - * ========================================= */ + * current holder + * ========================================= */ const currentHolder = profile.current_holders?.find( - x => + (x) => x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); @@ -7425,37 +7425,40 @@ export class OrganizationDotnetController extends Controller { let _positions: any[] = []; let _educations: any[] = []; if (body.report && ["LEAVE16", "LEAVE18"].includes(body.report.trim().toUpperCase())) { - const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today"); let _currentDate = CURRENT_DATE[0].today; if (profile && profile?.isLeave) { _currentDate = - profile && profile.leaveDate ? Extension.toDateOnlyString(profile.leaveDate) : _currentDate; + profile && profile.leaveDate + ? Extension.toDateOnlyString(profile.leaveDate) + : _currentDate; } const positions = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [ profile!.id, _currentDate, ]); - _positions = positions[0].length > 0 - ? _positions.slice(0, -1).map((x: any, idx: number) => ({ - positionName: x.positionName, - dateStart: x.commandDateAffect ?? null, - dateEnd: _positions[idx + 1]?.commandDateAffect ?? null, - })) - : []; + _positions = + positions[0].length > 0 + ? _positions.slice(0, -1).map((x: any, idx: number) => ({ + positionName: x.positionName, + dateStart: x.commandDateAffect ?? null, + dateEnd: _positions[idx + 1]?.commandDateAffect ?? null, + })) + : []; const profileEducations = await this.educationRepo.find({ where: { profileEmployeeId: profile!.id, isDeleted: false }, order: { level: "ASC" }, }); - _educations = profileEducations.length > 0 - ? profileEducations.map((x) => ({ - educationLevel: x.educationLevel, - institute: x.institute ?? "-", - country: x.country ?? "-", - finishDate: x.finishDate, - })) - : []; + _educations = + profileEducations.length > 0 + ? profileEducations.map((x) => ({ + educationLevel: x.educationLevel, + institute: x.institute ?? "-", + country: x.country ?? "-", + finishDate: x.finishDate, + })) + : []; } const mapProfile = { @@ -7465,15 +7468,11 @@ export class OrganizationDotnetController extends Controller { lastName: profile.lastName, citizenId: profile.citizenId, birthDate: profile.birthDate, - retireDate: profile.birthDate - ? calculateRetireLaw(profile.birthDate) - : null, + retireDate: profile.birthDate ? calculateRetireLaw(profile.birthDate) : null, govAge: profile.dateAppoint ? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี` : null, - age: profile.birthDate - ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET") - : null, + age: profile.birthDate ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET") : null, dateAppoint: profile.dateAppoint, dateCurrent: new Date(), amount: profile.amount, @@ -7481,16 +7480,16 @@ export class OrganizationDotnetController extends Controller { currentAddress: profile && profile.currentAddress ? profile.currentAddress + - (profile.currentSubDistrict && profile.currentSubDistrict.name - ? " ตำบล/แขวง " + profile.currentSubDistrict.name - : "") + - (profile.currentDistrict && profile.currentDistrict.name - ? " อำเภอ/เขต " + profile.currentDistrict.name - : "") + - (profile.currentProvince && profile.currentProvince.name - ? " จังหวัด " + profile.currentProvince.name + " " - : "") + - profile.currentZipCode + (profile.currentSubDistrict && profile.currentSubDistrict.name + ? " ตำบล/แขวง " + profile.currentSubDistrict.name + : "") + + (profile.currentDistrict && profile.currentDistrict.name + ? " อำเภอ/เขต " + profile.currentDistrict.name + : "") + + (profile.currentProvince && profile.currentProvince.name + ? " จังหวัด " + profile.currentProvince.name + " " + : "") + + profile.currentZipCode : "-", position: profile.position, posType: profile.posType?.posTypeName, @@ -7513,12 +7512,11 @@ export class OrganizationDotnetController extends Controller { } /* ========================================= - * current holder - * ========================================= */ + * current holder + * ========================================= */ const currentHolder = profile.current_holders?.find( - x => - x.orgRevision?.orgRevisionIsDraft === false && - x.orgRevision?.orgRevisionIsCurrent === true, + (x) => + x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); let oc = ""; @@ -7537,19 +7535,18 @@ export class OrganizationDotnetController extends Controller { } /* ========================================= - * posType + posLevel - * ========================================= */ + * posType + posLevel + * ========================================= */ const positionLeaveName = profile.posType && - profile.posLevel && - (profile.posType.posTypeName === "บริหาร" || - profile.posType.posTypeName === "อำนวยการ") + profile.posLevel && + (profile.posType.posTypeName === "บริหาร" || profile.posType.posTypeName === "อำนวยการ") ? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}` - : profile.posLevel?.posLevelName ?? null; + : (profile.posLevel?.posLevelName ?? null); /* ========================================= - * position executive - * ========================================= */ + * position executive + * ========================================= */ const _posExec = await this.positionRepository.findOne({ where: { positionIsSelected: true, @@ -7565,37 +7562,40 @@ export class OrganizationDotnetController extends Controller { let _positions: any[] = []; let _educations: any[] = []; if (body.report && ["LEAVE16", "LEAVE18"].includes(body.report.trim().toUpperCase())) { - const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today"); let _currentDate = CURRENT_DATE[0].today; if (profile && profile?.isLeave) { _currentDate = - profile && profile.leaveDate ? Extension.toDateOnlyString(profile.leaveDate) : _currentDate; + profile && profile.leaveDate + ? Extension.toDateOnlyString(profile.leaveDate) + : _currentDate; } const positions = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [ profile!.id, _currentDate, ]); - _positions = positions[0].length > 0 - ? _positions.slice(0, -1).map((x: any, idx: number) => ({ - positionName: x.positionName, - dateStart: x.commandDateAffect ?? null, - dateEnd: _positions[idx + 1]?.commandDateAffect ?? null, - })) - : []; + _positions = + positions[0].length > 0 + ? _positions.slice(0, -1).map((x: any, idx: number) => ({ + positionName: x.positionName, + dateStart: x.commandDateAffect ?? null, + dateEnd: _positions[idx + 1]?.commandDateAffect ?? null, + })) + : []; const profileEducations = await this.educationRepo.find({ where: { profileId: profile!.id, isDeleted: false }, order: { level: "ASC" }, }); - _educations = profileEducations.length > 0 - ? profileEducations.map((x) => ({ - educationLevel: x.educationLevel, - institute: x.institute ?? "-", - country: x.country ?? "-", - finishDate: x.finishDate, - })) - : []; + _educations = + profileEducations.length > 0 + ? profileEducations.map((x) => ({ + educationLevel: x.educationLevel, + institute: x.institute ?? "-", + country: x.country ?? "-", + finishDate: x.finishDate, + })) + : []; } const mapProfile = { @@ -7605,15 +7605,11 @@ export class OrganizationDotnetController extends Controller { lastName: profile.lastName, citizenId: profile.citizenId, birthDate: profile.birthDate, - retireDate: profile.birthDate - ? calculateRetireLaw(profile.birthDate) - : null, + retireDate: profile.birthDate ? calculateRetireLaw(profile.birthDate) : null, govAge: profile.dateAppoint ? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี` : null, - age: profile.birthDate - ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET") - : null, + age: profile.birthDate ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET") : null, dateAppoint: profile.dateAppoint, dateCurrent: new Date(), amount: profile.amount, @@ -7621,16 +7617,16 @@ export class OrganizationDotnetController extends Controller { currentAddress: profile && profile.currentAddress ? profile.currentAddress + - (profile.currentSubDistrict && profile.currentSubDistrict.name - ? " ตำบล/แขวง " + profile.currentSubDistrict.name - : "") + - (profile.currentDistrict && profile.currentDistrict.name - ? " อำเภอ/เขต " + profile.currentDistrict.name - : "") + - (profile.currentProvince && profile.currentProvince.name - ? " จังหวัด " + profile.currentProvince.name + " " - : "") + - profile.currentZipCode + (profile.currentSubDistrict && profile.currentSubDistrict.name + ? " ตำบล/แขวง " + profile.currentSubDistrict.name + : "") + + (profile.currentDistrict && profile.currentDistrict.name + ? " อำเภอ/เขต " + profile.currentDistrict.name + : "") + + (profile.currentProvince && profile.currentProvince.name + ? " จังหวัด " + profile.currentProvince.name + " " + : "") + + profile.currentZipCode : "-", position: profile.position ?? "-", posLevel: profile.posLevel?.posLevelName ?? "-", @@ -7661,7 +7657,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("find/insignia-requests-profile/{type}") async GetInsigniaRequestsProfileAsync( - @Request() req: RequestWithUser, @Path() type: string, @Body() body: { @@ -7791,7 +7786,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("officer-by-admin-rolev2") async GetOfficersByAdminRoleV2( - @Request() req: RequestWithUser, @Body() body: { node: number; @@ -7836,8 +7830,7 @@ export class OrganizationDotnetController extends Controller { typeCondition = {}; break; } - } - else if (body.role === "BROTHER") { + } else if (body.role === "BROTHER") { switch (body.node) { case 0: typeCondition = { @@ -7868,7 +7861,7 @@ export class OrganizationDotnetController extends Controller { typeCondition = {}; break; } - } + } // else if (body.role === "PARENT") { // typeCondition = { // rootDnaId: body.nodeId, @@ -8016,7 +8009,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("officer-by-admin-rolev3") async GetOfficersByAdminRoleV3( - @Request() req: RequestWithUser, @Body() body: { node: number; @@ -8073,8 +8065,7 @@ export class OrganizationDotnetController extends Controller { typeCondition = {}; break; } - } - else if (body.role === "BROTHER") { + } else if (body.role === "BROTHER") { switch (body.node) { case 0: typeCondition = { @@ -8115,7 +8106,7 @@ export class OrganizationDotnetController extends Controller { typeCondition = {}; break; } - } + } // else if (body.role === "PARENT") { // typeCondition = { // orgRoot: { @@ -8287,25 +8278,25 @@ export class OrganizationDotnetController extends Controller { item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild3 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild3 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild2 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild2 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgChild1 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.orgChild1 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != - null && - item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) - ?.orgRoot != null + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) + ?.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 = @@ -8364,7 +8355,6 @@ export class OrganizationDotnetController extends Controller { */ @Post("officer-by-admin-rolev4") async GetOfficersByAdminRoleV4( - @Request() req: RequestWithUser, @Body() body: { node: number; @@ -8409,8 +8399,7 @@ export class OrganizationDotnetController extends Controller { typeCondition = {}; break; } - } - else if (body.role === "BROTHER") { + } else if (body.role === "BROTHER") { switch (body.node) { case 0: typeCondition = { @@ -8441,7 +8430,7 @@ export class OrganizationDotnetController extends Controller { typeCondition = {}; break; } - } + } // else if (body.role === "PARENT") { // typeCondition = { // rootDnaId: body.nodeId, @@ -8608,17 +8597,16 @@ export class OrganizationDotnetController extends Controller { ); return new HttpSuccess( - (profile_ ?? []).sort((a, b) => - a.posNo.localeCompare(b.posNo, undefined, { numeric: true })) + (profile_ ?? []).sort((a, b) => a.posNo.localeCompare(b.posNo, undefined, { numeric: true })), ); } /** - * API ค้นหา กจ. - * - * @summary API ค้นหา กจ. - * - */ + * API ค้นหา กจ. + * + * @summary API ค้นหา กจ. + * + */ @Post("find-staff") async findHigher( @Body() @@ -8626,18 +8614,13 @@ export class OrganizationDotnetController extends Controller { profileId: string; assignId: string; }, - @Request() request: RequestWithUser, ) { const profile = await this.profileRepo.findOne({ where: { id: requestBody.profileId }, - relations: [ - "current_holders", - "current_holders.orgRevision" - ], + relations: ["current_holders", "current_holders.orgRevision"], }); - if (!profile) - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); const assign = await this.assignRepository.findOne({ where: { id: requestBody.assignId.trim().toLocaleUpperCase() }, @@ -8647,7 +8630,7 @@ export class OrganizationDotnetController extends Controller { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลระบบสิทธิ์หน้าที่ความรับผิดชอบ"); const currentHolder = profile.current_holders?.find( - h => h.orgRevision?.orgRevisionIsCurrent && !h.orgRevision?.orgRevisionIsDraft, + (h) => h.orgRevision?.orgRevisionIsCurrent && !h.orgRevision?.orgRevisionIsDraft, ); if (!currentHolder) @@ -8690,7 +8673,7 @@ export class OrganizationDotnetController extends Controller { profileId: profile.id, }) .andWhere("assign.assignId = :assignId", { - assignId: assign.id + assignId: assign.id, }) .getRawMany();