เพิ่มฟิลด์

This commit is contained in:
Bright 2024-04-22 15:24:44 +07:00
parent bc38831966
commit 4dd5c04cbd
2 changed files with 32 additions and 13 deletions

View file

@ -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 });
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddFieldsTableUserEvaluation1713774054952 implements MigrationInterface {
name = 'AddFieldsTableUserEvaluation1713774054952'
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`evaluationResults\``);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`evaluationStatus\``);
}
}