diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 80113b1..a7d3a6c 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -153,7 +153,7 @@ export class DevelopmentController extends Controller { // description: "Store Development.", // }); const before = null; - + await this.developmentRepository.save(development, { data: request }); setLogDataDiff(request, { before, after: development }); return new HttpSuccess(development.id); @@ -1464,6 +1464,30 @@ export class DevelopmentController extends Controller { return new HttpSuccess({ data: data, total }); } + /** + * API รายการโครงการ/หลักสูตรการฝึกอบรมที่เสร็จสิ้น + * + * @summary DEV_004 - รายการโครงการ/หลักสูตรการฝึกอบรมที่เสร็จสิ้น + * + */ + @Get("done") + async GetDevelopmentListsDone(@Query("year") year: number) { + const [development, total] = await AppDataSource.getRepository(Development) + .createQueryBuilder("development") + .andWhere(year > 0 ? "development.year LIKE :year" : "1=1", { + year: `${year.toString()}`, + }) + .andWhere("development.status LIKE :status", { + status: `%FINISH%`, + }) + .select(["development.id", "development.projectName", "development.year"]) + .orderBy("development.year", "DESC") + .orderBy("development.createdAt", "DESC") + .getManyAndCount(); + + return new HttpSuccess({ data: development, total }); + } + /** * API ลบโครงการ/หลักสูตรการฝึกอบรม * @@ -1899,6 +1923,48 @@ export class DevelopmentController extends Controller { return new HttpSuccess(_getDevelopment); } + /** + * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab3 + * + * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab3 # + * + * @param {string} id Id โครงการ + */ + @Get("tab3_1/{id}") + async GetDevelopemtTab3_1ById(@Path() id: string) { + const getDevelopment = await this.developmentRepository.findOne({ + where: { id: id }, + relations: [ + "developmentProjectTypes", + "developmentProjectTechniquePlanneds", + "developmentProjectTechniqueActuals", + ], + }); + if (!getDevelopment) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); + } + let _getDevelopment: any = { + projectModalActual: getDevelopment.projectModalActual, + isBackActual: getDevelopment.isBackActual, + isHoldActual: getDevelopment.isHoldActual, + projectDayBackActual: getDevelopment.projectDayBackActual, + projectDayHoldActual: getDevelopment.projectDayHoldActual, + projectNigthHoldActual: getDevelopment.projectNigthHoldActual, + reasonActual70: getDevelopment.reasonActual70, + reasonActual20: getDevelopment.reasonActual20, + reasonActual10: getDevelopment.reasonActual10, + developmentProjectTechniqueActuals: getDevelopment.developmentProjectTechniqueActuals + .map((x) => x.name) + .sort(), + strategyChild1Actual: getDevelopment.strategyChild1ActualId, + strategyChild2Actual: getDevelopment.strategyChild2ActualId, + strategyChild3Actual: getDevelopment.strategyChild3ActualId, + strategyChild4Actual: getDevelopment.strategyChild4ActualId, + strategyChild5Actual: getDevelopment.strategyChild5ActualId, + }; + return new HttpSuccess(_getDevelopment); + } + /** * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab4 *