From a96384130633c0aa192de082c5e2aa9f8113bd7a Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 22 Dec 2025 16:26:29 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD?= =?UTF-8?q?=E0=B8=9C=E0=B8=B9=E0=B9=89=E0=B8=A2=E0=B8=B7=E0=B9=88=E0=B8=99?= =?UTF-8?q?=E0=B8=AD=E0=B8=B8=E0=B8=98=E0=B8=A3=E0=B8=93=E0=B9=8C/?= =?UTF-8?q?=E0=B8=A3=E0=B9=89=E0=B8=AD=E0=B8=87=E0=B8=97=E0=B8=B8=E0=B8=81?= =?UTF-8?q?=E0=B8=82=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 36 ++++++++++++++++---- src/controllers/ProfileEmployeeController.ts | 31 +++++++++++++---- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index ac19ffdf..4dfa06fc 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -10800,14 +10800,27 @@ export class ProfileController extends Controller { */ @Post("search-personal-no-keycloak") async getProfileBySearchKeywordNoKeyCloak( + @Request() request: RequestWithUser, @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Body() body: { fieldName: string; keyword?: string; + system?: string; }, ) { + // ค้นหารายชื่อถ้าไม่ส่ง system มาให้ default ตามทะเบียนประวัติ + let _system: string = "SYS_REGISTRY_OFFICER"; + if (body.system) _system = body.system; + let _data = await new permission().PermissionOrgList(request, _system); + const findRevision = await this.orgRevisionRepo.findOne({ + where: { orgRevisionIsCurrent: true }, + }); + if (!findRevision) { + throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision"); + } + let findProfile: any; let total: any; const skip = (page - 1) * pageSize; @@ -10825,6 +10838,22 @@ export class ProfileController extends Controller { }); break; + case "fullName": + [findProfile, total] = await this.profileRepo + .createQueryBuilder("profile") + .leftJoinAndSelect("profile.posType", "posType") + .leftJoinAndSelect("profile.posLevel", "posLevel") + .leftJoinAndSelect("profile.current_holders", "current_holders") + .where("profile.keycloak IS NULL") + .andWhere( + "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", + { keyword: `%${body.keyword}%` } + ) + .skip(skip) + .take(take) + .getManyAndCount(); + break; + case "firstname": [findProfile, total] = await this.profileRepo.findAndCount({ where: { @@ -10861,13 +10890,6 @@ export class ProfileController extends Controller { break; } - const findRevision = await this.orgRevisionRepo.findOne({ - where: { orgRevisionIsCurrent: true }, - }); - if (!findRevision) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision"); - } - const mapDataProfile = await Promise.all( findProfile.map(async (item: Profile) => { const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`; diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index f72df407..e2a1fc09 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -5726,8 +5726,16 @@ export class ProfileEmployeeController extends Controller { body: { fieldName: string; keyword?: string; + system?: string; }, ) { + const findRevision = await this.orgRevisionRepo.findOne({ + where: { orgRevisionIsCurrent: true }, + }); + if (!findRevision) { + throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision"); + } + let findProfile: any; let total: any; const skip = (page - 1) * pageSize; @@ -5746,6 +5754,22 @@ export class ProfileEmployeeController extends Controller { }); break; + case "fullName": + [findProfile, total] = await this.profileRepo + .createQueryBuilder("profile") + .leftJoinAndSelect("profile.posType", "posType") + .leftJoinAndSelect("profile.posLevel", "posLevel") + .leftJoinAndSelect("profile.current_holders", "current_holders") + .where("profile.keycloak IS NULL") + .andWhere( + "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", + { keyword: `%${body.keyword}%` } + ) + .skip(skip) + .take(take) + .getManyAndCount(); + break; + case "firstname": [findProfile, total] = await this.profileRepo.findAndCount({ where: { @@ -5785,13 +5809,6 @@ export class ProfileEmployeeController extends Controller { break; } - const findRevision = await this.orgRevisionRepo.findOne({ - where: { orgRevisionIsCurrent: true }, - }); - if (!findRevision) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision"); - } - const mapDataProfile = await Promise.all( findProfile.map(async (item: ProfileEmployee) => { const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;