diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index a5d6fdf..2e9bd9c 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2606,6 +2606,58 @@ export class DevelopmentController extends Controller { return new HttpSuccess(getOrg); } + @Get("registry/{type}/{developmentId}") + async developmentDetail( + @Path() developmentId: string, + @Path() type: string, + @Request() request: RequestWithUser + ) { + const getDevelopment = await this.developmentRepository.findOne({ + where: { id: developmentId }, + relations: [ + "developmentProjectTypes", + "developmentProjectTechniquePlanneds", + "developmentProjectTechniqueActuals", + "developmentAddresss", + ], + }); + if (!getDevelopment) + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); + + if (type.trim().toLocaleUpperCase() == "OFFICER") { + let _workflow = await new permission().Workflow(request, developmentId, "SYS_REGISTRY_OFFICER"); + if (_workflow == false) await new permission().PermissionGet(request, "SYS_REGISTRY_OFFICER"); + } else if (type.trim().toLocaleUpperCase() == "USER") { + } else { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถเข้าถึงข้อมูลนี้ได้"); + } + + let _getDevelopment: any = { + id: getDevelopment.id, + evaluationId: null, + target: null, + summary: null, + point: null, + name: getDevelopment.projectName, + achievement10: "มีผลการพัฒนาและมีการดำเนินการตามเป้าหมายการนำไปพัฒนางาน1", + achievement5: "มีผลการพัฒนาแต่ยังไม่ได้ดำเนินการตามเป้าหมายการนำไปพัฒนางาน", + achievement0: "ไม่ได้ดำเนินการพัฒนา", + isDevelopment70: getDevelopment.isReasonActual70, + isDevelopment20: getDevelopment.isReasonActual20, + isDevelopment10: getDevelopment.isReasonActual10, + reasonDevelopment70: getDevelopment.reasonActual70, + reasonDevelopment20: getDevelopment.reasonActual20, + reasonDevelopment10: getDevelopment.reasonActual10, + selectType: "PROJECT", + selectTypeYear: getDevelopment.year, + selectTypeId: null, + developmentProjects : getDevelopment.developmentProjectTechniqueActuals + .map((x) => x.name) + .sort(), + }; + return new HttpSuccess(_getDevelopment); + } + /** * API upload User *