This commit is contained in:
AdisakKanthawilang 2024-04-19 17:13:45 +07:00
parent 6499cb3da0
commit 17f110d345

View file

@ -124,7 +124,6 @@ export class kpiLinkController extends Controller {
await this.positionRepository.remove(chkKpiLink.positions);
Object.assign(chkKpiLink, {
...requestBody,
positions: [],
kpiCapacitys: [],
});
chkKpiLink.kpiGroupId = requestBody.kpiGroupId,
@ -194,22 +193,27 @@ export class kpiLinkController extends Controller {
return new HttpSuccess(formattedResponse);
}
// /**
// * API ลบเชื่อมโยง
// * @param id
// */
// @Delete("{id}")
// async deleteKpiLink(@Path() id: string) {
// const kpiLink = await this.kpiLinkRepository.findOne({
// where: { id: id },
// });
// if (!kpiLink) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการเชื่อมโยง");
// }
/**
* API
* @param id
*/
@Delete("{id}")
async deleteKpiLink(@Path() id: string) {
const kpiLink = await this.kpiLinkRepository.findOne({
where: { id: id },
relations: ["kpiCapacitys"],
});
if (!kpiLink) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการเชื่อมโยง");
}
kpiLink.kpiCapacitys = [];
await this.kpiLinkRepository.save(kpiLink);
// await this.kpiLinkRepository.remove(kpiLink);
// return new HttpSuccess();
// }
await this.positionRepository.delete({ kpiLinkId: id });
await this.kpiLinkRepository.delete({ id: id });
return new HttpSuccess();
}
/**
* API list