From 53945853c978df5a7a6a6d73153412e1f74be459 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 26 Mar 2024 09:53:28 +0700 Subject: [PATCH] =?UTF-8?q?fix=20=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3?= =?UTF-8?q?=E0=B8=AB=E0=B8=A5=E0=B8=B1=E0=B8=81=E0=B9=80=E0=B8=81=E0=B8=93?= =?UTF-8?q?=E0=B8=91=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SalaryFormulaEmployeeController.ts | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/controllers/SalaryFormulaEmployeeController.ts b/src/controllers/SalaryFormulaEmployeeController.ts index 8a3fff2..c5545cf 100644 --- a/src/controllers/SalaryFormulaEmployeeController.ts +++ b/src/controllers/SalaryFormulaEmployeeController.ts @@ -227,16 +227,20 @@ export class SalaryFormulaEmployeeController extends Controller { @Query("pageSize") pageSize: number = 10, @Query("keyword") keyword?: string, ) { + let whereClause: any = {}; + if (keyword != undefined && keyword !== "") { + whereClause = { + where: [ + { details: Like(`%${keyword}%`) }, + { position: Like(`%${keyword}%`) }, + { posType: { posTypeName: Like(`%${keyword}%`)} }, + { posLevel: { posLevelName: Like(`%${keyword}%`)} }, + ], + }; + } const [getFormula, total] = await this.salaryFormulaEmployeeRepository.findAndCount({ relations: ["salaryEmployee", "posType", "posLevel", "salaryEmployeeMins"], - where: { - details: Like(`%${keyword}%`), - position: Like(`%${keyword}%`), - // posLevel: { posLevelName: keyword }, - posType: { posTypeName: Like(`%${keyword}%`) }, - // salaryEmployeeMins: { group: keyword }, - // salaryEmployee: { group: keyword }, - }, + ...whereClause, order: { lastUpdatedAt: "DESC", }, @@ -245,16 +249,13 @@ export class SalaryFormulaEmployeeController extends Controller { const mapFormula = getFormula.map((item) => ({ id: item.id, - // posLevelId: item.posLevelId, posLevel: item.posLevel != null ? item.posLevel.posLevelName : null, - position: item.position, //// - // posTypeId: item.posTypeId, + position: item.position, posType: item.posType != null ? item.posType.posTypeName : null, - details: item.details, //// - salaryMin: item.salaryMin, // - salary: item.salary, // - salaryMax: item.salaryMax, // - // salaryEmployeeId: item.salaryEmployeeId, + details: item.details, + salaryMin: item.salaryMin, + salary: item.salary, + salaryMax: item.salaryMax, group: item.salaryEmployee != null ? item.salaryEmployee.group : null, salaryEmployeeMin: item.salaryEmployeeMins != null ? item.salaryEmployeeMins.map((x) => x.group) : null,