From c810f75abd26d111c778fa5ea21d88a1dbff379e Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 16 Aug 2024 11:22:16 +0700 Subject: [PATCH 1/3] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20API?= =?UTF-8?q?=20=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB=E0=B8=B2=E0=B8=84?= =?UTF-8?q?=E0=B8=99=E0=B9=83=E0=B8=99=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A?= =?UTF-8?q?=E0=B8=B5=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4=20=E0=B9=80=E0=B8=9E=E0=B8=B4?= =?UTF-8?q?=E0=B9=88=E0=B8=A1=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=88=E0=B8=B2?= =?UTF-8?q?=E0=B8=81=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88?= =?UTF-8?q?=E0=B8=87=E0=B9=80=E0=B8=A5=E0=B8=82=E0=B8=97=E0=B8=B5=E0=B9=88?= =?UTF-8?q?=20=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=A7=E0=B8=A2=E0=B8=87?= =?UTF-8?q?=E0=B8=B2=E0=B8=99/=E0=B8=AA=E0=B9=88=E0=B8=A7=E0=B8=99?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=81=E0=B8=B2=E0=B8=A3=20#88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 29 +++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 692783b4..c8e6a997 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -2556,13 +2556,15 @@ export class ProfileController extends Controller { async listProfile( @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, - @Query() searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position", + @Query() searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position" | "posNo", @Query() searchKeyword: string = "", @Query() posType?: string, @Query() posLevel?: string, @Query() yearLeave?: number, @Query() isProbation?: boolean, @Query() isRetire?: boolean, + @Query() node?: number, + @Query() nodeId?: string, ) { let queryLike = "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword"; @@ -2570,6 +2572,27 @@ export class ProfileController extends Controller { queryLike = "profile.citizenId LIKE :keyword"; } else if (searchField == "position") { queryLike = "profile.position LIKE :keyword"; + } else if (searchField == "posNo") { + queryLike = `CONCAT( + IFNULL(orgChild4.orgChild4ShortName, ''), + IFNULL(orgChild3.orgChild3ShortName, ''), + IFNULL(orgChild2.orgChild2ShortName, ''), + IFNULL(orgChild1.orgChild1ShortName, ''), + IFNULL(orgRoot.orgRootShortName, ''), + IFNULL(current_holders.posMasterNo , '') + ) LIKE :keyword`; + } + let nodeCondition = "1=1"; + if (node === 0 && nodeId) { + nodeCondition = "current_holders.orgRootId = :nodeId"; + } else if (node === 1 && nodeId) { + nodeCondition = "current_holders.orgChild1Id = :nodeId"; + } else if (node === 2 && nodeId) { + nodeCondition = "current_holders.orgChild2Id = :nodeId"; + } else if (node === 3 && nodeId) { + nodeCondition = "current_holders.orgChild3Id = :nodeId"; + } else if (node === 4 && nodeId) { + nodeCondition = "current_holders.orgChild4Id = :nodeId"; } const [record, total] = await this.profileRepo .createQueryBuilder("profile") @@ -2619,9 +2642,13 @@ export class ProfileController extends Controller { keyword: `%${searchKeyword}%`, }, ) + .andWhere(nodeCondition, { + nodeId: nodeId, + }) .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); + const findRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true }, }); From 4468704f57fb92027b1e46dfc7f2af4502c72428 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 16 Aug 2024 11:44:08 +0700 Subject: [PATCH 2/3] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A?= =?UTF-8?q?=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=95=E0=B8=B1=E0=B8=A7?= =?UTF-8?q?=E0=B9=81=E0=B8=9B=E0=B8=A3=20method=20=3D>=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/PermissionController.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/controllers/PermissionController.ts b/src/controllers/PermissionController.ts index e1c7d5d4..625520a0 100644 --- a/src/controllers/PermissionController.ts +++ b/src/controllers/PermissionController.ts @@ -192,21 +192,21 @@ export class PermissionController extends Controller { /** * API permission (dotnet api) * @summary permission (dotnet api) - * @param {string} method Method + * @param {string} action action * @param {string} system authSysId */ - @Get("dotnet/{method}/{system}") + @Get("dotnet/{action}/{system}") public async dotnet( @Request() req: RequestWithUser, - @Path() method: string, + @Path() action: string, @Path() system: string ) { - if(!["CREATE", "DELETE", "GET", "LIST", "UPDATE"].includes(method)) { - throw new HttpError(HttpStatus.NOT_FOUND, "Method ไม่ถูกต้อง"); + if(!["CREATE", "DELETE", "GET", "LIST", "UPDATE"].includes(action)) { + throw new HttpError(HttpStatus.NOT_FOUND, "Action ไม่ถูกต้อง"); } - let res = await new permission().Permission(req, system.toLocaleUpperCase(), method); + let res = await new permission().Permission(req, system.toLocaleUpperCase(), action); return new HttpSuccess(res); } } From 81c9db66e5d5042e9f501608d93cecbff28c11d3 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 16 Aug 2024 12:06:37 +0700 Subject: [PATCH 3/3] fix find fullName --- src/controllers/ProfileController.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 6faf820f..daf35527 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -4191,7 +4191,8 @@ export class ProfileController extends Controller { keyword?: string; }, ) { - const [firstName, lastName] = body.keyword ? body.keyword.split(" ") : ["", ""]; + let conditionFullName = + "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword"; const [findProfile, total] = await AppDataSource.getRepository(Profile) .createQueryBuilder("profile") .leftJoinAndSelect("profile.posLevel", "posLevel") @@ -4223,16 +4224,9 @@ export class ProfileController extends Controller { .orWhere(`posType.posTypeName LIKE :keyword`, { keyword: `%${body.keyword}%`, }) - .orWhere( - new Brackets((qb) => { - if (body.keyword) { - qb.where(`profile.firstName LIKE :firstName`, { firstName: `%${firstName}%` }).orWhere( - `profile.lastName LIKE :lastName`, - { lastName: `%${lastName}%` }, - ); - } - }), - ) + .orWhere(conditionFullName, { + keyword: `%${body.keyword}%`, + }) .orderBy("profile.citizenId", "ASC") .skip((body.page - 1) * body.pageSize) .take(body.pageSize)