no message

This commit is contained in:
Kittapath 2024-05-08 18:03:47 +07:00
parent 305fd51c99
commit b3adb67e44
13 changed files with 497 additions and 121 deletions

View file

@ -30,10 +30,6 @@ import {
} from "../entities/kpiUserEvaluation";
import { Like, In, Brackets } from "typeorm";
import CallAPI from "../interfaces/call-api";
import {
KpiUserEvaluationReason,
updateKpiUserReasonEvaluation,
} from "../entities/kpiUserEvaluationReason";
@Route("api/v1/kpi/user/evaluation")
@Tags("kpiUserEvaluation")
@ -46,7 +42,6 @@ import {
export class KpiUserEvaluationController extends Controller {
private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod);
private kpiUserEvalutionRepository = AppDataSource.getRepository(KpiUserEvaluation);
private kpiUserEvaluationReasonRepository = AppDataSource.getRepository(KpiUserEvaluationReason);
/**
* API
@ -195,56 +190,56 @@ export class KpiUserEvaluationController extends Controller {
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Put("{type}/{id}")
async updateKpiUserEvaluatorEvaluation(
@Path() id: string,
@Path() type: string,
@Body() requestBody: updateKpiUserReasonEvaluation,
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
// /**
// * API แก้ไขหมายเหตุ (USER)
// *
// * @summary แก้ไขหมายเหตุ (USER)
// *
// * @param {string} id Guid, *Id คนประเมิน (USER)
// */
// @Put("{type}/{id}")
// async updateKpiUserEvaluatorEvaluation(
// @Path() id: string,
// @Path() type: string,
// @Body() requestBody: updateKpiUserReasonEvaluation,
// @Request() request: { user: Record<string, any> },
// ) {
// const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
// where: { id: id },
// });
// if (!kpiUserEvaluation) {
// throw new HttpError(
// HttpStatusCode.NOT_FOUND,
// "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
// );
// }
const kpiUserEvaluationReason = Object.assign(new KpiUserEvaluationReason(), requestBody);
kpiUserEvaluationReason.type = type.trim().toUpperCase();
kpiUserEvaluationReason.kpiUserEvaluationId = id;
kpiUserEvaluationReason.createdUserId = request.user.sub;
kpiUserEvaluationReason.createdFullName = request.user.name;
kpiUserEvaluationReason.lastUpdateUserId = request.user.sub;
kpiUserEvaluationReason.lastUpdateFullName = request.user.name;
await this.kpiUserEvaluationReasonRepository.save(kpiUserEvaluationReason);
return new HttpSuccess(kpiUserEvaluation.id);
}
// const kpiUserEvaluationReason = Object.assign(new KpiUserEvaluationReason(), requestBody);
// kpiUserEvaluationReason.type = type.trim().toUpperCase();
// kpiUserEvaluationReason.kpiUserEvaluationId = id;
// kpiUserEvaluationReason.createdUserId = request.user.sub;
// kpiUserEvaluationReason.createdFullName = request.user.name;
// kpiUserEvaluationReason.lastUpdateUserId = request.user.sub;
// kpiUserEvaluationReason.lastUpdateFullName = request.user.name;
// await this.kpiUserEvaluationReasonRepository.save(kpiUserEvaluationReason);
// return new HttpSuccess(kpiUserEvaluation.id);
// }
/**
* API list (USER)
*
* @summary list (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Get("{type}/{id}")
async listKpiUserCommanderEvaluation(@Path() id: string, @Path() type: string) {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRepository.find({
where: { kpiUserEvaluationId: id, type: type.trim().toUpperCase() },
order: { createdAt: "ASC" },
});
return new HttpSuccess(kpiUserEvaluationReason);
}
// /**
// * API list หมายเหตุ (USER)
// *
// * @summary list หมายเหตุ (USER)
// *
// * @param {string} id Guid, *Id คนประเมิน (USER)
// */
// @Get("{type}/{id}")
// async listKpiUserCommanderEvaluation(@Path() id: string, @Path() type: string) {
// const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRepository.find({
// where: { kpiUserEvaluationId: id, type: type.trim().toUpperCase() },
// order: { createdAt: "ASC" },
// });
// return new HttpSuccess(kpiUserEvaluationReason);
// }
/**
* API (USER)