split (kpi/evaluation/edit) to criteria

This commit is contained in:
AdisakKanthawilang 2024-09-11 16:55:58 +07:00
parent e7d35773a9
commit b95cda9512

View file

@ -78,7 +78,41 @@ export class kpiEvaluationController extends Controller {
) {
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
let whereClause: any = {};
console.log("CODE8");
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 formatted = kpiEvaluation.map((item) => ({
id: item.id,
level: item.level,
description: item.description,
}));
return new HttpSuccess({ data: formatted, total });
}
/**
* API
*/
@Get("criteria")
async listKpiEvaluationEditInKpiList(
@Request() request: RequestWithUser,
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query("keyword") keyword?: string,
) {
await new permission().PermissionGet(request, "SYS_KPI_LIST");
let whereClause: any = {};
if (keyword !== undefined && keyword !== "") {
whereClause = {
where: [{ description: Like(`%${keyword}%`) }],