From 4dd5c04cbdc2ca66b7596f35c0b8d968047b97e1 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 22 Apr 2024 15:24:44 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KpiUserEvaluationController.ts | 29 ++++++++++--------- ...4054952-add_fields_table_userEvaluation.ts | 16 ++++++++++ 2 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 src/migration/1713774054952-add_fields_table_userEvaluation.ts diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index c413c5b..c38a6dc 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -151,23 +151,23 @@ export class KpiUserEvaluationController extends Controller { async listKpiUserEvaluation( @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, - @Query("period") period?: string, - @Query("keyword") keyword?: string, + @Query("kpiPeriodId") kpiPeriodId?: string, + // @Query("keyword") keyword?: string, ) { const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation) .createQueryBuilder("kpiUserEvaluation") - .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod") - .andWhere( - keyword == undefined - ? "1=1" - : [ - { prefix: Like(`%${keyword}%`) }, - { firstName: Like(`%${keyword}%`) }, - { lastName: Like(`%${keyword}%`) }, - ], - ) - .andWhere(period ? "kpiPeriod.durationKPI LIKE :period" : "1=1", { period: `%${period}%` }) + // .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod") + // .andWhere( + // keyword == undefined + // ? "1=1" + // : [ + // { prefix: Like(`%${keyword}%`) }, + // { firstName: Like(`%${keyword}%`) }, + // { lastName: Like(`%${keyword}%`) }, + // ], + // ) + .andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", { kpiPeriodId: `%${kpiPeriodId}%` }) .orderBy("kpiUserEvaluation.createdAt", "ASC") .skip((page - 1) * pageSize) .take(pageSize) @@ -180,6 +180,9 @@ export class KpiUserEvaluationController extends Controller { firstname: item.firstName, lastname: item.lastName, kpiPeriodId: item.kpiPeriodId, + evaluationStatus: item.evaluationStatus, + evaluationResults: item.evaluationResults, + createdAt: item.createdAt, })); return new HttpSuccess({ data: mapData, total }); } diff --git a/src/migration/1713774054952-add_fields_table_userEvaluation.ts b/src/migration/1713774054952-add_fields_table_userEvaluation.ts new file mode 100644 index 0000000..1a3197e --- /dev/null +++ b/src/migration/1713774054952-add_fields_table_userEvaluation.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddFieldsTableUserEvaluation1713774054952 implements MigrationInterface { + name = 'AddFieldsTableUserEvaluation1713774054952' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`evaluationStatus\` varchar(40) NULL COMMENT 'สถานะการประเมินผล'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`evaluationResults\` varchar(40) NULL COMMENT 'ผลการประเมิน'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`evaluationResults\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`evaluationStatus\``); + } + +}