fix เพิ่มตัวชี้วัด

This commit is contained in:
Bright 2024-07-11 12:10:15 +07:00
parent fb41b66bf9
commit 555e56417b
2 changed files with 6 additions and 4 deletions

View file

@ -48,14 +48,15 @@ export class kpiPlanController extends Controller {
@Request() request: { user: Record<string, any> },
) {
const kpiPlan = Object.assign(new KpiPlan(), requestBody);
if (requestBody.year != null) {
if (requestBody.year != null && requestBody.period != null) {
const kpiPeriod = await this.kpiPeriodRepository
.createQueryBuilder("kpiPeriod")
.where("kpiPeriod.year = :year", { year: requestBody.year })
.andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period })
.getOne();
if (!kpiPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้");
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้");
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบการประเมินนี้ในปีงบประมาณ "+requestBody.year);
}
}
await new CallAPI()

View file

@ -48,14 +48,15 @@ export class kpiRoleController extends Controller {
@Request() request: { user: Record<string, any> },
) {
const kpiRole = Object.assign(new KpiRole(), requestBody);
if (requestBody.year != null) {
if (requestBody.year != null && requestBody.period != null) {
const kpiPeriod = await this.kpiPeriodRepository
.createQueryBuilder("kpiPeriod")
.where("kpiPeriod.year = :year", { year: requestBody.year })
.andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period })
.getOne();
if (!kpiPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้");
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้");
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบการประเมินนี้ในปีงบประมาณ "+requestBody.year);
}
}
await new CallAPI()