validate remove kpiPeriod
This commit is contained in:
parent
289216089c
commit
22117c4d24
1 changed files with 11 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ import HttpError from "../interfaces/http-error";
|
|||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { KpiPeriod, createKpiPeriod, updateKpiPeriod } from "../entities/kpiPeriod";
|
||||
import { Like } from "typeorm/browser";
|
||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
|
||||
@Route("api/v1/kpi/period")
|
||||
@Tags("kpiPeriod")
|
||||
|
|
@ -32,6 +33,7 @@ import { Like } from "typeorm/browser";
|
|||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class kpiPeriodController extends Controller {
|
||||
private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod);
|
||||
private kpiUserEvaluationRepository = AppDataSource.getRepository(KpiUserEvaluation);
|
||||
/**
|
||||
* สร้างรอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||
* @param requestBody
|
||||
|
|
@ -205,7 +207,15 @@ export class kpiPeriodController extends Controller {
|
|||
"ไม่พบข้อมูลรอบการประเมินผลการปฏิบัติหน้าที่ราชการนี้",
|
||||
);
|
||||
}
|
||||
|
||||
const chkKpiUserEvaluation = await this.kpiUserEvaluationRepository.find({
|
||||
where: { kpiPeriodId: id },
|
||||
})
|
||||
if (chkKpiUserEvaluation) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่สามารถลบข้อมูลได้",
|
||||
);
|
||||
}
|
||||
await this.kpiPeriodRepository.remove(kpiPeriod);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue