Merge branch 'develop' of github.com:Frappet/bma-ehr-kpi into develop

# Conflicts:
#	src/entities/kpiEvaluation.ts
This commit is contained in:
Kittapath 2024-04-18 17:24:39 +07:00
commit 91c48f4a40
2 changed files with 38 additions and 36 deletions

View file

@ -32,41 +32,39 @@ import { KpiEvaluation, updateKpiEvaluation } from "../entities/kpiEvaluation";
export class kpiEvaluationController extends Controller { export class kpiEvaluationController extends Controller {
private kpiEvaluationRepository = AppDataSource.getRepository(KpiEvaluation); private kpiEvaluationRepository = AppDataSource.getRepository(KpiEvaluation);
// /** /**
// * API แก้ไขเกณฑ์การประเมิน * API
// * @param id ไอดีของเกณฑ์การประเมิน * @param id
// */ */
// @Put("{id}") @Put()
// async updateKpiEvaluation( async updateKpiEvaluations(
// @Path() id: string, @Body() requestBody: updateKpiEvaluation[],
// @Body() requestBody: updateKpiEvaluation, @Request() request: { user: Record<string, any> },
// @Request() request: { user: Record<string, any> }, ) {
// ) { const updatedIds: string[] = [];
// const kpiEvaluation = await this.kpiEvaluationRepository.findOne({
// where: { id: id },
// });
// if (!kpiEvaluation) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเกณฑ์การประเมินนี้");
// }
// // const chkkpinameGroup = await this.kpiGroupRepository.findOne({ for (const item of requestBody) {
// // where: { const kpiEvaluation = await this.kpiEvaluationRepository.findOne({
// // nameGroupKPI: requestBody.nameGroupKPI, where: { id: item.id },
// // }, });
// // }); if (!kpiEvaluation) {
// // if (chkkpinameGroup) { throw new HttpError(HttpStatusCode.NOT_FOUND, `ไม่พบข้อมูลเกณฑ์การประเมินนี้: ${item.id}`);
// // throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อกลุ่มงานนี้มีอยู่ในระบบแล้ว"); }
// // }
this.kpiEvaluationRepository.merge(kpiEvaluation, item);
kpiEvaluation.lastUpdateUserId = request.user.sub;
kpiEvaluation.lastUpdateFullName = request.user.name;
await this.kpiEvaluationRepository.save(kpiEvaluation);
updatedIds.push(item.id);
}
return new HttpSuccess();
}
// this.kpiEvaluationRepository.merge(kpiEvaluation, requestBody);
// kpiEvaluation.lastUpdateUserId = request.user.sub;
// kpiEvaluation.lastUpdateFullName = request.user.name;
// await this.kpiEvaluationRepository.save(kpiEvaluation);
// return new HttpSuccess(id);
// }
/** /**
* API list * API list
* @param page * @param page
* @param pageSize * @param pageSize
*/ */
@ -80,13 +78,17 @@ export class kpiEvaluationController extends Controller {
if (keyword !== undefined && keyword !== "") { if (keyword !== undefined && keyword !== "") {
whereClause = { whereClause = {
where: [{ nameGroupKPI: Like(`%${keyword}%`) }], where: [{ description: 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"}
}); });
return new HttpSuccess({ data: kpiEvaluation, total }); return new HttpSuccess({ data: kpiEvaluation, total });

View file

@ -26,9 +26,9 @@ export class createKpiEvaluation {
} }
export class updateKpiEvaluation { export class updateKpiEvaluation {
@Column() @Column("uuid")
description: string; id: string;
@Column() @Column()
level: Number; description: string;
} }