เพิ่ม put เเก้ไข status/edit

This commit is contained in:
AnandaTon 2024-05-09 12:05:55 +07:00
parent fe7dcd6815
commit 940a6171ca
2 changed files with 72 additions and 0 deletions

View file

@ -27,6 +27,8 @@ import {
updateKpiUserCheckEvaluation,
updateKpiUserEvaluation,
updateKpiUserPointEvaluation,
updateKpiUserStatusEvaluation,
updateKpiUserReqEditEvaluation,
} from "../entities/kpiUserEvaluation";
import { Like, In, Brackets } from "typeorm";
import CallAPI from "../interfaces/call-api";
@ -230,6 +232,66 @@ export class KpiUserEvaluationController extends Controller {
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Put("edit/{id}")
async updateKpiUserReqEditEvaluation(
@Path() id: string,
@Body() requestBody: updateKpiUserReqEditEvaluation,
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
kpiUserEvaluation.evaluationReqEdit = requestBody.status.trim().toUpperCase();
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
// Object.assign(kpiUserEvaluation, requestBody);
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Put("status/{id}")
async updateKpiUserStatusEvaluation(
@Path() id: string,
@Body() requestBody: updateKpiUserStatusEvaluation,
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
kpiUserEvaluation.evaluationStatus = requestBody.status.trim().toUpperCase();
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
// Object.assign(kpiUserEvaluation, requestBody);
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*

View file

@ -203,3 +203,13 @@ export class updateKpiUserPointEvaluation {
@Column()
capacityPoint: number | null;
}
export class updateKpiUserReqEditEvaluation {
@Column()
status: string;
}
export class updateKpiUserStatusEvaluation {
@Column()
status: string;
}