point
This commit is contained in:
parent
bdd2c9aa30
commit
5db5f445c8
4 changed files with 69 additions and 3 deletions
|
|
@ -19,7 +19,7 @@ import {
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { KpiUserPlanned, CreateKpiUserPlanned, UpdateKpiUserPlanned } from "../entities/kpiUserPlanned";
|
||||
import { KpiUserPlanned, CreateKpiUserPlanned, UpdateKpiUserPlanned, KpiUserPlannedDataPoint } from "../entities/kpiUserPlanned";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Not } from "typeorm";
|
||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
|
|
@ -194,4 +194,32 @@ export class KpiUserPlannedController extends Controller {
|
|||
}));
|
||||
return new HttpSuccess(mapKpiUserPlanned);
|
||||
}
|
||||
|
||||
/**
|
||||
* API กรอกระดับคะแนนงานตามแผนปฏิบัติราชการประจำปี
|
||||
*
|
||||
* @summary กรอกระดับคะแนนงานตามแผนปฏิบัติราชการประจำปี
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Post("point")
|
||||
async CreateKpiUserPlannedPoint(
|
||||
@Body() requestBody: KpiUserPlannedDataPoint[],
|
||||
@Request() request: { user: Record<string, any> },
|
||||
){
|
||||
|
||||
for (const item of requestBody) {
|
||||
const kpiUserPlanned = await this.kpiUserPlannedRepository.findOne({
|
||||
where: { id: item.id },
|
||||
});
|
||||
if (!kpiUserPlanned) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, `ไม่พบข้อมูลงานตามแผนปฏิบัติราชการประจำปีนี้: ${item.id}`);
|
||||
}
|
||||
this.kpiUserPlannedRepository.merge(kpiUserPlanned, item);
|
||||
kpiUserPlanned.lastUpdateUserId = request.user.sub;
|
||||
kpiUserPlanned.lastUpdateFullName = request.user.name;
|
||||
await this.kpiUserPlannedRepository.save(kpiUserPlanned);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue