diff --git a/src/controllers/KpiSpecialController.ts b/src/controllers/KpiSpecialController.ts index 6b1ae48..6bb2e6f 100644 --- a/src/controllers/KpiSpecialController.ts +++ b/src/controllers/KpiSpecialController.ts @@ -162,21 +162,21 @@ export class kpiSpecialController extends Controller { keyword?: string | null; }, ) { - let condition: any = {}; - if (requestBody.keyword !== undefined && requestBody.keyword !== "") { - condition = { - where: [ - { - including: Like(`%${requestBody.keyword}%`), - includingName: Like(`%${requestBody.keyword}%`), - }, - ], - }; - } + // let condition: any = {}; + // if (requestBody.keyword !== undefined && requestBody.keyword !== "") { + // condition = { + // where: [ + // { + // including: Like(`%${requestBody.keyword}%`), + // includingName: Like(`%${requestBody.keyword}%`), + // }, + // ], + // }; + // } const [kpiSpecial, total] = await AppDataSource.getRepository(KpiSpecial) .createQueryBuilder("kpiSpecial") - .andWhere(condition) + // .andWhere(condition) .andWhere(requestBody.year ? "kpiSpecial.year LIKE :year" : "1=1", { year: `%${requestBody.year}%`, }) diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 374b68c..7c2ae5b 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -58,6 +58,9 @@ export class KpiUserEvaluationController extends Controller { @Query("pageSize") pageSize: number = 10, @Query("kpiPeriodId") kpiPeriodId?: string, @Query("keyword") keyword?: string, + @Query("status") status?: string, + @Query("results") results?: string, + @Query("reqedit") reqedit?: string, ) { let profileId: any = null; await new CallAPI() @@ -73,6 +76,21 @@ export class KpiUserEvaluationController extends Controller { .andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", { kpiPeriodId: kpiPeriodId, }) + .andWhere(status != null && status != undefined ? "evaluationStatus LIKE :status" : "1=1", { + status: status, + }) + .andWhere( + results != null && results != undefined ? "evaluationResults LIKE :results" : "1=1", + { + results: results, + }, + ) + .andWhere( + reqedit != null && reqedit != undefined ? "evaluationReqEdit LIKE :reqedit" : "1=1", + { + reqedit: reqedit, + }, + ) .andWhere( new Brackets((qb) => { qb.orWhere("kpiUserEvaluation.evaluatorId LIKE :profileId", { diff --git a/src/entities/kpiUserEvaluation.ts b/src/entities/kpiUserEvaluation.ts index d499542..bf099dd 100644 --- a/src/entities/kpiUserEvaluation.ts +++ b/src/entities/kpiUserEvaluation.ts @@ -88,7 +88,7 @@ export class KpiUserEvaluation extends EntityBase { nullable: true, length: 40, comment: "คำขอแก้ไข", - default: "NEW", + default: null, }) evaluationReqEdit: string; diff --git a/src/migration/1715242826033-update_table_kpiSpecial_date_nullable1.ts b/src/migration/1715242826033-update_table_kpiSpecial_date_nullable1.ts new file mode 100644 index 0000000..89422c1 --- /dev/null +++ b/src/migration/1715242826033-update_table_kpiSpecial_date_nullable1.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableKpiSpecialDateNullable11715242826033 implements MigrationInterface { + name = 'UpdateTableKpiSpecialDateNullable11715242826033' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationReqEdit\` \`evaluationReqEdit\` varchar(40) NULL COMMENT 'คำขอแก้ไข'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationReqEdit\` \`evaluationReqEdit\` varchar(40) NULL COMMENT 'คำขอแก้ไข' DEFAULT 'NEW'`); + } + +}