This commit is contained in:
AdisakKanthawilang 2024-04-18 17:49:34 +07:00
parent 396ef9400e
commit 7550ea729b

View file

@ -70,23 +70,27 @@ async updateKpiEvaluations(
*/ */
@Get() @Get()
async listKpiEvaluation( async listKpiEvaluation(
@Query("page") page: number = 1, // @Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10, // @Query("pageSize") pageSize: number = 10,
@Query("keyword") keyword?: string, // @Query("keyword") keyword?: string,
) { ) {
let whereClause: any = {}; let whereClause: any = {};
if (keyword !== undefined && keyword !== "") { // if (keyword !== undefined && keyword !== "") {
whereClause = { // whereClause = {
where: [{ description: Like(`%${keyword}%`) }], // where: [{ description: Like(`%${keyword}%`) }],
}; // };
whereClause.where.push({ level: Like(`%${keyword}%`) }); // whereClause.where.push({ level: Like(`%${keyword}%`) });
} // }
const [kpiEvaluation, total] = await this.kpiEvaluationRepository.findAndCount({ // const [kpiEvaluation, total] = await this.kpiEvaluationRepository.findAndCount({
...whereClause, // ...whereClause,
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }), // ...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
// order:{
// level: "DESC"}
// });
const kpiEvaluation = await this.kpiEvaluationRepository.find({
order:{ order:{
level: "DESC"} level: "DESC"}
}); });
@ -96,6 +100,6 @@ async updateKpiEvaluations(
level: item.level, level: item.level,
description: item.description description: item.description
})); }));
return new HttpSuccess({ data: formatted, total }); return new HttpSuccess(formatted);
} }
} }