checkpoint

This commit is contained in:
AdisakKanthawilang 2024-04-19 16:19:09 +07:00
parent b70f447174
commit 85f39a55a6
3 changed files with 260 additions and 166 deletions

View file

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