หมายเหตุ ผู้ประเมิน

This commit is contained in:
Kittapath 2024-06-26 12:41:38 +07:00
parent 468d8d8865
commit ae87b678d1
3 changed files with 302 additions and 0 deletions

View file

@ -987,4 +987,207 @@ export class KpiUserEvaluationController extends Controller {
return new HttpSuccess();
}
/**
*
*
* @param {string} id Guid, *Id (USER)
*/
@Get("open/{id}")
async openKpiUserEvaluation(
@Path() id: string,
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
kpiUserEvaluation.isOpen = true;
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Put("reason/user/{id}")
async updateReasonKpiUserEvaluation(
@Path() id: string,
@Body()
requestBody: {
topicEvaluator?: string | null;
developEvaluator?: string | null;
timeEvaluator?: string | null;
reasonEvaluator?: string | null;
},
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
const _null: any = null;
kpiUserEvaluation.topicEvaluator =
requestBody.topicEvaluator == null ? _null : requestBody.topicEvaluator;
kpiUserEvaluation.developEvaluator =
requestBody.developEvaluator == null ? _null : requestBody.developEvaluator;
kpiUserEvaluation.timeEvaluator =
requestBody.timeEvaluator == null ? _null : requestBody.timeEvaluator;
kpiUserEvaluation.reasonEvaluator =
requestBody.reasonEvaluator == null ? _null : requestBody.reasonEvaluator;
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Put("reason/commander/{id}")
async updateReasonKpiCommanderEvaluation(
@Path() id: string,
@Body()
requestBody: {
isReason: boolean;
reason?: string | null;
},
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
const _null: any = null;
kpiUserEvaluation.isReasonCommander = requestBody.isReason;
kpiUserEvaluation.reasonCommander = requestBody.reason == null ? _null : requestBody.reason;
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Put("reason/commanderHigh/{id}")
async updateReasonKpiCommanderHighEvaluation(
@Path() id: string,
@Body()
requestBody: {
isReason: boolean;
reason?: string | null;
},
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
const _null: any = null;
kpiUserEvaluation.isReasonCommanderHigh = requestBody.isReason;
kpiUserEvaluation.reasonCommanderHigh = requestBody.reason == null ? _null : requestBody.reason;
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Get("reason/{id}")
async getReasonKpiEvaluation(
@Path() id: string,
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
select: [
"topicEvaluator",
"developEvaluator",
"timeEvaluator",
"reasonEvaluator",
"isReasonCommander",
"reasonCommander",
"isReasonCommanderHigh",
"reasonCommanderHigh",
"isOpen",
],
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
return new HttpSuccess(kpiUserEvaluation);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Get("summary/{id}")
async getSummaryKpiEvaluation(
@Path() id: string,
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
select: ["id", "evaluationStatus", "lastUpdateUserId", "lastUpdateFullName"],
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
kpiUserEvaluation.evaluationStatus = "SUMMARY";
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation);
}
}