This commit is contained in:
AdisakKanthawilang 2024-04-22 17:10:37 +07:00
parent 42264be4a2
commit 245e7f9df5
3 changed files with 242 additions and 16 deletions

View file

@ -69,8 +69,8 @@ export class KpiUserEvaluationController extends Controller {
kpiUserEvaluation.lastName = x.lastName
})
.catch((x) => {});
kpiUserEvaluation.evaluationStatus = requestBody.evaluationStatus
kpiUserEvaluation.evaluationResults = requestBody.evaluationResults
kpiUserEvaluation.evaluationStatus = "PENDING";
kpiUserEvaluation.evaluationResults = "PENDING";
kpiUserEvaluation.createdUserId = request.user.sub;
kpiUserEvaluation.createdFullName = request.user.name;
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
@ -113,8 +113,8 @@ export class KpiUserEvaluationController extends Controller {
}
if (kpiUserEvaluation) {
kpiUserEvaluation.evaluationStatus = requestBody.evaluationStatus
kpiUserEvaluation.evaluationResults = requestBody.evaluationResults
// kpiUserEvaluation.evaluationStatus = requestBody.evaluationStatus
// kpiUserEvaluation.evaluationResults = requestBody.evaluationResults
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
this.kpiUserEvalutionRepository.merge(kpiUserEvaluation, requestBody);

View file

@ -0,0 +1,234 @@
// import {
// Controller,
// Get,
// Post,
// Put,
// Delete,
// Patch,
// Route,
// Security,
// Tags,
// Body,
// Path,
// Request,
// Example,
// SuccessResponse,
// Response,
// Query,
// } from "tsoa";
// 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 HttpError from "../interfaces/http-error";
// import { Not } from "typeorm";
// @Route("api/v1/kpi/user/achievement/planned")
// @Tags("KpiUserPlanned")
// @Security("bearerAuth")
// @Response(
// HttpStatusCode.INTERNAL_SERVER_ERROR,
// "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
// )
// @SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
// export class KpiUserPlannedController extends Controller {
// private posTypeRepository = AppDataSource.getRepository(KpiUserPlanned);
// private posLevelRepository = AppDataSource.getRepository(PosLevel);
// /**
// * API เพิ่มประเภทตำแหน่ง
// *
// * @summary ORG_045 - เพิ่มประเภทตำแหน่ง (ADMIN) #48
// *
// */
// @Post()
// @Example({
// positionName: "นักบริหาร",
// posTypeRank: 1,
// })
// async createType(
// @Body()
// requestBody: CreateKpiUserPlanned,
// @Request() request: { user: Record<string, any> },
// ) {
// const posType = Object.assign(new KpiUserPlanned(), requestBody);
// if (!posType) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
// }
// const chkKpiUserPlannedName = await this.posTypeRepository.findOne({
// where: {
// posTypeName: requestBody.posTypeName,
// },
// });
// if (chkKpiUserPlannedName) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อประเภทตำแหน่งนี้มีอยู่ในระบบแล้ว");
// }
// posType.createdUserId = request.user.sub;
// posType.createdFullName = request.user.name;
// posType.lastUpdateUserId = request.user.sub;
// posType.lastUpdateFullName = request.user.name;
// await this.posTypeRepository.save(posType);
// return new HttpSuccess(posType);
// }
// /**
// * API แก้ไขประเภทตำแหน่ง
// *
// * @summary ORG_046 - แก้ไขประเภทตำแหน่ง (ADMIN) #49
// *
// * @param {string} id Id ประเภทตำแหน่ง
// */
// @Put("{id}")
// @Example({
// positionName: "นักบริหาร",
// posTypeRank: 1,
// })
// async editType(
// @Path() id: string,
// @Body() requestBody: UpdateKpiUserPlanned,
// @Request() request: { user: Record<string, any> },
// ) {
// const posType = await this.posTypeRepository.findOne({ where: { id } });
// if (!posType) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
// }
// const chkKpiUserPlannedName = await this.posTypeRepository.findOne({
// where: {
// id: Not(id),
// posTypeName: requestBody.posTypeName,
// },
// });
// if (chkKpiUserPlannedName) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อประเภทตำแหน่งนี้มีอยู่ในระบบแล้ว");
// }
// posType.lastUpdateUserId = request.user.sub;
// posType.lastUpdateFullName = request.user.name;
// this.posTypeRepository.merge(posType, requestBody);
// await this.posTypeRepository.save(posType);
// return new HttpSuccess(posType.id);
// }
// /**
// * API ลบประเภทตำแหน่ง
// *
// * @summary ORG_047 - ลบประเภทตำแหน่ง (ADMIN) #50
// *
// * @param {string} id Id ตำแหน่ง
// */
// @Delete("{id}")
// async deleteType(@Path() id: string) {
// const delKpiUserPlanned = await this.posTypeRepository.findOne({ where: { id } });
// if (!delKpiUserPlanned) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
// }
// const IdExitsInLevel = await this.posLevelRepository.find({
// where: { posTypeId: id },
// });
// if (IdExitsInLevel.length > 0) {
// throw new HttpError(
// HttpStatusCode.NOT_FOUND,
// "ไม่สามารถลบได้เนื่องจากพบข้อมูลที่ตารางระดับตำแหน่ง",
// );
// }
// await this.posTypeRepository.remove(delKpiUserPlanned);
// return new HttpSuccess();
// }
// /**
// * API รายละเอียดประเภทตำแหน่ง
// *
// * @summary ORG_048 - รายละเอียดประเภทตำแหน่ง (ADMIN) #51
// *
// * @param {string} id Id ประเภทตำแหน่ง
// */
// @Get("{id}")
// @Example([
// {
// id: "00000000-0000-0000-0000-000000000000",
// posTypeName: "นักบริหาร",
// posLevelposTypeRanks: 1,
// posLevels: [
// {
// id: "00000000-0000-0000-0000-000000000000",
// posLevelName: "นักบริหาร",
// posLevelRank: 1,
// posLevelAuthority: "HEAD",
// },
// ],
// },
// ])
// async GetTypeDetail(@Path() id: string) {
// const getKpiUserPlanned = await this.posTypeRepository.findOne({
// select: ["id", "posTypeName", "posTypeRank"],
// relations: ["posLevels"],
// where: { id: id },
// });
// if (!getKpiUserPlanned) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
// }
// const mapGetKpiUserPlanned = {
// id: getKpiUserPlanned.id,
// posTypeName: getKpiUserPlanned.posTypeName,
// posTypeRank: getKpiUserPlanned.posTypeRank,
// posLevels: getKpiUserPlanned.posLevels
// .sort((a, b) => a.posLevelRank - b.posLevelRank)
// .map((posLevel) => ({
// id: posLevel.id,
// posLevelName: posLevel.posLevelName,
// posLevelRank: posLevel.posLevelRank,
// posLevelAuthority: posLevel.posLevelAuthority,
// })),
// };
// return new HttpSuccess(mapGetKpiUserPlanned);
// }
// /**
// * API รายการประเภทตำแหน่ง
// *
// * @summary ORG_027 - รายการประเภทตำแหน่ง (ADMIN) #29
// *
// */
// @Get()
// @Example([
// {
// id: "00000000-0000-0000-0000-000000000000",
// posTypeName: "นักบริหาร",
// posTypeRank: 1,
// posLevels: [
// {
// id: "00000000-0000-0000-0000-000000000000",
// posLevelName: "นักบริหาร",
// posLevelRank: 1,
// posLevelAuthority: "HEAD",
// },
// ],
// },
// ])
// async GetKpiUserPlanned() {
// const posType = await this.posTypeRepository.find({
// select: ["id", "posTypeName", "posTypeRank"],
// relations: ["posLevels"],
// order: { posTypeRank: "ASC" },
// });
// // if (!posType) {
// // return new HttpSuccess([]);
// // }
// const mapKpiUserPlanned = posType.map((item) => ({
// id: item.id,
// posTypeName: item.posTypeName,
// posTypeRank: item.posTypeRank,
// posLevels: item.posLevels
// .sort((a, b) => a.posLevelRank - b.posLevelRank)
// .map((posLevel) => ({
// id: posLevel.id,
// posLevelName: posLevel.posLevelName,
// posLevelRank: posLevel.posLevelRank,
// posLevelAuthority: posLevel.posLevelAuthority,
// })),
// }));
// return new HttpSuccess(mapKpiUserPlanned);
// }
// }

View file

@ -48,19 +48,19 @@ export class KpiUserEvaluation extends EntityBase {
profileId: string;
@Column({
// PENDING = รอการประเมิน , INPROGRESS = กําลังประเมิน , DONE = ประเมินเสร็จสิ้น
// "สถานะการประเมินผล ดังนี้ PENDING = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น",
nullable: true,
length: 40,
comment: "สถานะการประเมินผล",
comment: "สถานะการประเมินผล ดังนี้ PENDING = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น",
default: null,
})
evaluationStatus: string;
@Column({
// PASSED = ผ่านการประเมิน , NOTPASSED = ไม่ผ่านการประเมิน
// "ผลการประเมิน ดังนี้ PENDING = รอดำเนินการ, PASSED = ผ่านการประเมิน, NOTPASSED = ไม่ผ่านการประเมิน",
nullable: true,
length: 40,
comment: "ผลการประเมิน",
comment: "ผลการประเมิน ดังนี้ PENDING = รอดำเนินการ, PASSED = ผ่านการประเมิน, NOTPASSED = ไม่ผ่านการประเมิน",
default: null,
})
evaluationResults: string;
@ -93,10 +93,6 @@ export class createKpiUserEvaluation {
kpiPeriodId: string;
@Column()
profileId: string;
@Column()
evaluationStatus: string;
@Column()
evaluationResults: string;
}
export class updateKpiUserEvaluation {
@ -110,8 +106,4 @@ export class updateKpiUserEvaluation {
kpiPeriodId: string;
@Column()
profileId: string;
@Column()
evaluationStatus: string;
@Column()
evaluationResults: string;
}