From f247d20afb91df9a86e84c212d13f1dfa3fc8887 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 8 May 2024 14:03:13 +0700 Subject: [PATCH 1/3] status start NEW --- src/controllers/KpiUserEvaluationController.ts | 2 +- src/entities/kpiUserEvaluation.ts | 2 +- .../1715151729330-add_table_kpiDevelopment1.ts | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/migration/1715151729330-add_table_kpiDevelopment1.ts diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 102a1f8..0c8e8fd 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -127,7 +127,7 @@ export class KpiUserEvaluationController extends Controller { kpiUserEvaluation.lastName = x.lastName; }) .catch((x) => {}); - kpiUserEvaluation.evaluationStatus = "PENDING"; + kpiUserEvaluation.evaluationStatus = "NEW"; kpiUserEvaluation.evaluationResults = "PENDING"; kpiUserEvaluation.createdUserId = request.user.sub; kpiUserEvaluation.createdFullName = request.user.name; diff --git a/src/entities/kpiUserEvaluation.ts b/src/entities/kpiUserEvaluation.ts index 54c70af..f20e494 100644 --- a/src/entities/kpiUserEvaluation.ts +++ b/src/entities/kpiUserEvaluation.ts @@ -71,7 +71,7 @@ export class KpiUserEvaluation extends EntityBase { length: 40, comment: "สถานะการประเมินผล ดังนี้ NEW = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น", - default: null, + default: "NEW", }) evaluationStatus: string; diff --git a/src/migration/1715151729330-add_table_kpiDevelopment1.ts b/src/migration/1715151729330-add_table_kpiDevelopment1.ts new file mode 100644 index 0000000..06b0b21 --- /dev/null +++ b/src/migration/1715151729330-add_table_kpiDevelopment1.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableKpiDevelopment11715151729330 implements MigrationInterface { + name = 'AddTableKpiDevelopment11715151729330' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationStatus\` \`evaluationStatus\` varchar(40) NULL COMMENT 'สถานะการประเมินผล ดังนี้ NEW = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น' DEFAULT 'NEW'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationStatus\` \`evaluationStatus\` varchar(40) NULL COMMENT 'สถานะการประเมินผล ดังนี้ NEW = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น'`); + } + +} From 5834958081bf3047a08dba528b3392f06fda599d Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 8 May 2024 14:03:42 +0700 Subject: [PATCH 2/3] fix isNull and fix Get{id} --- src/controllers/KpiPlanController.ts | 43 ++++++++++++++++++------- src/controllers/KpiRoleController.ts | 48 ++++++++++++++++++---------- 2 files changed, 63 insertions(+), 28 deletions(-) diff --git a/src/controllers/KpiPlanController.ts b/src/controllers/KpiPlanController.ts index c48c5c7..09b7f6a 100644 --- a/src/controllers/KpiPlanController.ts +++ b/src/controllers/KpiPlanController.ts @@ -340,8 +340,10 @@ export class kpiPlanController extends Controller { } const formattedData = { id: kpiPlan.id, - year: kpiPlan.kpiPeriod == null ? null : kpiPlan.kpiPeriod.year, - round: kpiPlan.kpiPeriod == null ? null : kpiPlan.kpiPeriod.durationKPI, + // year: kpiPlan.kpiPeriod == null ? null : kpiPlan.kpiPeriod.year, + // round: kpiPlan.kpiPeriod == null ? null : kpiPlan.kpiPeriod.durationKPI, + year: kpiPlan.kpiPeriod == null ? null : kpiPlan.year, + round: kpiPlan.kpiPeriod == null ? null : kpiPlan.period, kpiPeriodId: kpiPlan.kpiPeriodId, including: kpiPlan.including, includingName: kpiPlan.includingName, @@ -372,6 +374,7 @@ export class kpiPlanController extends Controller { strategyChild3: kpiPlan.strategyChild3Id, strategyChild4: kpiPlan.strategyChild4Id, strategyChild5: kpiPlan.strategyChild5Id, + documentInfoEvidence: kpiPlan.documentInfoEvidence, }; return new HttpSuccess(formattedData); } @@ -392,9 +395,9 @@ export class kpiPlanController extends Controller { period?: string | null; nodeId?: string | null; node?: number | null; - keyword?: string; - isAll?: boolean; - isNull?: boolean; + keyword?: string | null; + isAll?: boolean | false; + // isNull?: boolean | false; }, ) { let condition = ""; @@ -442,21 +445,37 @@ export class kpiPlanController extends Controller { } parameters.nodeId = `%${requestBody.nodeId}%`; } - if (requestBody.year && requestBody.period && requestBody.isNull === true) { - condition += ` AND (kpiPlan.year LIKE :year OR kpiPlan.year IS NULL) AND (kpiPlan.period LIKE :period OR kpiPlan.period IS NULL)`; - parameters.year = `%${requestBody.year}%`; - parameters.period = `%${requestBody.period}%`; - } + // if (requestBody.year && requestBody.period && requestBody.isNull === true) { + // condition += ` AND (kpiPlan.year LIKE :year OR kpiPlan.year IS NULL) AND (kpiPlan.period LIKE :period OR kpiPlan.period IS NULL)`; + // parameters.year = `%${requestBody.year}%`; + // parameters.period = `%${requestBody.period}%`; + // } const [kpiPlan, total] = await AppDataSource.getRepository(KpiPlan) .createQueryBuilder("kpiPlan") .leftJoinAndSelect("kpiPlan.kpiPeriod", "kpiPeriod") .andWhere(condition, parameters) + // .andWhere( + // requestBody.year && requestBody.period + // ? "kpiPlan.year LIKE :year AND kpiPlan.period LIKE :period" + // : "1=1", + // { + // year: `%${requestBody.year}%`, + // period: `%${requestBody.period}%`, + // }, + // ) .andWhere( - requestBody.isNull === false && requestBody.year && requestBody.period - ? "kpiPlan.year LIKE :year AND kpiPlan.period LIKE :period" + requestBody.year + ? "kpiPlan.year LIKE :year" : "1=1", { year: `%${requestBody.year}%`, + }, + ) + .andWhere( + requestBody.period + ? "kpiPlan.period LIKE :period" + : "1=1", + { period: `%${requestBody.period}%`, }, ) diff --git a/src/controllers/KpiRoleController.ts b/src/controllers/KpiRoleController.ts index a96b16d..964725d 100644 --- a/src/controllers/KpiRoleController.ts +++ b/src/controllers/KpiRoleController.ts @@ -342,9 +342,9 @@ export class kpiRoleController extends Controller { nodeId?: string | null; node?: number | null; position?: string | null; - keyword?: string; - isAll?: boolean; - isNull?: boolean; + keyword?: string | null; + isAll?: boolean | false; + // isNull?: boolean | false; }, ) { let condition = ""; @@ -392,11 +392,11 @@ export class kpiRoleController extends Controller { } parameters.nodeId = `%${requestBody.nodeId}%`; } - if (requestBody.year && requestBody.period && requestBody.isNull === true) { - condition += ` AND (kpiRole.year LIKE :year OR kpiRole.year IS NULL) AND (kpiRole.period LIKE :period OR kpiRole.period IS NULL)`; - parameters.year = `%${requestBody.year}%`; - parameters.period = `%${requestBody.period}%`; - } + // if (requestBody.year && requestBody.period && requestBody.isNull === true) { + // condition += ` AND (kpiRole.year LIKE :year OR kpiRole.year IS NULL) AND (kpiRole.period LIKE :period OR kpiRole.period IS NULL)`; + // parameters.year = `%${requestBody.year}%`; + // parameters.period = `%${requestBody.period}%`; + // } const [kpiRole, total] = await AppDataSource.getRepository(KpiRole) .createQueryBuilder("kpiRole") .leftJoinAndSelect("kpiRole.kpiPeriod", "kpiPeriod") @@ -416,15 +416,31 @@ export class kpiRoleController extends Controller { nodeId: requestBody.nodeId, }, ) + // .andWhere( + // requestBody.year && requestBody.period + // ? "kpiRole.year LIKE :year AND kpiRole.period LIKE :period" + // : "1=1", + // { + // year: `%${requestBody.year}%`, + // period: `%${requestBody.period}%`, + // }, + // ) .andWhere( - requestBody.isNull === false && requestBody.year && requestBody.period - ? "kpiRole.year LIKE :year AND kpiRole.period LIKE :period" - : "1=1", - { - year: `%${requestBody.year}%`, - period: `%${requestBody.period}%`, - }, - ) + requestBody.year + ? "kpiRole.year LIKE :year" + : "1=1", + { + year: `%${requestBody.year}%`, + }, + ) + .andWhere( + requestBody.period + ? "kpiRole.period LIKE :period" + : "1=1", + { + period: `%${requestBody.period}%`, + }, + ) .andWhere(requestBody.position != undefined ? "kpiRole.position LIKE :position" : "1=1", { position: `%${requestBody.position}%`, }) From b63d998442f9632e91e184ab85ee30db5175b43b Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 8 May 2024 14:10:22 +0700 Subject: [PATCH 3/3] fix --- src/controllers/KpiPlanController.ts | 4 ++-- src/controllers/KpiRoleController.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/controllers/KpiPlanController.ts b/src/controllers/KpiPlanController.ts index 09b7f6a..35f8e33 100644 --- a/src/controllers/KpiPlanController.ts +++ b/src/controllers/KpiPlanController.ts @@ -342,8 +342,8 @@ export class kpiPlanController extends Controller { id: kpiPlan.id, // year: kpiPlan.kpiPeriod == null ? null : kpiPlan.kpiPeriod.year, // round: kpiPlan.kpiPeriod == null ? null : kpiPlan.kpiPeriod.durationKPI, - year: kpiPlan.kpiPeriod == null ? null : kpiPlan.year, - round: kpiPlan.kpiPeriod == null ? null : kpiPlan.period, + year: kpiPlan.year == null ? null : kpiPlan.year, + round: kpiPlan.period == null ? null : kpiPlan.period, kpiPeriodId: kpiPlan.kpiPeriodId, including: kpiPlan.including, includingName: kpiPlan.includingName, diff --git a/src/controllers/KpiRoleController.ts b/src/controllers/KpiRoleController.ts index 964725d..fd57ee5 100644 --- a/src/controllers/KpiRoleController.ts +++ b/src/controllers/KpiRoleController.ts @@ -296,8 +296,10 @@ export class kpiRoleController extends Controller { } const formattedData = { id: kpiRole.id, - year: kpiRole.kpiPeriod == null ? null : kpiRole.kpiPeriod.year, - round: kpiRole.kpiPeriod == null ? null : kpiRole.kpiPeriod.durationKPI, + // year: kpiRole.kpiPeriod == null ? null : kpiRole.kpiPeriod.year, + // round: kpiRole.kpiPeriod == null ? null : kpiRole.kpiPeriod.durationKPI, + year: kpiRole.year == null ? null : kpiRole.year, + round: kpiRole.period == null ? null : kpiRole.period, kpiPeriodId: kpiRole.kpiPeriodId, including: kpiRole.including, includingName: kpiRole.includingName, @@ -321,6 +323,8 @@ export class kpiRoleController extends Controller { nodeName: nodeName, orgRevisionId: kpiRole.orgRevisionId, position: kpiRole.position, + documentInfoEvidence: kpiRole.documentInfoEvidence, + }; return new HttpSuccess(formattedData); }