From a4eed4f690ac0e131a1ee56cd58c564ccb6a5389 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 11 Apr 2024 16:32:44 +0700 Subject: [PATCH 1/5] =?UTF-8?q?api=20=E0=B8=97=E0=B8=B8=E0=B8=99=20?= =?UTF-8?q?=E0=B8=82=E0=B8=AD=E0=B8=87=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/DevelopmentController.ts | 346 ++++++++++++------ .../DevelopmentScholarshipController.ts | 84 +++++ src/entities/Development.ts | 34 +- ...s => DevelopmentProjectTechniqueActual.ts} | 8 +- .../DevelopmentProjectTechniquePlanned.ts | 39 ++ src/entities/DevelopmentScholarship.ts | 63 ++++ .../1712815316667-add_table_starty1.ts | 20 + ...ble_developmentScholarship_add_planType.ts | 26 ++ 8 files changed, 496 insertions(+), 124 deletions(-) rename src/entities/{DevelopmentProjectTechnique.ts => DevelopmentProjectTechniqueActual.ts} (86%) create mode 100644 src/entities/DevelopmentProjectTechniquePlanned.ts create mode 100644 src/migration/1712815316667-add_table_starty1.ts create mode 100644 src/migration/1712824449740-update_table_developmentScholarship_add_planType.ts diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 466db5e..bf63fe5 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -38,9 +38,13 @@ import { PosLevel } from "../entities/PosLevel"; import { PlannedGoalPosition } from "../entities/PlannedGoalPosition"; import { DevelopmentHistory } from "../entities/DevelopmentHistory"; import { DevelopmentProjectType } from "../entities/DevelopmentProjectType"; -import { DevelopmentProjectTechnique } from "../entities/DevelopmentProjectTechnique"; -import { DevelopmentEvaluation } from "../entities/DevelopmentEvaluation"; +import { + CreateDevelopmentEvaluation, + DevelopmentEvaluation, +} from "../entities/DevelopmentEvaluation"; import { DevelopmentAddress } from "../entities/DevelopmentAddress"; +import { DevelopmentProjectTechniquePlanned } from "../entities/DevelopmentProjectTechniquePlanned"; +import { DevelopmentProjectTechniqueActual } from "../entities/DevelopmentProjectTechniqueActual"; @Route("api/v1/development/main") @Tags("Development") @@ -50,8 +54,11 @@ export class DevelopmentController extends Controller { private developmentAddresssRepository = AppDataSource.getRepository(DevelopmentAddress); private developmentEvaluationRepository = AppDataSource.getRepository(DevelopmentEvaluation); private developmentProjectTypeRepository = AppDataSource.getRepository(DevelopmentProjectType); - private developmentProjectTechniqueRepository = AppDataSource.getRepository( - DevelopmentProjectTechnique, + private developmentProjectTechniquePlannedRepository = AppDataSource.getRepository( + DevelopmentProjectTechniquePlanned, + ); + private developmentProjectTechniqueActualRepository = AppDataSource.getRepository( + DevelopmentProjectTechniqueActual, ); private developmentHistoryRepository = AppDataSource.getRepository(DevelopmentHistory); private actualPeopleRepository = AppDataSource.getRepository(ActualPeople); @@ -162,7 +169,7 @@ export class DevelopmentController extends Controller { if (!development) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - const data = Object.assign(new PlannedGoal(), requestBody); + const data = Object.assign(new PlannedGoal(), { ...requestBody, positions: [] }); data.createdUserId = request.user.sub; data.createdFullName = request.user.name; data.lastUpdateUserId = request.user.sub; @@ -284,7 +291,7 @@ export class DevelopmentController extends Controller { @Put("tab2_4_add/{id}") async CreateDevelopmenttab2_4( @Path() id: string, - @Body() requestBody: CreateActualPeople[], + @Body() requestBody: CreateActualPeople, @Request() request: { user: Record }, ) { const development = await this.developmentRepository.findOne({ @@ -308,7 +315,7 @@ export class DevelopmentController extends Controller { * * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-1 # * - * @param {string} id Id โครงการ + * @param {string} id Id รายการ */ @Put("tab2_1_edit/{id}") async UpdateDevelopmenttab2_1( @@ -327,9 +334,7 @@ export class DevelopmentController extends Controller { } await this.plannedGoalPositionRepository.remove(development.plannedGoalPositions); - const _requestBody: any = requestBody; - delete _requestBody.positions; - Object.assign(development, requestBody); + Object.assign(development, { ...requestBody, positions: [] }); development.lastUpdateUserId = request.user.sub; development.lastUpdateFullName = request.user.name; await this.plannedGoalRepository.save(development); @@ -371,7 +376,7 @@ export class DevelopmentController extends Controller { * * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-2 # * - * @param {string} id Id โครงการ + * @param {string} id Id รายการ */ @Put("tab2_2_edit/{id}") async UpdateDevelopmenttab2_2( @@ -397,7 +402,7 @@ export class DevelopmentController extends Controller { * * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-3 # * - * @param {string} id Id โครงการ + * @param {string} id Id รายการ */ @Put("tab2_3_edit/{id}") async UpdateDevelopmenttab2_3( @@ -439,7 +444,7 @@ export class DevelopmentController extends Controller { * * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-4 # * - * @param {string} id Id โครงการ + * @param {string} id Id รายการ */ @Put("tab2_4_edit/{id}") async UpdateDevelopmenttab2_4( @@ -557,19 +562,28 @@ export class DevelopmentController extends Controller { where: { id }, relations: { developmentProjectTypes: true, - developmentProjectTechniques: true, + developmentProjectTechniquePlanneds: true, + developmentProjectTechniqueActuals: true, }, }); if (!development) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - Object.assign(development, requestBody); + Object.assign(development, { + ...requestBody, + developmentProjectTypes: [], + developmentProjectTechniquePlanneds: [], + developmentProjectTechniqueActuals: [], + }); development.lastUpdateUserId = request.user.sub; development.lastUpdateFullName = request.user.name; await this.developmentRepository.save(development); await this.developmentProjectTypeRepository.remove(development.developmentProjectTypes); - await this.developmentProjectTechniqueRepository.remove( - development.developmentProjectTechniques, + await this.developmentProjectTechniquePlannedRepository.remove( + development.developmentProjectTechniquePlanneds, + ); + await this.developmentProjectTechniqueActualRepository.remove( + development.developmentProjectTechniqueActuals, ); if (requestBody.developmentProjectTypes != null) { await Promise.all( @@ -585,17 +599,31 @@ export class DevelopmentController extends Controller { }), ); } - if (requestBody.developmentProjectTechniques != null) { + if (requestBody.developmentProjectTechniquePlanneds != null) { await Promise.all( - requestBody.developmentProjectTechniques.map(async (x) => { - let data = new DevelopmentProjectTechnique(); + requestBody.developmentProjectTechniquePlanneds.map(async (x) => { + let data = new DevelopmentProjectTechniquePlanned(); data.name = x; data.createdUserId = request.user.sub; data.createdFullName = request.user.name; data.lastUpdateUserId = request.user.sub; data.lastUpdateFullName = request.user.name; data.developmentId = development.id; - await this.developmentProjectTechniqueRepository.save(data); + await this.developmentProjectTechniquePlannedRepository.save(data); + }), + ); + } + if (requestBody.developmentProjectTechniqueActuals != null) { + await Promise.all( + requestBody.developmentProjectTechniqueActuals.map(async (x) => { + let data = new DevelopmentProjectTechniquePlanned(); + data.name = x; + data.createdUserId = request.user.sub; + data.createdFullName = request.user.name; + data.lastUpdateUserId = request.user.sub; + data.lastUpdateFullName = request.user.name; + data.developmentId = development.id; + await this.developmentProjectTechniqueActualRepository.save(data); }), ); } @@ -617,9 +645,6 @@ export class DevelopmentController extends Controller { ) { const development = await this.developmentRepository.findOne({ where: { id }, - relations: { - developmentEvaluations: true, - }, }); if (!development) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); @@ -628,18 +653,80 @@ export class DevelopmentController extends Controller { development.lastUpdateUserId = request.user.sub; development.lastUpdateFullName = request.user.name; await this.developmentRepository.save(development); - await this.developmentEvaluationRepository.remove(development.developmentEvaluations); - await Promise.all( - requestBody.developmentEvaluations.map(async (x) => { - const data = Object.assign(new DevelopmentEvaluation(), x); - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.developmentId = development.id; - await this.developmentEvaluationRepository.save(data); - }), - ); + return new HttpSuccess(development.id); + } + + /** + * API เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab4-1 + * + * @summary DEV_00 - เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab4-1 # + * + * @param {string} id Id โครงการ + */ + @Put("tab4_1_add/{id}") + async CreateDevelopmenttab4_1( + @Path() id: string, + @Body() requestBody: CreateDevelopmentEvaluation, + @Request() request: { user: Record }, + ) { + const development = await this.developmentRepository.findOne({ + where: { id }, + }); + if (!development) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); + } + const data = Object.assign(new DevelopmentEvaluation(), requestBody); + data.createdUserId = request.user.sub; + data.createdFullName = request.user.name; + data.lastUpdateUserId = request.user.sub; + data.lastUpdateFullName = request.user.name; + data.developmentId = development.id; + await this.developmentEvaluationRepository.save(data); + return new HttpSuccess(data.id); + } + + /** + * API ลบโครงการ/หลักสูตรการฝึกอบรมtab4-1 + * + * @summary DEV_00 - ลบโครงการ/หลักสูตรการฝึกอบรมtab4-1 # + * + * @param {string} id Id รายการ + */ + @Delete("tab4_1/{id}") + async DeleteDevelopmenttab4_1(@Path() id: string) { + const development = await this.developmentEvaluationRepository.findOne({ + where: { id }, + }); + if (!development) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้เกี่ยวข้องเป้าหมายตามแผน"); + } + await this.developmentEvaluationRepository.remove(development); + return new HttpSuccess(development.id); + } + + /** + * API แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab4-1 + * + * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab4-1 # + * + * @param {string} id Id รายการ + */ + @Put("tab4_1_edit/{id}") + async UpdateDevelopmenttab4_1( + @Path() id: string, + @Body() requestBody: CreateDevelopmentEvaluation, + @Request() request: { user: Record }, + ) { + const development = await this.developmentEvaluationRepository.findOne({ + where: { id }, + }); + if (!development) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); + } + Object.assign(development, requestBody); + development.lastUpdateUserId = request.user.sub; + development.lastUpdateFullName = request.user.name; + await this.developmentEvaluationRepository.save(development); return new HttpSuccess(development.id); } @@ -658,9 +745,7 @@ export class DevelopmentController extends Controller { ) { const development = await this.developmentRepository.findOne({ where: { id }, - relations: { - developmentAddresss: true, - }, + relations: { developmentAddresss: true }, }); if (!development) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); @@ -673,28 +758,31 @@ export class DevelopmentController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลจังหวัดข้อมูลด้านวิชาการ"); } } - Object.assign(development, requestBody); + + Object.assign(development, { ...requestBody, developmentAddresss: [] }); development.lastUpdateUserId = request.user.sub; development.lastUpdateFullName = request.user.name; await this.developmentRepository.save(development); + await this.developmentAddresssRepository.remove(development.developmentAddresss); await Promise.all( requestBody.developmentAddresss.map(async (x) => { const data = Object.assign(new DevelopmentAddress(), x); - const chkProvince = await this.provinceRepository.find({ + const chkProvince = await this.provinceRepository.findOne({ where: { id: x.provinceId, }, }); if (chkProvince == null) return; + data.developmentId = development.id; data.createdUserId = request.user.sub; data.createdFullName = request.user.name; data.lastUpdateUserId = request.user.sub; data.lastUpdateFullName = request.user.name; - data.developmentId = development.id; await this.developmentAddresssRepository.save(data); }), ); + return new HttpSuccess(development.id); } @@ -703,7 +791,6 @@ export class DevelopmentController extends Controller { * * @summary DEV_00 - ค้นหาโครงการ # * - * @param {string} id Id โครงการ */ @Get("search") async ListDevelopemt( @@ -752,7 +839,7 @@ export class DevelopmentController extends Controller { * * @summary DEV_003 - ลบโครงการ/หลักสูตรการฝึกอบรม #3 * - * @param {string} id Id โครงการ + * @param {string} id Id รายการ */ @Delete("{id}") async DeleteDevelopment(@Path() id: string) { @@ -764,7 +851,8 @@ export class DevelopmentController extends Controller { developmentActualGoals: true, developmentPlannedGoals: true, developmentProjectTypes: true, - developmentProjectTechniques: true, + developmentProjectTechniquePlanneds: true, + developmentProjectTechniqueActuals: true, developmentEvaluations: true, developmentAddresss: true, }, @@ -787,8 +875,11 @@ export class DevelopmentController extends Controller { await this.actualGoalRepository.remove(development.developmentActualGoals); await this.plannedGoalRepository.remove(development.developmentPlannedGoals); await this.developmentProjectTypeRepository.remove(development.developmentProjectTypes); - await this.developmentProjectTechniqueRepository.remove( - development.developmentProjectTechniques, + await this.developmentProjectTechniquePlannedRepository.remove( + development.developmentProjectTechniquePlanneds, + ); + await this.developmentProjectTechniqueActualRepository.remove( + development.developmentProjectTechniqueActuals, ); await this.developmentEvaluationRepository.remove(development.developmentEvaluations); await this.developmentAddresssRepository.remove(development.developmentAddresss); @@ -915,10 +1006,38 @@ export class DevelopmentController extends Controller { } let _getDevelopment: any = { id: getDevelopment.id, - actualPeoples: getDevelopment.developmentActualPeoples, - plannedPeoples: getDevelopment.developmentPlannedPeoples, - actualGoals: getDevelopment.developmentActualGoals, - plannedGoals: getDevelopment.developmentPlannedGoals, + actualPeoples: + getDevelopment.developmentActualPeoples == null + ? null + : getDevelopment.developmentActualPeoples.sort((a, b) => + (a.groupTarget == null ? "" : a.groupTarget).localeCompare( + b.groupTarget == null ? "" : b.groupTarget, + ), + ), + plannedPeoples: + getDevelopment.developmentPlannedPeoples == null + ? null + : getDevelopment.developmentPlannedPeoples.sort((a, b) => + (a.groupTarget == null ? "" : a.groupTarget).localeCompare( + b.groupTarget == null ? "" : b.groupTarget, + ), + ), + actualGoals: + getDevelopment.developmentActualGoals == null + ? null + : getDevelopment.developmentActualGoals.sort((a, b) => + (a.groupTarget == null ? "" : a.groupTarget).localeCompare( + b.groupTarget == null ? "" : b.groupTarget, + ), + ), + plannedGoals: + getDevelopment.developmentPlannedGoals == null + ? null + : getDevelopment.developmentPlannedGoals.sort((a, b) => + (a.groupTarget == null ? "" : a.groupTarget).localeCompare( + b.groupTarget == null ? "" : b.groupTarget, + ), + ), }; return new HttpSuccess(_getDevelopment); } @@ -935,28 +1054,34 @@ export class DevelopmentController extends Controller { const getDevelopment = await this.developmentRepository.findOne({ where: { id: id }, relations: [ - "developmentActualPeoples", - "developmentPlannedPeoples", - "developmentActualGoals", - "developmentPlannedGoals", - "developmentPlannedGoals.plannedGoalPositions", - "provinces", - // "provinces.developmentProvinces", + "developmentProjectTypes", + "developmentProjectTechniquePlanneds", + "developmentProjectTechniqueActuals", ], }); if (!getDevelopment) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - let _getDevelopment: any = getDevelopment; - _getDevelopment.actualPeoples = getDevelopment.developmentActualPeoples; - _getDevelopment.plannedPeoples = getDevelopment.developmentPlannedPeoples; - _getDevelopment.actualGoals = getDevelopment.developmentActualGoals; - _getDevelopment.plannedGoals = getDevelopment.developmentPlannedGoals; - // _getDevelopment.provinces = getDevelopment.provinces.map(x=>x.developmentProvinces); - delete _getDevelopment.developmentActualPeoples; - delete _getDevelopment.developmentPlannedPeoples; - delete _getDevelopment.developmentActualGoals; - delete _getDevelopment.developmentPlannedGoals; + let _getDevelopment: any = { + developmentProjectTypes: getDevelopment.developmentProjectTypes.map((x) => x.name).sort(), + projectModal: getDevelopment.projectModal, + isBackPlanned: getDevelopment.isBackPlanned, + isHoldPlanned: getDevelopment.isHoldPlanned, + projectDayBackPlanned: getDevelopment.projectDayBackPlanned, + projectDayHoldPlanned: getDevelopment.projectDayHoldPlanned, + projectNigthHoldPlanned: getDevelopment.projectNigthHoldPlanned, + developmentProjectTechniquePlanneds: getDevelopment.developmentProjectTechniquePlanneds + .map((x) => x.name) + .sort(), + isBackActual: getDevelopment.isBackActual, + isHoldActual: getDevelopment.isHoldActual, + projectDayBackActual: getDevelopment.projectDayBackActual, + projectDayHoldActual: getDevelopment.projectDayHoldActual, + projectNigthHoldActual: getDevelopment.projectNigthHoldActual, + developmentProjectTechniqueActuals: getDevelopment.developmentProjectTechniqueActuals + .map((x) => x.name) + .sort(), + }; return new HttpSuccess(_getDevelopment); } @@ -971,29 +1096,28 @@ export class DevelopmentController extends Controller { async GetDevelopemtTab4ById(@Path() id: string) { const getDevelopment = await this.developmentRepository.findOne({ where: { id: id }, - relations: [ - "developmentActualPeoples", - "developmentPlannedPeoples", - "developmentActualGoals", - "developmentPlannedGoals", - "developmentPlannedGoals.plannedGoalPositions", - "provinces", - // "provinces.developmentProvinces", - ], + relations: ["developmentEvaluations"], }); if (!getDevelopment) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - let _getDevelopment: any = getDevelopment; - _getDevelopment.actualPeoples = getDevelopment.developmentActualPeoples; - _getDevelopment.plannedPeoples = getDevelopment.developmentPlannedPeoples; - _getDevelopment.actualGoals = getDevelopment.developmentActualGoals; - _getDevelopment.plannedGoals = getDevelopment.developmentPlannedGoals; - // _getDevelopment.provinces = getDevelopment.provinces.map(x=>x.developmentProvinces); - delete _getDevelopment.developmentActualPeoples; - delete _getDevelopment.developmentPlannedPeoples; - delete _getDevelopment.developmentActualGoals; - delete _getDevelopment.developmentPlannedGoals; + let _getDevelopment = { + developmentEvaluations: + getDevelopment.developmentEvaluations == null + ? null + : getDevelopment.developmentEvaluations.sort((a, b) => + (a.indicators == null ? "" : a.indicators).localeCompare( + b.indicators == null ? "" : b.indicators, + ), + ), + project: getDevelopment.project, + isPassAllocate: getDevelopment.isPassAllocate, + isPassNoAllocate: getDevelopment.isPassNoAllocate, + isNoPass: getDevelopment.isNoPass, + isBudget: getDevelopment.isBudget, + isOutBudget: getDevelopment.isOutBudget, + }; + return new HttpSuccess(_getDevelopment); } @@ -1008,29 +1132,39 @@ export class DevelopmentController extends Controller { async GetDevelopemtTab5ById(@Path() id: string) { const getDevelopment = await this.developmentRepository.findOne({ where: { id: id }, - relations: [ - "developmentActualPeoples", - "developmentPlannedPeoples", - "developmentActualGoals", - "developmentPlannedGoals", - "developmentPlannedGoals.plannedGoalPositions", - "provinces", - // "provinces.developmentProvinces", - ], + relations: ["developmentAddresss"], }); if (!getDevelopment) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - let _getDevelopment: any = getDevelopment; - _getDevelopment.actualPeoples = getDevelopment.developmentActualPeoples; - _getDevelopment.plannedPeoples = getDevelopment.developmentPlannedPeoples; - _getDevelopment.actualGoals = getDevelopment.developmentActualGoals; - _getDevelopment.plannedGoals = getDevelopment.developmentPlannedGoals; - // _getDevelopment.provinces = getDevelopment.provinces.map(x=>x.developmentProvinces); - delete _getDevelopment.developmentActualPeoples; - delete _getDevelopment.developmentPlannedPeoples; - delete _getDevelopment.developmentActualGoals; - delete _getDevelopment.developmentPlannedGoals; + let _getDevelopment = { + dateStart: getDevelopment.dateStart, + dateEnd: getDevelopment.dateEnd, + totalDate: getDevelopment.totalDate, + developmentAddresss: + getDevelopment.developmentAddresss == null + ? null + : getDevelopment.developmentAddresss.sort((a, b) => + (a.address == null ? "" : a.address).localeCompare( + b.address == null ? "" : b.address, + ), + ), + budget: getDevelopment.budget, + budgetSub: getDevelopment.budgetSub, + accept: getDevelopment.accept, + receive: getDevelopment.receive, + approved: getDevelopment.approved, + budgetPay: getDevelopment.budgetPay, + issues: getDevelopment.issues, + chance: getDevelopment.chance, + effects: getDevelopment.effects, + riskLevel: getDevelopment.riskLevel, + riskManagement: getDevelopment.riskManagement, + expect: getDevelopment.expect, + topicAcademic: getDevelopment.topicAcademic, + addressAcademic: getDevelopment.addressAcademic, + provinceActualId: getDevelopment.provinceActualId, + }; return new HttpSuccess(_getDevelopment); } diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index 3ef6c50..f305148 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -21,6 +21,7 @@ import { CreateDevelopmentScholarship, DevelopmentScholarship, UpdateDevelopmentScholarship, + UpdateDevelopmentScholarshipUser, } from "../entities/DevelopmentScholarship"; import { PosType } from "../entities/PosType"; import { PosLevel } from "../entities/PosLevel"; @@ -314,10 +315,91 @@ export class DevelopmentScholarshipController extends Controller { totalPeriod: getDevelopment.totalPeriod ? getDevelopment.totalPeriod : null, status: getDevelopment.status ? getDevelopment.status : null, profileId: getDevelopment.profileId ? getDevelopment.profileId : null, + planType: getDevelopment.planType ? getDevelopment.planType : null, + isNoUseBudget: getDevelopment.isNoUseBudget ? getDevelopment.isNoUseBudget : null, }; return new HttpSuccess(formattedData); } + /** + * API รายการทุนของ user + * + * @summary DEV_0 - รายการทุนของ user # + * + * @param {string} profileId profileId ข้าราชการฯที่ได้รับทุนการศึกษา + */ + @Get("user/{profileId}") + async GetDevelopemtScholarshipUserById(@Path() profileId: string) { + const getDevelopment = await this.developmentScholarshipRepository.find({ + where: { profileId: profileId }, + }); + const formattedData = getDevelopment.map((item) => ({ + id: item.id, + scholarshipYear: item.scholarshipYear, + scholarshipType: item.scholarshipType, + fundType: item.fundType, + })); + + return new HttpSuccess(formattedData); + } + + /** + * API รายละเอียดทุนของ user + * + * @summary DEV_0 - รายละเอียดทุนของ user # + * + * @param {string} id id รายการ + */ + @Get("user/detail/{id}") + async GetDevelopemtScholarshipUserDetailById(@Path() id: string) { + const getDevelopment = await this.developmentScholarshipRepository.findOne({ + where: { id: id }, + select: [ + "id", + "scholarshipYear", + "scholarshipType", + "fundType", + "governmentDate", + "isGraduated", + "graduatedDate", + "isNoGraduated", + "graduatedReason", + ], + }); + if (!getDevelopment) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); + } + + return new HttpSuccess(getDevelopment); + } + + /** + * API แก้ไขรายการทุนของ user + * + * @summary DEV_015 - แก้ไขรายการทุนของ user #15 + * + * @param {string} id รายการ + */ + @Put("user/detail/{id}") + async UpdateDevelopemtScholarshipUserById( + @Path() id: string, + @Body() requestBody: UpdateDevelopmentScholarshipUser, + @Request() request: { user: Record }, + ) { + const getDevelopment = await this.developmentScholarshipRepository.findOne({ + where: { id: id }, + }); + if (!getDevelopment) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); + } + Object.assign(getDevelopment, requestBody); + getDevelopment.lastUpdateUserId = request.user.sub; + getDevelopment.lastUpdateFullName = request.user.name; + await this.developmentScholarshipRepository.save(getDevelopment); + + return new HttpSuccess(getDevelopment.id); + } + /** * API เปลี่ยนสถานะ * @@ -340,6 +422,8 @@ export class DevelopmentScholarshipController extends Controller { } const _status = status.trim().toUpperCase(); getDevelopment.status = _status; + getDevelopment.lastUpdateUserId = request.user.sub; + getDevelopment.lastUpdateFullName = request.user.name; if (_status == "GRADUATE") { if (getDevelopment.scholarshipType != null) { switch (getDevelopment.scholarshipType.trim().toUpperCase()) { diff --git a/src/entities/Development.ts b/src/entities/Development.ts index bae93d3..3c1a34e 100644 --- a/src/entities/Development.ts +++ b/src/entities/Development.ts @@ -7,9 +7,10 @@ import { ActualGoal, CreateActualGoal } from "./ActualGoal"; import { CreatePlannedGoal, PlannedGoal } from "./PlannedGoal"; import { DevelopmentHistory } from "./DevelopmentHistory"; import { DevelopmentProjectType } from "./DevelopmentProjectType"; -import { DevelopmentProjectTechnique } from "./DevelopmentProjectTechnique"; +import { DevelopmentProjectTechniquePlanned } from "./DevelopmentProjectTechniquePlanned"; import { CreateDevelopmentEvaluation, DevelopmentEvaluation } from "./DevelopmentEvaluation"; import { CreateDevelopmentAddress, DevelopmentAddress } from "./DevelopmentAddress"; +import { DevelopmentProjectTechniqueActual } from "./DevelopmentProjectTechniqueActual"; @Entity("development") export class Development extends EntityBase { @@ -141,11 +142,18 @@ export class Development extends EntityBase { projectNigthHoldActual: number; @OneToMany( - () => DevelopmentProjectTechnique, - (developmentProjectTechnique: DevelopmentProjectTechnique) => - developmentProjectTechnique.development, + () => DevelopmentProjectTechniquePlanned, + (developmentProjectTechniquePlanned: DevelopmentProjectTechniquePlanned) => + developmentProjectTechniquePlanned.development, ) - developmentProjectTechniques: DevelopmentProjectTechnique[]; + developmentProjectTechniquePlanneds: DevelopmentProjectTechniquePlanned[]; + + @OneToMany( + () => DevelopmentProjectTechniqueActual, + (developmentProjectTechniqueActual: DevelopmentProjectTechniqueActual) => + developmentProjectTechniqueActual.development, + ) + developmentProjectTechniqueActuals: DevelopmentProjectTechniqueActual[]; @Column({ nullable: true, @@ -400,6 +408,8 @@ export class UpdateDevelopment3 { @Column() developmentProjectTypes?: string[]; @Column() + projectModal?: number | null; + @Column() isBackPlanned?: boolean | null; @Column() isHoldPlanned?: boolean | null; @@ -410,6 +420,8 @@ export class UpdateDevelopment3 { @Column() projectNigthHoldPlanned?: number | null; @Column() + developmentProjectTechniquePlanneds?: string[]; + @Column() isBackActual?: boolean | null; @Column() isHoldActual?: boolean | null; @@ -420,13 +432,11 @@ export class UpdateDevelopment3 { @Column() projectNigthHoldActual?: number | null; @Column() - developmentProjectTechniques?: string[]; - @Column() - projectModal?: number | null; + developmentProjectTechniqueActuals?: string[]; } export class UpdateDevelopment4 { - @Column() - developmentEvaluations: CreateDevelopmentEvaluation[]; + // @Column() + // developmentEvaluations: CreateDevelopmentEvaluation[]; @Column() project: string | null; @Column() @@ -479,8 +489,4 @@ export class UpdateDevelopment5 { addressAcademic: string | null; @Column() provinceActualId: string | null; - @Column() - dateStudyStart: Date | null; - @Column() - dateStudyEnd: Date | null; } diff --git a/src/entities/DevelopmentProjectTechnique.ts b/src/entities/DevelopmentProjectTechniqueActual.ts similarity index 86% rename from src/entities/DevelopmentProjectTechnique.ts rename to src/entities/DevelopmentProjectTechniqueActual.ts index 2d3ac30..a437e00 100644 --- a/src/entities/DevelopmentProjectTechnique.ts +++ b/src/entities/DevelopmentProjectTechniqueActual.ts @@ -2,8 +2,8 @@ import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { Development } from "./Development"; -@Entity("developmentProjectTechnique") -export class DevelopmentProjectTechnique extends EntityBase { +@Entity("developmentProjectTechniqueActual") +export class DevelopmentProjectTechniqueActual extends EntityBase { @Column({ // TRAINING = การอบรม // MEETING = การประชุม @@ -28,12 +28,12 @@ export class DevelopmentProjectTechnique extends EntityBase { @ManyToOne( () => Development, - (development: Development) => development.developmentProjectTechniques, + (development: Development) => development.developmentProjectTechniqueActuals, ) @JoinColumn({ name: "developmentId" }) development: Development; } -export class CreateDevelopmentProjectTechnique { +export class CreateDevelopmentProjectTechniqueActual { @Column() name: number; } diff --git a/src/entities/DevelopmentProjectTechniquePlanned.ts b/src/entities/DevelopmentProjectTechniquePlanned.ts new file mode 100644 index 0000000..bb8d3dc --- /dev/null +++ b/src/entities/DevelopmentProjectTechniquePlanned.ts @@ -0,0 +1,39 @@ +import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Development } from "./Development"; + +@Entity("developmentProjectTechniquePlanned") +export class DevelopmentProjectTechniquePlanned extends EntityBase { + @Column({ + // TRAINING = การอบรม + // MEETING = การประชุม + // SEMINAR = การสัมมนา + // STUDY_TOUR = การศึกษาดูงาน + // ACADEMIC_SEMINAR = การสัมมนาทางวิชาการ + // WORKSHOP = การสัมมนาเชิงปฏิบัติการ + // SPECIAL_LECTURE = การบรรยายพิเศษ + // STUDY_TRAINING = การฝึกศึกษา + nullable: true, + comment: "เทคนิควิธีการที่ใช้ในการพัฒนา", + default: null, + }) + name: string; + + @Column({ + nullable: true, + comment: "โครงการ/หลักสูตรการฝึกอบรม", + default: null, + }) + developmentId: string; + + @ManyToOne( + () => Development, + (development: Development) => development.developmentProjectTechniquePlanneds, + ) + @JoinColumn({ name: "developmentId" }) + development: Development; +} +export class CreateDevelopmentProjectTechniquePlanned { + @Column() + name: number; +} diff --git a/src/entities/DevelopmentScholarship.ts b/src/entities/DevelopmentScholarship.ts index fa3e020..1c850af 100644 --- a/src/entities/DevelopmentScholarship.ts +++ b/src/entities/DevelopmentScholarship.ts @@ -429,6 +429,57 @@ export class DevelopmentScholarship extends EntityBase { default: null, }) totalPeriod: string; + + @Column({ + // ในแผนฯ (INPLAN) + // นอกแผนฯ (OUTPLAN) + nullable: true, + comment: "ในแผนฯ", + length: 40, + default: null, + }) + planType: string; + + @Column({ + comment: "ไม่ใช้งบประมาณ", + default: false, + }) + isNoUseBudget: boolean; + + @Column({ + nullable: true, + type: "datetime", + comment: "กลับเข้ารับราชการตั้งแต่", + default: null, + }) + governmentDate: Date; + + @Column({ + comment: "สำเร็จการศึกษาตามที่หลักสูตรกำหนด", + default: false, + }) + isGraduated: boolean; + + @Column({ + nullable: true, + type: "datetime", + comment: "ตั้งแต่", + default: null, + }) + graduatedDate: Date; + + @Column({ + comment: "เสร็จสิ้นการศึกษาตามที่หลักสูตรกำหนดแล้วแต่ยังไม่สำเร็จการศึกษา", + default: false, + }) + isNoGraduated: boolean; + + @Column({ + nullable: true, + comment: "เนื่องจาก", + default: null, + }) + graduatedReason: string; } export class CreateDevelopmentScholarship { profileId: string | null; @@ -481,6 +532,8 @@ export class CreateDevelopmentScholarship { studyAbroadStartDate: Date | null; studyAbroadEndDate: Date | null; totalPeriod: string | null; + planType: string | null; + isNoUseBudget: boolean | null; } export class UpdateDevelopmentScholarship { @@ -534,4 +587,14 @@ export class UpdateDevelopmentScholarship { studyAbroadStartDate: Date | null; studyAbroadEndDate: Date | null; totalPeriod: string | null; + planType: string | null; + isNoUseBudget: boolean | null; +} + +export class UpdateDevelopmentScholarshipUser { + governmentDate: Date | null; + isGraduated: boolean | null; + graduatedDate: Date | null; + isNoGraduated: boolean | null; + graduatedReason: string | null; } diff --git a/src/migration/1712815316667-add_table_starty1.ts b/src/migration/1712815316667-add_table_starty1.ts new file mode 100644 index 0000000..3a5d95f --- /dev/null +++ b/src/migration/1712815316667-add_table_starty1.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableStarty11712815316667 implements MigrationInterface { + name = 'AddTableStarty11712815316667' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`developmentProjectTechniquePlanned\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`name\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`developmentProjectTechniqueActual\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`name\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` ADD CONSTRAINT \`FK_7166cc94112552ea072a2cc6134\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` ADD CONSTRAINT \`FK_aaaee1c5fb44bef093ed78a0c32\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` DROP FOREIGN KEY \`FK_aaaee1c5fb44bef093ed78a0c32\``); + await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` DROP FOREIGN KEY \`FK_7166cc94112552ea072a2cc6134\``); + await queryRunner.query(`DROP TABLE \`developmentProjectTechniqueActual\``); + await queryRunner.query(`DROP TABLE \`developmentProjectTechniquePlanned\``); + } + +} diff --git a/src/migration/1712824449740-update_table_developmentScholarship_add_planType.ts b/src/migration/1712824449740-update_table_developmentScholarship_add_planType.ts new file mode 100644 index 0000000..e9bce7e --- /dev/null +++ b/src/migration/1712824449740-update_table_developmentScholarship_add_planType.ts @@ -0,0 +1,26 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevelopmentScholarshipAddPlanType1712824449740 implements MigrationInterface { + name = 'UpdateTableDevelopmentScholarshipAddPlanType1712824449740' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`planType\` varchar(40) NULL COMMENT 'ในแผนฯ'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`isNoUseBudget\` tinyint NOT NULL COMMENT 'ไม่ใช้งบประมาณ' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`governmentDate\` datetime NULL COMMENT 'กลับเข้ารับราชการตั้งแต่'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`isGraduated\` tinyint NOT NULL COMMENT 'สำเร็จการศึกษาตามที่หลักสูตรกำหนด' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`graduatedDate\` datetime NULL COMMENT 'ตั้งแต่'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`isNoGraduated\` tinyint NOT NULL COMMENT 'เสร็จสิ้นการศึกษาตามที่หลักสูตรกำหนดแล้วแต่ยังไม่สำเร็จการศึกษา' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`graduatedReason\` varchar(255) NULL COMMENT 'เนื่องจาก'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`graduatedReason\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`isNoGraduated\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`graduatedDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`isGraduated\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`governmentDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`isNoUseBudget\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`planType\``); + } + +} From 371f09c26f5bfb1daa3b59b1044c8bdb66d6184a Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Thu, 11 Apr 2024 18:02:03 +0700 Subject: [PATCH 2/5] =?UTF-8?q?api=20report=20=E0=B8=A3=E0=B8=B2=E0=B8=A2?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9D?= =?UTF-8?q?=E0=B8=B6=E0=B8=81=E0=B8=AD=E0=B8=9A=E0=B8=A3=E0=B8=A1/?= =?UTF-8?q?=E0=B8=94=E0=B8=B9=E0=B8=87=E0=B8=B2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 99 +++++++++++++++++++++++------ 1 file changed, 80 insertions(+), 19 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index f0b976d..dbd5be4 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -25,7 +25,7 @@ import { } from "../entities/DevelopmentHistory"; import { PosType } from "../entities/PosType"; import { PosLevel } from "../entities/PosLevel"; - +import Extension from "../interfaces/extension"; @Route("api/v1/development/report") @Tags("Report") @Security("bearerAuth") @@ -63,18 +63,49 @@ export class ReportController extends Controller { * * @summary DEV_0xx - Report รายการประวัติการฝึกอบรม/ดูงานของข้าราชการกรุงเทพมหานครสามัญ #xx * - * @param {string} type type ประเภท report */ - @Get("history-officer/{type}") - async GetReportDevelopemtHistoryOfficer(@Path() type: string) { - const _type = type.trim().toUpperCase(); - const formattedData = { - org: _type, - }; + @Get("history-officer/{year}") + async GetReportDevelopemtHistoryOfficer(@Query("year") year: number) { + const type = "OFFICER"; + const development = await AppDataSource.getRepository(DevelopmentHistory) + .createQueryBuilder("developmentHistory") + .leftJoinAndSelect("developmentHistory.posLevel", "posLevel") + .leftJoinAndSelect("developmentHistory.posType", "posType") + .leftJoinAndSelect("developmentHistory.development", "development") + .andWhere( + year != 0 && year != null && year != undefined ? "development.year = :year" : "1=1", + { year: year }, + ) + .andWhere("developmentHistory.type = :type", { type: type }) + .select([ + "developmentHistory.citizenId", + "developmentHistory.rank", + "developmentHistory.position", + "developmentHistory.posExecutive", + "developmentHistory.developmentId", + "developmentHistory.prefix", + "developmentHistory.firstName", + "developmentHistory.lastName", + "posLevel.posLevelName", + "posType.posTypeName", + "development.projectName", + ]) + .getMany(); + + const formattedData = development.map((item) => ({ + id: item.id, + citizenId: Extension.ToThaiNumber(item.citizenId.toString()), + fullName: item.prefix + item.firstName + " " + item.lastName, + position: item.position, + posType: item.posType ? item.posType.posTypeName : null, + posLevel: item.posLevel ? item.posLevel.posLevelName : null, + posExecutive: item.posExecutive, + projectName: item.development ? item.development.projectName : null, + })); return new HttpSuccess({ - template: "development", - reportName: "development", + template: "developmentHistoryOfficer", + reportName: "developmentHistoryOfficer", data: { data: formattedData, }, @@ -86,18 +117,48 @@ export class ReportController extends Controller { * * @summary DEV_0xx - Report รายการประวัติฝึกอบรม/ดูงานลูกจ้าง #xx * - * @param {string} type type ประเภท report + * @param {number} year year ปี report */ - @Get("history-employee/{type}") - async GetReportDevelopemtHistoryEmployee(@Path() type: string) { - const _type = type.trim().toUpperCase(); - const formattedData = { - org: _type, - }; + @Get("history-employee/{year}") + async GetReportDevelopemtHistoryEmployee(@Query("year") year: number = 2024) { + const type = "EMPLOYEE"; + const development = await AppDataSource.getRepository(DevelopmentHistory) + .createQueryBuilder("developmentHistory") + .leftJoinAndSelect("developmentHistory.employeePosLevel", "employeePosLevel") + .leftJoinAndSelect("developmentHistory.employeePosType", "employeePosType") + .leftJoinAndSelect("developmentHistory.development", "development") + .where("development.year = :year", { year }) + .andWhere("developmentHistory.type = :type", { type: type }) + .select([ + "developmentHistory.citizenId", + "developmentHistory.position", + "developmentHistory.developmentId", + "developmentHistory.prefix", + "developmentHistory.firstName", + "developmentHistory.lastName", + "employeePosLevel.posLevelName", + "employeePosType.posTypeName", + "employeePosType.posTypeShortName", + "development.projectName", + ]) + .getMany(); + + const formattedData = development.map((item) => ({ + id: item.id, + citizenId: Extension.ToThaiNumber(item.citizenId.toString()), + fullName: item.prefix + item.firstName + " " + item.lastName, + position: item.position, + employeePosType: item.employeePosType ? item.employeePosType.posTypeName : null, + employeePosLevel: + item.employeePosType.posTypeShortName + + " " + + Extension.ToThaiNumber(item.employeePosLevel.posLevelName.toString()), + projectName: item.development ? item.development.projectName : null, + })); return new HttpSuccess({ - template: "development", - reportName: "development", + template: "developmentHistoryEmployee", + reportName: "developmentHistoryEmployee", data: { data: formattedData, }, From 650c6fe3e330d84ab4ddd6473cdd74a34f25fcc2 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Fri, 12 Apr 2024 14:22:44 +0700 Subject: [PATCH 3/5] =?UTF-8?q?=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97?= =?UTF-8?q?=E0=B8=B6=E0=B8=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=A7=E0=B8=A2?= =?UTF-8?q?=E0=B8=87=E0=B8=B2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/DevelopmentController.ts | 44 ++++++++++++++++--- src/entities/Development.ts | 44 +++++++++++++++++++ ...13381-update_table_development_add_root.ts | 16 +++++++ ...ate_table_development_add_rootshortname.ts | 16 +++++++ 4 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 src/migration/1712904313381-update_table_development_add_root.ts create mode 100644 src/migration/1712904744359-update_table_development_add_rootshortname.ts diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index bf63fe5..9981c45 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -799,12 +799,12 @@ export class DevelopmentController extends Controller { @Query() searchField?: "year" | "projectName", @Query() searchKeyword: string = "", ) { - let queryLike = "developer.projectName LIKE :keyword"; + let queryLike = "development.projectName LIKE :keyword"; if (searchField == "year") { - queryLike = "developer.year LIKE :keyword"; + queryLike = "development.year LIKE :keyword"; } const [record, total] = await this.developmentRepository - .createQueryBuilder("developer") + .createQueryBuilder("development") .andWhere( searchKeyword != undefined && searchKeyword != null && searchKeyword != "" ? queryLike @@ -899,6 +899,7 @@ export class DevelopmentController extends Controller { @Query("pageSize") pageSize: number = 10, @Query("year") year: number, @Query("status") status: string, + @Query("root") root?: string | null, @Query("keyword") keyword?: string, ) { const [development, total] = await AppDataSource.getRepository(Development) @@ -906,13 +907,16 @@ export class DevelopmentController extends Controller { .andWhere(year > 0 ? "development.year LIKE :year" : "1=1", { year: `${year.toString()}`, }) + .andWhere(root != undefined && root != null ? "development.root LIKE :root" : "1=1", { + root: `${root}`, + }) .andWhere(status != undefined ? "development.status LIKE :status" : "1=1", { status: `%${status}%`, }) .andWhere(keyword != undefined ? "development.projectName LIKE :keyword" : "1=1", { keyword: `%${keyword}%`, }) - .select(["development.id", "development.projectName", "development.year"]) + .select(["development.id", "development.projectName", "development.year", "development.root"]) .orderBy("development.year", "DESC") .orderBy("development.createdAt", "DESC") .skip((page - 1) * pageSize) @@ -974,7 +978,17 @@ export class DevelopmentController extends Controller { async GetDevelopemtTab1ById(@Path() id: string) { const getDevelopment = await this.developmentRepository.findOne({ where: { id: id }, - select: ["id", "year", "projectName", "reason", "objective"], + select: [ + "id", + "year", + "projectName", + "reason", + "objective", + "root", + "rootId", + "orgRootShortName", + "orgRevisionId", + ], }); if (!getDevelopment) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); @@ -1205,6 +1219,26 @@ export class DevelopmentController extends Controller { return new HttpSuccess(_getDevelopment); } + /** + * API list หน่วยงาน + * + * @summary DEV_00 - list หน่วยงาน # + * + */ + @Get("org/root") + async GetOrgDevelopemt(@Request() request: { user: Record }) { + const getOrg = await this.developmentRepository + .createQueryBuilder("development") + .select("development.root") + .groupBy("development.root") + .getRawMany(); + if (getOrg.length > 0) { + return new HttpSuccess(getOrg.map((x) => x.development_root)); + } + + return new HttpSuccess(getOrg); + } + /** * API upload User * diff --git a/src/entities/Development.ts b/src/entities/Development.ts index 3c1a34e..a708ece 100644 --- a/src/entities/Development.ts +++ b/src/entities/Development.ts @@ -14,6 +14,34 @@ import { DevelopmentProjectTechniqueActual } from "./DevelopmentProjectTechnique @Entity("development") export class Development extends EntityBase { + @Column({ + nullable: true, + comment: "id หน่วยงาน", + default: null, + }) + rootId: string; + + @Column({ + nullable: true, + comment: "ชื่อหน่วยงาน", + default: null, + }) + root: string; + + @Column({ + nullable: true, + comment: "ชื่อย่ิหน่วยงาน", + default: null, + }) + orgRootShortName: string; + + @Column({ + nullable: true, + comment: "id revision", + default: null, + }) + orgRevisionId: string; + @Column({ // กำลังดำเนินการ (ONGOING) // เสร็จสิ้น (FINISH) @@ -380,6 +408,14 @@ export class CreateDevelopment { year: number; @Column() projectName: string; + @Column() + root: string; + @Column() + rootId: string; + @Column() + orgRootShortName: string; + @Column() + orgRevisionId: string; } export class UpdateDevelopment1 { @@ -391,6 +427,14 @@ export class UpdateDevelopment1 { reason: string | null; @Column() objective: string | null; + @Column() + root: string; + @Column() + rootId: string; + @Column() + orgRootShortName: string; + @Column() + orgRevisionId: string; } export class UpdateDevelopment2_1 { @Column() diff --git a/src/migration/1712904313381-update_table_development_add_root.ts b/src/migration/1712904313381-update_table_development_add_root.ts new file mode 100644 index 0000000..1644d26 --- /dev/null +++ b/src/migration/1712904313381-update_table_development_add_root.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevelopmentAddRoot1712904313381 implements MigrationInterface { + name = 'UpdateTableDevelopmentAddRoot1712904313381' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`development\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`root\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`rootId\``); + } + +} diff --git a/src/migration/1712904744359-update_table_development_add_rootshortname.ts b/src/migration/1712904744359-update_table_development_add_rootshortname.ts new file mode 100644 index 0000000..2fa0f19 --- /dev/null +++ b/src/migration/1712904744359-update_table_development_add_rootshortname.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevelopmentAddRootshortname1712904744359 implements MigrationInterface { + name = 'UpdateTableDevelopmentAddRootshortname1712904744359' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`development\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`orgRevisionId\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`orgRootShortName\``); + } + +} From be703f8e3ba50cc3c94c2a12290d6f27deafbcd5 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Sat, 13 Apr 2024 20:47:28 +0700 Subject: [PATCH 4/5] =?UTF-8?q?=E0=B9=82=E0=B8=84=E0=B8=A3=E0=B8=87?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B6=E0=B8=81?= =?UTF-8?q?=E0=B8=A2=E0=B8=B8=E0=B8=97=E0=B8=98=E0=B8=A8=E0=B8=B2=E0=B8=AA?= =?UTF-8?q?=E0=B8=95=E0=B8=A3=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/DevelopmentController.ts | 440 ++++++++++++++++-- .../DevelopmentHistoryController.ts | 59 ++- .../DevelopmentScholarshipController.ts | 2 + src/controllers/ReportController.ts | 131 +++++- src/entities/Development.ts | 131 ++++++ src/entities/DevelopmentHistory.ts | 34 ++ src/entities/DevelopmentScholarship.ts | 46 +- src/entities/StrategyChild1.ts | 6 +- src/entities/StrategyChild2.ts | 12 +- src/entities/StrategyChild3.ts | 10 +- src/entities/StrategyChild4.ts | 8 +- src/entities/StrategyChild5.ts | 9 +- ...ate_table_development_add_strategyChild.ts | 52 +++ ...te_table_development_add_strategyChild1.ts | 22 + ...ate_table_developmentscholar_add_rootid.ts | 20 + ...ble_developmentscholar_date_to_datetime.ts | 32 ++ 16 files changed, 930 insertions(+), 84 deletions(-) create mode 100644 src/migration/1712927871127-update_table_development_add_strategyChild.ts create mode 100644 src/migration/1712930900458-update_table_development_add_strategyChild1.ts create mode 100644 src/migration/1713012352435-update_table_developmentscholar_add_rootid.ts create mode 100644 src/migration/1713014657464-update_table_developmentscholar_date_to_datetime.ts diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 9981c45..50c7ef6 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -11,7 +11,6 @@ import { Path, Request, Query, - Example, } from "tsoa"; import { AppDataSource } from "../database/data-source"; import { In, Not } from "typeorm"; @@ -22,8 +21,6 @@ import { Development, CreateDevelopment, UpdateDevelopment1, - UpdateDevelopment2_1, - UpdateDevelopment2_2, UpdateDevelopment3, UpdateDevelopment4, UpdateDevelopment5, @@ -45,6 +42,11 @@ import { import { DevelopmentAddress } from "../entities/DevelopmentAddress"; import { DevelopmentProjectTechniquePlanned } from "../entities/DevelopmentProjectTechniquePlanned"; import { DevelopmentProjectTechniqueActual } from "../entities/DevelopmentProjectTechniqueActual"; +import { StrategyChild1 } from "../entities/StrategyChild1"; +import { StrategyChild2 } from "../entities/StrategyChild2"; +import { StrategyChild3 } from "../entities/StrategyChild3"; +import { StrategyChild4 } from "../entities/StrategyChild4"; +import { StrategyChild5 } from "../entities/StrategyChild5"; @Route("api/v1/development/main") @Tags("Development") @@ -69,6 +71,11 @@ export class DevelopmentController extends Controller { private provinceRepository = AppDataSource.getRepository(Province); private posTypeRepository = AppDataSource.getRepository(PosType); private posLevelRepository = AppDataSource.getRepository(PosLevel); + private strategyChild1Repository = AppDataSource.getRepository(StrategyChild1); + private strategyChild2Repository = AppDataSource.getRepository(StrategyChild2); + private strategyChild3Repository = AppDataSource.getRepository(StrategyChild3); + private strategyChild4Repository = AppDataSource.getRepository(StrategyChild4); + private strategyChild5Repository = AppDataSource.getRepository(StrategyChild5); /** * API เพิ่มโครงการ/หลักสูตรการฝึกอบรม @@ -97,8 +104,188 @@ export class DevelopmentController extends Controller { " มีอยู่ในระบบแล้ว", ); } - + let _null: any = null; const development = Object.assign(new Development(), requestBody); + switch (requestBody.strategyChildPlannedNode) { + case 1: { + const checkId = await this.strategyChild1Repository.findOne({ + where: { id: requestBody.strategyChildPlannedId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 1", + ); + } + development.strategyChild1PlannedId = checkId.id; + development.strategyChild2ActualId = _null; + development.strategyChild3ActualId = _null; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 2: { + const checkId = await this.strategyChild2Repository.findOne({ + where: { id: requestBody.strategyChildPlannedId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2", + ); + } + development.strategyChild1PlannedId = checkId.strategyChild1Id; + development.strategyChild2PlannedId = checkId.id; + development.strategyChild3ActualId = _null; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 3: { + const checkId = await this.strategyChild3Repository.findOne({ + where: { id: requestBody.strategyChildPlannedId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2", + ); + } + development.strategyChild1PlannedId = checkId.strategyChild1Id; + development.strategyChild2PlannedId = checkId.strategyChild2Id; + development.strategyChild3PlannedId = checkId.id; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 4: { + const checkId = await this.strategyChild4Repository.findOne({ + where: { id: requestBody.strategyChildPlannedId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 3", + ); + } + development.strategyChild1PlannedId = checkId.strategyChild1Id; + development.strategyChild2PlannedId = checkId.strategyChild2Id; + development.strategyChild3PlannedId = checkId.strategyChild3Id; + development.strategyChild4PlannedId = checkId.id; + development.strategyChild5ActualId = _null; + break; + } + case 5: { + const checkId = await this.strategyChild5Repository.findOne({ + where: { id: requestBody.strategyChildPlannedId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2", + ); + } + development.strategyChild1PlannedId = checkId.strategyChild1Id; + development.strategyChild2PlannedId = checkId.strategyChild2Id; + development.strategyChild3PlannedId = checkId.strategyChild3Id; + development.strategyChild4PlannedId = checkId.strategyChild4Id; + development.strategyChild5PlannedId = checkId.id; + break; + } + + default: + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผน"); + } + switch (requestBody.strategyChildActualNode) { + case 1: { + const checkId = await this.strategyChild1Repository.findOne({ + where: { id: requestBody.strategyChildActualId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 1", + ); + } + development.strategyChild1ActualId = checkId.id; + development.strategyChild2ActualId = _null; + development.strategyChild3ActualId = _null; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 2: { + const checkId = await this.strategyChild2Repository.findOne({ + where: { id: requestBody.strategyChildActualId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 2", + ); + } + development.strategyChild1ActualId = checkId.strategyChild1Id; + development.strategyChild2ActualId = checkId.id; + development.strategyChild3ActualId = _null; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 3: { + const checkId = await this.strategyChild3Repository.findOne({ + where: { id: requestBody.strategyChildActualId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 3", + ); + } + development.strategyChild1ActualId = checkId.strategyChild1Id; + development.strategyChild2ActualId = checkId.strategyChild2Id; + development.strategyChild3ActualId = checkId.id; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 4: { + const checkId = await this.strategyChild4Repository.findOne({ + where: { id: requestBody.strategyChildActualId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 4", + ); + } + development.strategyChild1ActualId = checkId.strategyChild1Id; + development.strategyChild2ActualId = checkId.strategyChild2Id; + development.strategyChild3ActualId = checkId.strategyChild3Id; + development.strategyChild4ActualId = checkId.id; + development.strategyChild5ActualId = _null; + break; + } + case 5: { + const checkId = await this.strategyChild5Repository.findOne({ + where: { id: requestBody.strategyChildActualId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 5", + ); + } + development.strategyChild1ActualId = checkId.strategyChild1Id; + development.strategyChild2ActualId = checkId.strategyChild2Id; + development.strategyChild3ActualId = checkId.strategyChild3Id; + development.strategyChild4ActualId = checkId.strategyChild4Id; + development.strategyChild5ActualId = checkId.id; + break; + } + + default: + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริง"); + } development.createdUserId = request.user.sub; development.createdFullName = request.user.name; development.lastUpdateUserId = request.user.sub; @@ -143,6 +330,187 @@ export class DevelopmentController extends Controller { " มีอยู่ในระบบแล้ว", ); } + let _null: any = null; + switch (requestBody.strategyChildPlannedNode) { + case 1: { + const checkId = await this.strategyChild1Repository.findOne({ + where: { id: requestBody.strategyChildPlannedId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 1", + ); + } + development.strategyChild1PlannedId = checkId.id; + development.strategyChild2ActualId = _null; + development.strategyChild3ActualId = _null; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 2: { + const checkId = await this.strategyChild2Repository.findOne({ + where: { id: requestBody.strategyChildPlannedId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2", + ); + } + development.strategyChild1PlannedId = checkId.strategyChild1Id; + development.strategyChild2PlannedId = checkId.id; + development.strategyChild3ActualId = _null; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 3: { + const checkId = await this.strategyChild3Repository.findOne({ + where: { id: requestBody.strategyChildPlannedId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2", + ); + } + development.strategyChild1PlannedId = checkId.strategyChild1Id; + development.strategyChild2PlannedId = checkId.strategyChild2Id; + development.strategyChild3PlannedId = checkId.id; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 4: { + const checkId = await this.strategyChild4Repository.findOne({ + where: { id: requestBody.strategyChildPlannedId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 3", + ); + } + development.strategyChild1PlannedId = checkId.strategyChild1Id; + development.strategyChild2PlannedId = checkId.strategyChild2Id; + development.strategyChild3PlannedId = checkId.strategyChild3Id; + development.strategyChild4PlannedId = checkId.id; + development.strategyChild5ActualId = _null; + break; + } + case 5: { + const checkId = await this.strategyChild5Repository.findOne({ + where: { id: requestBody.strategyChildPlannedId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2", + ); + } + development.strategyChild1PlannedId = checkId.strategyChild1Id; + development.strategyChild2PlannedId = checkId.strategyChild2Id; + development.strategyChild3PlannedId = checkId.strategyChild3Id; + development.strategyChild4PlannedId = checkId.strategyChild4Id; + development.strategyChild5PlannedId = checkId.id; + break; + } + + default: + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผน"); + } + switch (requestBody.strategyChildActualNode) { + case 1: { + const checkId = await this.strategyChild1Repository.findOne({ + where: { id: requestBody.strategyChildActualId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 1", + ); + } + development.strategyChild1ActualId = checkId.id; + development.strategyChild2ActualId = _null; + development.strategyChild3ActualId = _null; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 2: { + const checkId = await this.strategyChild2Repository.findOne({ + where: { id: requestBody.strategyChildActualId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 2", + ); + } + development.strategyChild1ActualId = checkId.strategyChild1Id; + development.strategyChild2ActualId = checkId.id; + development.strategyChild3ActualId = _null; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 3: { + const checkId = await this.strategyChild3Repository.findOne({ + where: { id: requestBody.strategyChildActualId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 3", + ); + } + development.strategyChild1ActualId = checkId.strategyChild1Id; + development.strategyChild2ActualId = checkId.strategyChild2Id; + development.strategyChild3ActualId = checkId.id; + development.strategyChild4ActualId = _null; + development.strategyChild5ActualId = _null; + break; + } + case 4: { + const checkId = await this.strategyChild4Repository.findOne({ + where: { id: requestBody.strategyChildActualId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 4", + ); + } + development.strategyChild1ActualId = checkId.strategyChild1Id; + development.strategyChild2ActualId = checkId.strategyChild2Id; + development.strategyChild3ActualId = checkId.strategyChild3Id; + development.strategyChild4ActualId = checkId.id; + development.strategyChild5ActualId = _null; + break; + } + case 5: { + const checkId = await this.strategyChild5Repository.findOne({ + where: { id: requestBody.strategyChildActualId }, + }); + if (!checkId) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 5", + ); + } + development.strategyChild1ActualId = checkId.strategyChild1Id; + development.strategyChild2ActualId = checkId.strategyChild2Id; + development.strategyChild3ActualId = checkId.strategyChild3Id; + development.strategyChild4ActualId = checkId.strategyChild4Id; + development.strategyChild5ActualId = checkId.id; + break; + } + + default: + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริง"); + } Object.assign(development, requestBody); development.lastUpdateUserId = request.user.sub; development.lastUpdateFullName = request.user.name; @@ -988,6 +1356,16 @@ export class DevelopmentController extends Controller { "rootId", "orgRootShortName", "orgRevisionId", + "strategyChild1Planned", + "strategyChild2Planned", + "strategyChild3Planned", + "strategyChild4Planned", + "strategyChild5Planned", + "strategyChild1Actual", + "strategyChild2Actual", + "strategyChild3Actual", + "strategyChild4Actual", + "strategyChild5Actual", ], }); if (!getDevelopment) { @@ -1191,31 +1569,37 @@ export class DevelopmentController extends Controller { */ @Get("tab6/{id}") async GetDevelopemtTab6ById(@Path() id: string) { - const getDevelopment = await this.developmentRepository.findOne({ - where: { id: id }, - relations: [ - "developmentActualPeoples", - "developmentPlannedPeoples", - "developmentActualGoals", - "developmentPlannedGoals", - "developmentPlannedGoals.plannedGoalPositions", - "provinces", - // "provinces.developmentProvinces", - ], + const getDevelopment = await this.developmentHistoryRepository.find({ + where: { developmentId: id }, + relations: ["posLevel", "posType", "employeePosLevel", "employeePosType"], }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - let _getDevelopment: any = getDevelopment; - _getDevelopment.actualPeoples = getDevelopment.developmentActualPeoples; - _getDevelopment.plannedPeoples = getDevelopment.developmentPlannedPeoples; - _getDevelopment.actualGoals = getDevelopment.developmentActualGoals; - _getDevelopment.plannedGoals = getDevelopment.developmentPlannedGoals; - // _getDevelopment.provinces = getDevelopment.provinces.map(x=>x.developmentProvinces); - delete _getDevelopment.developmentActualPeoples; - delete _getDevelopment.developmentPlannedPeoples; - delete _getDevelopment.developmentActualGoals; - delete _getDevelopment.developmentPlannedGoals; + const _getDevelopment = getDevelopment.map((item) => ({ + id: item.id, + citizenId: item.citizenId, + fullName: item.prefix + item.firstName + " " + item.lastName, + position: item.position, + posType: + item.type == "OFFICER" + ? item.posType + ? item.posType.posTypeName + : null + : item.employeePosType + ? item.employeePosType.posTypeName + : null, + posLevel: + item.type == "OFFICER" + ? item.posLevel + ? item.posLevel.posLevelName + : null + : item.employeePosLevel + ? item.employeePosLevel.posLevelName + : null, + posExecutive: item.posExecutive, + root: item.root, + order: item.order, + dateOrder: item.dateOrder, + isDone: item.isDone, + })); return new HttpSuccess(_getDevelopment); } diff --git a/src/controllers/DevelopmentHistoryController.ts b/src/controllers/DevelopmentHistoryController.ts index eb5055e..787c300 100644 --- a/src/controllers/DevelopmentHistoryController.ts +++ b/src/controllers/DevelopmentHistoryController.ts @@ -185,6 +185,7 @@ export class DevelopmentOfficerHistoryController extends Controller { @Query("pageSize") pageSize: number = 10, @Query("keyword") keyword?: string, @Query("year") year?: number, + @Query("root") root?: number, ) { const type = "OFFICER"; const [development, total] = await AppDataSource.getRepository(DevelopmentHistory) @@ -192,14 +193,18 @@ export class DevelopmentOfficerHistoryController extends Controller { .leftJoinAndSelect("developmentHistory.development", "development") .leftJoinAndSelect("developmentHistory.posLevel", "posLevel") .leftJoinAndSelect("developmentHistory.posType", "posType") - .andWhere(year != 0 && year != null && year != undefined ? "development.year = :year" : "1=1", { year: year }) + .andWhere( + year != 0 && year != null && year != undefined ? "development.year = :year" : "1=1", + { year: year }, + ) + .andWhere(root != null && root != undefined ? "development.root = :root" : "1=1", { + root: root, + }) .andWhere("developmentHistory.type = :type", { type: type }) .andWhere( new Brackets((qb) => { qb.where( - keyword != null && keyword != "" - ? "developmentHistory.prefix LIKE :keyword" - : "1=1", + keyword != null && keyword != "" ? "developmentHistory.prefix LIKE :keyword" : "1=1", { keyword: `%${keyword}%`, }, @@ -237,25 +242,19 @@ export class DevelopmentOfficerHistoryController extends Controller { }, ) .orWhere( - keyword != null && keyword != "" - ? "development.projectName LIKE :keyword" - : "1=1", + keyword != null && keyword != "" ? "development.projectName LIKE :keyword" : "1=1", { keyword: `%${keyword}%`, }, ) .orWhere( - keyword != null && keyword != "" - ? "posType.posTypeName LIKE :keyword" - : "1=1", + keyword != null && keyword != "" ? "posType.posTypeName LIKE :keyword" : "1=1", { keyword: `%${keyword}%`, }, ) .orWhere( - keyword != null && keyword != "" - ? "posLevel.posLevelName LIKE :keyword" - : "1=1", + keyword != null && keyword != "" ? "posLevel.posLevelName LIKE :keyword" : "1=1", { keyword: `%${keyword}%`, }, @@ -266,10 +265,10 @@ export class DevelopmentOfficerHistoryController extends Controller { .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); - const formattedData = development.map(item => ({ + const formattedData = development.map((item) => ({ id: item.id, citizenId: item.citizenId, - fullName: item.prefix+item.firstName+" "+item.lastName, + fullName: item.prefix + item.firstName + " " + item.lastName, position: item.position, posType: item.posType ? item.posType.posTypeName : null, posLevel: item.posLevel ? item.posLevel.posLevelName : null, @@ -287,11 +286,11 @@ export class DevelopmentOfficerHistoryController extends Controller { * * @param {string} id Id โครงการ */ - @Get("{id}") + @Get("{id}") async GetDevelopemtHistoryById(@Path() id: string) { const type = "OFFICER"; const getDevelopment = await this.developmentHistoryRepository.findOne({ - relations: ["development","posLevel","posType"], + relations: ["development", "posLevel", "posType"], where: { id: id, type: type }, }); if (!getDevelopment) { @@ -306,7 +305,9 @@ export class DevelopmentOfficerHistoryController extends Controller { citizenId: getDevelopment.citizenId ? getDevelopment.citizenId : null, position: getDevelopment.position ? getDevelopment.position : null, posLevelId: getDevelopment.posLevelId ? getDevelopment.posLevelId : null, - posLevelName: getDevelopment.posLevel.posLevelName ? getDevelopment.posLevel.posLevelName : null, + posLevelName: getDevelopment.posLevel.posLevelName + ? getDevelopment.posLevel.posLevelName + : null, posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null, posTypeName: getDevelopment.posType.posTypeName ? getDevelopment.posType.posTypeName : null, posExecutive: getDevelopment.posExecutive ? getDevelopment.posExecutive : null, @@ -314,17 +315,27 @@ export class DevelopmentOfficerHistoryController extends Controller { order: getDevelopment.order ? getDevelopment.order : null, dateOrder: getDevelopment.dateOrder ? getDevelopment.dateOrder : null, year: getDevelopment.development.year ? getDevelopment.development.year : null, - projectName: getDevelopment.development.projectName ? getDevelopment.development.projectName : null, + projectName: getDevelopment.development.projectName + ? getDevelopment.development.projectName + : null, dateStart: getDevelopment.development.dateStart ? getDevelopment.development.dateStart : null, dateEnd: getDevelopment.development.dateEnd ? getDevelopment.development.dateEnd : null, totalDate: getDevelopment.development.totalDate ? getDevelopment.development.totalDate : null, - addressAcademic: getDevelopment.development.addressAcademic ? getDevelopment.development.addressAcademic : null, - topicAcademic: getDevelopment.development.topicAcademic ? getDevelopment.development.topicAcademic : null, - dateStudyStart: getDevelopment.development.dateStudyStart ? getDevelopment.development.dateStudyStart : null, - dateStudyEnd: getDevelopment.development.dateStudyEnd ? getDevelopment.development.dateStudyEnd : null, + addressAcademic: getDevelopment.development.addressAcademic + ? getDevelopment.development.addressAcademic + : null, + topicAcademic: getDevelopment.development.topicAcademic + ? getDevelopment.development.topicAcademic + : null, + dateStudyStart: getDevelopment.development.dateStudyStart + ? getDevelopment.development.dateStudyStart + : null, + dateStudyEnd: getDevelopment.development.dateStudyEnd + ? getDevelopment.development.dateStudyEnd + : null, org: null, }; - + return new HttpSuccess(formattedData); } } diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index f305148..520135e 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -238,6 +238,7 @@ export class DevelopmentScholarshipController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); } const formattedData = { + root: getDevelopment.root ? getDevelopment.root : null, rank: getDevelopment.rank ? getDevelopment.rank : null, prefix: getDevelopment.prefix ? getDevelopment.prefix : null, firstName: getDevelopment.firstName ? getDevelopment.firstName : null, @@ -364,6 +365,7 @@ export class DevelopmentScholarshipController extends Controller { "graduatedDate", "isNoGraduated", "graduatedReason", + "root", ], }); if (!getDevelopment) { diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index dbd5be4..29a8c0d 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -26,6 +26,7 @@ import { import { PosType } from "../entities/PosType"; import { PosLevel } from "../entities/PosLevel"; import Extension from "../interfaces/extension"; +import { DevelopmentScholarship } from "../entities/DevelopmentScholarship"; @Route("api/v1/development/report") @Tags("Report") @Security("bearerAuth") @@ -34,6 +35,7 @@ export class ReportController extends Controller { private developmentRepository = AppDataSource.getRepository(Development); private posTypeRepository = AppDataSource.getRepository(PosType); private posLevelRepository = AppDataSource.getRepository(PosLevel); + private developmentScholarshipRepository = AppDataSource.getRepository(DevelopmentScholarship); /** * API Report รายการโครงการ/หลักสูตรการฝึกอบรมที่หน่วยงานของกรุงเทพมหานครเป็นผู้จัด @@ -64,19 +66,26 @@ export class ReportController extends Controller { * @summary DEV_0xx - Report รายการประวัติการฝึกอบรม/ดูงานของข้าราชการกรุงเทพมหานครสามัญ #xx * */ - @Get("history-officer/{year}") - async GetReportDevelopemtHistoryOfficer(@Query("year") year: number) { - const type = "OFFICER"; + @Post("history-officer") + async PostReportDevelopemtHistoryOfficer( + @Body() + body: { + year: number; + root: string; + }, + ) { const development = await AppDataSource.getRepository(DevelopmentHistory) .createQueryBuilder("developmentHistory") .leftJoinAndSelect("developmentHistory.posLevel", "posLevel") .leftJoinAndSelect("developmentHistory.posType", "posType") .leftJoinAndSelect("developmentHistory.development", "development") - .andWhere( - year != 0 && year != null && year != undefined ? "development.year = :year" : "1=1", - { year: year }, - ) - .andWhere("developmentHistory.type = :type", { type: type }) + .andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", { + year: body.year, + }) + .andWhere(body.root != null ? "development.root = :root" : "1=1", { + root: body.root, + }) + .andWhere("developmentHistory.type = :type", { type: "OFFICER" }) .select([ "developmentHistory.citizenId", "developmentHistory.rank", @@ -89,6 +98,7 @@ export class ReportController extends Controller { "posLevel.posLevelName", "posType.posTypeName", "development.projectName", + "development.root", ]) .getMany(); @@ -101,6 +111,7 @@ export class ReportController extends Controller { posLevel: item.posLevel ? item.posLevel.posLevelName : null, posExecutive: item.posExecutive, projectName: item.development ? item.development.projectName : null, + root: item.root, })); return new HttpSuccess({ @@ -119,16 +130,26 @@ export class ReportController extends Controller { * * @param {number} year year ปี report */ - @Get("history-employee/{year}") - async GetReportDevelopemtHistoryEmployee(@Query("year") year: number = 2024) { - const type = "EMPLOYEE"; + @Post("history-employee") + async PostReportDevelopemtHistoryEmployee( + @Body() + body: { + year: number; + root: string; + }, + ) { const development = await AppDataSource.getRepository(DevelopmentHistory) .createQueryBuilder("developmentHistory") .leftJoinAndSelect("developmentHistory.employeePosLevel", "employeePosLevel") .leftJoinAndSelect("developmentHistory.employeePosType", "employeePosType") .leftJoinAndSelect("developmentHistory.development", "development") - .where("development.year = :year", { year }) - .andWhere("developmentHistory.type = :type", { type: type }) + .andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", { + year: body.year, + }) + .andWhere(body.root != null ? "development.root = :root" : "1=1", { + root: body.root, + }) + .andWhere("developmentHistory.type = :type", { type: "EMPLOYEE" }) .select([ "developmentHistory.citizenId", "developmentHistory.position", @@ -140,6 +161,7 @@ export class ReportController extends Controller { "employeePosType.posTypeName", "employeePosType.posTypeShortName", "development.projectName", + "development.root", ]) .getMany(); @@ -154,6 +176,7 @@ export class ReportController extends Controller { " " + Extension.ToThaiNumber(item.employeePosLevel.posLevelName.toString()), projectName: item.development ? item.development.projectName : null, + root: item.root, })); return new HttpSuccess({ @@ -185,4 +208,86 @@ export class ReportController extends Controller { }, }); } + + /** + * API Report ข้าราชการฯที่ได้รับทุนการศึกษา/ฝึกอบรมใน detail + * + * @summary DEV_0xx - Report ข้าราชการฯที่ได้รับทุนการศึกษา/ฝึกอบรมใน detail #xx + * + * @param {string} id Id scholarship + */ + @Get("scholarship/{id}") + async GetReportDevelopemtScholarshipDetail(@Path() id: string) { + const getDevelopment = await this.developmentScholarshipRepository.findOne({ + where: { id: id }, + }); + if (!getDevelopment) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); + } + if (getDevelopment.scholarshipType != null) { + switch (getDevelopment.scholarshipType.trim().toUpperCase()) { + case "DOMESTICE": + getDevelopment.scholarshipType = "การศึกษาในประเทศ"; + break; + case "NOABROAD": + getDevelopment.scholarshipType = + "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)"; + break; + case "ABROAD": + getDevelopment.scholarshipType = + "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)"; + break; + case "EXECUTIVE": + getDevelopment.scholarshipType = + "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร)"; + break; + default: + break; + } + } + + const formattedData = { + id: getDevelopment.id, + firstName: getDevelopment.firstName, + lastName: getDevelopment.lastName, + position: getDevelopment.position, + root: getDevelopment.root, + degreeLevel: getDevelopment.degreeLevel, + course: getDevelopment.course, + field: getDevelopment.field, + studyPlace: getDevelopment.studyPlace, + scholarshipType: getDevelopment.scholarshipType, + startDate: + getDevelopment.startDate == null + ? "" + : Extension.ToThaiNumber(Extension.ToThaiFullDate(getDevelopment.startDate)), + endDate: + getDevelopment.endDate == null + ? "" + : Extension.ToThaiNumber(Extension.ToThaiFullDate(getDevelopment.endDate)), + reportBackNo: + getDevelopment.reportBackNo == null + ? "" + : Extension.ToThaiNumber(getDevelopment.reportBackNo), + reportBackNoDate: + getDevelopment.reportBackNoDate == null + ? "" + : Extension.ToThaiNumber(Extension.ToThaiFullDate(getDevelopment.reportBackNoDate)), + governmentDate: + getDevelopment.governmentDate == null + ? "" + : Extension.ToThaiNumber(Extension.ToThaiFullDate(getDevelopment.governmentDate)), + graduatedDate: + getDevelopment.graduatedDate == null + ? "" + : Extension.ToThaiNumber(Extension.ToThaiFullDate(getDevelopment.graduatedDate)), + graduatedReason: getDevelopment.graduatedReason, + }; + + return new HttpSuccess({ + template: "repatriation", + reportName: "repatriation", + data: formattedData, + }); + } } diff --git a/src/entities/Development.ts b/src/entities/Development.ts index a708ece..dbbd06d 100644 --- a/src/entities/Development.ts +++ b/src/entities/Development.ts @@ -11,6 +11,11 @@ import { DevelopmentProjectTechniquePlanned } from "./DevelopmentProjectTechniqu import { CreateDevelopmentEvaluation, DevelopmentEvaluation } from "./DevelopmentEvaluation"; import { CreateDevelopmentAddress, DevelopmentAddress } from "./DevelopmentAddress"; import { DevelopmentProjectTechniqueActual } from "./DevelopmentProjectTechniqueActual"; +import { StrategyChild5 } from "./StrategyChild5"; +import { StrategyChild4 } from "./StrategyChild4"; +import { StrategyChild3 } from "./StrategyChild3"; +import { StrategyChild2 } from "./StrategyChild2"; +import { StrategyChild1 } from "./StrategyChild1"; @Entity("development") export class Development extends EntityBase { @@ -402,6 +407,116 @@ export class Development extends EntityBase { (developmentHistory: DevelopmentHistory) => developmentHistory.development, ) developmentHistorys: DevelopmentHistory[]; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามแผน", + default: null, + }) + strategyChild1PlannedId: string; + @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.developmentPlanneds) + @JoinColumn({ name: "strategyChild1PlannedId" }) + strategyChild1Planned: StrategyChild1; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามแผน", + default: null, + }) + strategyChild2PlannedId: string; + @ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.developmentPlanneds) + @JoinColumn({ name: "strategyChild2PlannedId" }) + strategyChild2Planned: StrategyChild2; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามแผน", + default: null, + }) + strategyChild3PlannedId: string; + @ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.developmentPlanneds) + @JoinColumn({ name: "strategyChild3PlannedId" }) + strategyChild3Planned: StrategyChild3; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามแผน", + default: null, + }) + strategyChild4PlannedId: string; + @ManyToOne(() => StrategyChild4, (strategyChild4) => strategyChild4.developmentPlanneds) + @JoinColumn({ name: "strategyChild4PlannedId" }) + strategyChild4Planned: StrategyChild4; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามแผน", + default: null, + }) + strategyChild5PlannedId: string; + @ManyToOne(() => StrategyChild5, (strategyChild5) => strategyChild5.developmentPlanneds) + @JoinColumn({ name: "strategyChild5PlannedId" }) + strategyChild5Planned: StrategyChild5; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามจริง", + default: null, + }) + strategyChild1ActualId: string; + @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.developmentActuals) + @JoinColumn({ name: "strategyChild1ActualId" }) + strategyChild1Actual: StrategyChild1; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามจริง", + default: null, + }) + strategyChild2ActualId: string; + @ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.developmentActuals) + @JoinColumn({ name: "strategyChild2ActualId" }) + strategyChild2Actual: StrategyChild2; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามจริง", + default: null, + }) + strategyChild3ActualId: string; + @ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.developmentActuals) + @JoinColumn({ name: "strategyChild3ActualId" }) + strategyChild3Actual: StrategyChild3; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามจริง", + default: null, + }) + strategyChild4ActualId: string; + @ManyToOne(() => StrategyChild4, (strategyChild4) => strategyChild4.developmentActuals) + @JoinColumn({ name: "strategyChild4ActualId" }) + strategyChild4Actual: StrategyChild4; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามจริง", + default: null, + }) + strategyChild5ActualId: string; + @ManyToOne(() => StrategyChild5, (strategyChild5) => strategyChild5.developmentActuals) + @JoinColumn({ name: "strategyChild5ActualId" }) + strategyChild5Actual: StrategyChild5; } export class CreateDevelopment { @Column() @@ -416,6 +531,14 @@ export class CreateDevelopment { orgRootShortName: string; @Column() orgRevisionId: string; + @Column() + strategyChildPlannedId: string; + @Column() + strategyChildPlannedNode: number; + @Column() + strategyChildActualId: string; + @Column() + strategyChildActualNode: number; } export class UpdateDevelopment1 { @@ -435,6 +558,14 @@ export class UpdateDevelopment1 { orgRootShortName: string; @Column() orgRevisionId: string; + @Column() + strategyChildPlannedId: string; + @Column() + strategyChildPlannedNode: number; + @Column() + strategyChildActualId: string; + @Column() + strategyChildActualNode: number; } export class UpdateDevelopment2_1 { @Column() diff --git a/src/entities/DevelopmentHistory.ts b/src/entities/DevelopmentHistory.ts index e8a25db..6e2ebca 100644 --- a/src/entities/DevelopmentHistory.ts +++ b/src/entities/DevelopmentHistory.ts @@ -8,6 +8,34 @@ import { EmployeePosLevel } from "./EmployeePosLevel"; @Entity("developmentHistory") export class DevelopmentHistory extends EntityBase { + @Column({ + nullable: true, + comment: "id หน่วยงาน", + default: null, + }) + rootId: string; + + @Column({ + nullable: true, + comment: "ชื่อหน่วยงาน", + default: null, + }) + root: string; + + @Column({ + nullable: true, + comment: "ชื่อย่ิหน่วยงาน", + default: null, + }) + orgRootShortName: string; + + @Column({ + nullable: true, + comment: "id revision", + default: null, + }) + orgRevisionId: string; + @Column({ nullable: true, comment: "ประเภทราชการ", @@ -142,6 +170,12 @@ export class DevelopmentHistory extends EntityBase { default: null, }) dateOrder: Date; + + @Column({ + comment: "บันทึกลงทะเบียนประวัติ", + default: false, + }) + isDone: boolean; } export class CreateDevelopmentHistory { @Column() diff --git a/src/entities/DevelopmentScholarship.ts b/src/entities/DevelopmentScholarship.ts index 1c850af..7ad4156 100644 --- a/src/entities/DevelopmentScholarship.ts +++ b/src/entities/DevelopmentScholarship.ts @@ -5,6 +5,34 @@ import { PosType } from "./PosType"; @Entity("developmentScholarship") export class DevelopmentScholarship extends EntityBase { + @Column({ + nullable: true, + comment: "id หน่วยงาน", + default: null, + }) + rootId: string; + + @Column({ + nullable: true, + comment: "ชื่อหน่วยงาน", + default: null, + }) + root: string; + + @Column({ + nullable: true, + comment: "ชื่อย่อหน่วยงาน", + default: null, + }) + orgRootShortName: string; + + @Column({ + nullable: true, + comment: "id revision", + default: null, + }) + orgRevisionId: string; + @Column({ nullable: true, comment: "id profile", @@ -213,7 +241,7 @@ export class DevelopmentScholarship extends EntityBase { @Column({ nullable: true, - type: "date", + type: "datetime", comment: "ลงวันที่(หนังสือ)", default: null, }) @@ -221,7 +249,7 @@ export class DevelopmentScholarship extends EntityBase { @Column({ nullable: true, - type: "date", + type: "datetime", comment: "หนังสืออนุมัติเมื่อวันที่", default: null, }) @@ -272,7 +300,7 @@ export class DevelopmentScholarship extends EntityBase { @Column({ nullable: true, - type: "date", + type: "datetime", comment: "ลงวันที่(เลขที่สัญญา)", default: null, }) @@ -288,7 +316,7 @@ export class DevelopmentScholarship extends EntityBase { @Column({ nullable: true, - type: "date", + type: "datetime", comment: "ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)", default: null, }) @@ -296,7 +324,7 @@ export class DevelopmentScholarship extends EntityBase { @Column({ nullable: true, - type: "date", + type: "datetime", comment: "รายงานตัวกลับวันที่", default: null, }) @@ -482,6 +510,10 @@ export class DevelopmentScholarship extends EntityBase { graduatedReason: string; } export class CreateDevelopmentScholarship { + rootId: string | null; + root: string | null; + orgRootShortName: string | null; + orgRevisionId: string | null; profileId: string | null; rank?: string | null; prefix: string | null; @@ -537,6 +569,10 @@ export class CreateDevelopmentScholarship { } export class UpdateDevelopmentScholarship { + rootId: string | null; + root: string | null; + orgRootShortName: string | null; + orgRevisionId: string | null; profileId: string | null; rank?: string | null; prefix: string | null; diff --git a/src/entities/StrategyChild1.ts b/src/entities/StrategyChild1.ts index 0cd0ab4..05c56ea 100644 --- a/src/entities/StrategyChild1.ts +++ b/src/entities/StrategyChild1.ts @@ -4,7 +4,7 @@ import { StrategyChild2 } from "./StrategyChild2"; import { StrategyChild3 } from "./StrategyChild3"; import { StrategyChild4 } from "./StrategyChild4"; import { StrategyChild5 } from "./StrategyChild5"; - +import { Development } from "./Development"; @Entity("strategyChild1") export class StrategyChild1 extends EntityBase { @@ -28,6 +28,10 @@ export class StrategyChild1 extends EntityBase { @OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild1) strategyChild5s: StrategyChild5[]; + @OneToMany(() => Development, (development) => development.strategyChild1Planned) + developmentPlanneds: Development[]; + @OneToMany(() => Development, (development) => development.strategyChild1Actual) + developmentActuals: Development[]; } export class CreateStrategyChild1 { diff --git a/src/entities/StrategyChild2.ts b/src/entities/StrategyChild2.ts index fbc74ef..9425e59 100644 --- a/src/entities/StrategyChild2.ts +++ b/src/entities/StrategyChild2.ts @@ -4,7 +4,7 @@ import { StrategyChild1 } from "./StrategyChild1"; import { StrategyChild3 } from "./StrategyChild3"; import { StrategyChild4 } from "./StrategyChild4"; import { StrategyChild5 } from "./StrategyChild5"; - +import { Development } from "./Development"; @Entity("strategyChild2") export class StrategyChild2 extends EntityBase { @@ -21,7 +21,7 @@ export class StrategyChild2 extends EntityBase { comment: "คีย์นอก(FK)ของตาราง strategyChild1", }) strategyChild1Id: string; - + @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild2s) @JoinColumn({ name: "strategyChild1Id" }) strategyChild1: StrategyChild1; @@ -35,9 +35,11 @@ export class StrategyChild2 extends EntityBase { @OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild2) strategyChild5s: StrategyChild5[]; - - -} + @OneToMany(() => Development, (development) => development.strategyChild2Planned) + developmentPlanneds: Development[]; + @OneToMany(() => Development, (development) => development.strategyChild2Actual) + developmentActuals: Development[]; +} export class CreateStrategyChild2 { @Column() diff --git a/src/entities/StrategyChild3.ts b/src/entities/StrategyChild3.ts index 2166902..9698d0c 100644 --- a/src/entities/StrategyChild3.ts +++ b/src/entities/StrategyChild3.ts @@ -4,7 +4,7 @@ import { StrategyChild1 } from "./StrategyChild1"; import { StrategyChild2 } from "./StrategyChild2"; import { StrategyChild4 } from "./StrategyChild4"; import { StrategyChild5 } from "./StrategyChild5"; - +import { Development } from "./Development"; @Entity("strategyChild3") export class StrategyChild3 extends EntityBase { @@ -42,12 +42,16 @@ export class StrategyChild3 extends EntityBase { @OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild3) strategyChild5s: StrategyChild5[]; -} + @OneToMany(() => Development, (development) => development.strategyChild3Planned) + developmentPlanneds: Development[]; + @OneToMany(() => Development, (development) => development.strategyChild3Actual) + developmentActuals: Development[]; +} export class CreateStrategyChild3 { @Column() strategyChild3Name: string; - + @Column("uuid") strategyChild2Id: string; } diff --git a/src/entities/StrategyChild4.ts b/src/entities/StrategyChild4.ts index 290fd85..4382a0c 100644 --- a/src/entities/StrategyChild4.ts +++ b/src/entities/StrategyChild4.ts @@ -4,7 +4,7 @@ import { StrategyChild1 } from "./StrategyChild1"; import { StrategyChild2 } from "./StrategyChild2"; import { StrategyChild3 } from "./StrategyChild3"; import { StrategyChild5 } from "./StrategyChild5"; - +import { Development } from "./Development"; @Entity("strategyChild4") export class StrategyChild4 extends EntityBase { @@ -48,8 +48,12 @@ export class StrategyChild4 extends EntityBase { @OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild4) strategyChild5s: StrategyChild5[]; -} + @OneToMany(() => Development, (development) => development.strategyChild4Planned) + developmentPlanneds: Development[]; + @OneToMany(() => Development, (development) => development.strategyChild4Actual) + developmentActuals: Development[]; +} export class CreateStrategyChild4 { @Column() diff --git a/src/entities/StrategyChild5.ts b/src/entities/StrategyChild5.ts index 2fa84a4..987f21f 100644 --- a/src/entities/StrategyChild5.ts +++ b/src/entities/StrategyChild5.ts @@ -4,7 +4,7 @@ import { StrategyChild1 } from "./StrategyChild1"; import { StrategyChild2 } from "./StrategyChild2"; import { StrategyChild3 } from "./StrategyChild3"; import { StrategyChild4 } from "./StrategyChild4"; - +import { Development } from "./Development"; @Entity("strategyChild5") export class StrategyChild5 extends EntityBase { @@ -56,8 +56,11 @@ export class StrategyChild5 extends EntityBase { @JoinColumn({ name: "strategyChild4Id" }) strategyChild4: StrategyChild4; -} - + @OneToMany(() => Development, (development) => development.strategyChild5Planned) + developmentPlanneds: Development[]; + @OneToMany(() => Development, (development) => development.strategyChild5Actual) + developmentActuals: Development[]; +} export class CreateStrategyChild5 { @Column() diff --git a/src/migration/1712927871127-update_table_development_add_strategyChild.ts b/src/migration/1712927871127-update_table_development_add_strategyChild.ts new file mode 100644 index 0000000..69dda24 --- /dev/null +++ b/src/migration/1712927871127-update_table_development_add_strategyChild.ts @@ -0,0 +1,52 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevelopmentAddStrategyChild1712927871127 implements MigrationInterface { + name = 'UpdateTableDevelopmentAddStrategyChild1712927871127' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild1PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามแผน'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild2PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามแผน'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild3PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามแผน'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild4PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามแผน'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild5PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามแผน'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild1ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามจริง'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild2ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามจริง'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild3ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามจริง'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild4ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามจริง'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild5ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามจริง'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_10ff41d23b977cf8dce92e9b167\` FOREIGN KEY (\`strategyChild1PlannedId\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_593bc4c0cda43a2bee2928bda49\` FOREIGN KEY (\`strategyChild2PlannedId\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_231ce173640401d258c977aae79\` FOREIGN KEY (\`strategyChild3PlannedId\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_44fb0c37a11d7ad9b8ca98aaa08\` FOREIGN KEY (\`strategyChild4PlannedId\`) REFERENCES \`strategyChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_4cd86d57223a295e6de3c42cb61\` FOREIGN KEY (\`strategyChild5PlannedId\`) REFERENCES \`strategyChild5\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_a54d96cd5fda35d92815f7f65eb\` FOREIGN KEY (\`strategyChild1ActualId\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_8a8b6b92dfd3f78d012300524df\` FOREIGN KEY (\`strategyChild2ActualId\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_9ee4f1c6a2f2c86760da928f01a\` FOREIGN KEY (\`strategyChild3ActualId\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_adf3d238b02f5806c9ed1e9b90b\` FOREIGN KEY (\`strategyChild4ActualId\`) REFERENCES \`strategyChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_f078e198298457e517c8d90e337\` FOREIGN KEY (\`strategyChild5ActualId\`) REFERENCES \`strategyChild5\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_f078e198298457e517c8d90e337\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_adf3d238b02f5806c9ed1e9b90b\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_9ee4f1c6a2f2c86760da928f01a\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_8a8b6b92dfd3f78d012300524df\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_a54d96cd5fda35d92815f7f65eb\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_4cd86d57223a295e6de3c42cb61\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_44fb0c37a11d7ad9b8ca98aaa08\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_231ce173640401d258c977aae79\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_593bc4c0cda43a2bee2928bda49\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_10ff41d23b977cf8dce92e9b167\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild5ActualId\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild4ActualId\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild3ActualId\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild2ActualId\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild1ActualId\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild5PlannedId\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild4PlannedId\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild3PlannedId\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild2PlannedId\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild1PlannedId\``); + } + +} diff --git a/src/migration/1712930900458-update_table_development_add_strategyChild1.ts b/src/migration/1712930900458-update_table_development_add_strategyChild1.ts new file mode 100644 index 0000000..f96285a --- /dev/null +++ b/src/migration/1712930900458-update_table_development_add_strategyChild1.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevelopmentAddStrategyChild11712930900458 implements MigrationInterface { + name = 'UpdateTableDevelopmentAddStrategyChild11712930900458' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`); + await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`isDone\` tinyint NOT NULL COMMENT 'บันทึกลงทะเบียนประวัติ' DEFAULT 0`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`isDone\``); + await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`orgRevisionId\``); + await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`orgRootShortName\``); + await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`root\``); + await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`rootId\``); + } + +} diff --git a/src/migration/1713012352435-update_table_developmentscholar_add_rootid.ts b/src/migration/1713012352435-update_table_developmentscholar_add_rootid.ts new file mode 100644 index 0000000..734ee75 --- /dev/null +++ b/src/migration/1713012352435-update_table_developmentscholar_add_rootid.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevelopmentscholarAddRootid1713012352435 implements MigrationInterface { + name = 'UpdateTableDevelopmentscholarAddRootid1713012352435' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`orgRevisionId\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`orgRootShortName\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`root\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`rootId\``); + } + +} diff --git a/src/migration/1713014657464-update_table_developmentscholar_date_to_datetime.ts b/src/migration/1713014657464-update_table_developmentscholar_date_to_datetime.ts new file mode 100644 index 0000000..8e468ea --- /dev/null +++ b/src/migration/1713014657464-update_table_developmentscholar_date_to_datetime.ts @@ -0,0 +1,32 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevelopmentscholarDateToDatetime1713014657464 implements MigrationInterface { + name = 'UpdateTableDevelopmentscholarDateToDatetime1713014657464' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookNoDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookNoDate\` datetime NULL COMMENT 'ลงวันที่(หนังสือ)'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookApproveDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookApproveDate\` datetime NULL COMMENT 'หนังสืออนุมัติเมื่อวันที่'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`contractDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`contractDate\` datetime NULL COMMENT 'ลงวันที่(เลขที่สัญญา)'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackNoDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackNoDate\` datetime NULL COMMENT 'ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackDate\` datetime NULL COMMENT 'รายงานตัวกลับวันที่'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackDate\` date NULL COMMENT 'รายงานตัวกลับวันที่'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackNoDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackNoDate\` date NULL COMMENT 'ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`contractDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`contractDate\` date NULL COMMENT 'ลงวันที่(เลขที่สัญญา)'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookApproveDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookApproveDate\` date NULL COMMENT 'หนังสืออนุมัติเมื่อวันที่'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookNoDate\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookNoDate\` date NULL COMMENT 'ลงวันที่(หนังสือ)'`); + } + +} From 422b0f3b87568f08ef52a58c0bef978cfa699866 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 16 Apr 2024 07:50:17 +0700 Subject: [PATCH 5/5] =?UTF-8?q?=E0=B9=82=E0=B8=84=E0=B8=A3=E0=B8=87?= =?UTF-8?q?=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B9=80=E0=B8=9E?= =?UTF-8?q?=E0=B8=B4=E0=B9=88=E0=B8=A1=E0=B8=AD=E0=B8=B1=E0=B8=9E=E0=B9=82?= =?UTF-8?q?=E0=B8=AB=E0=B8=A5=E0=B8=94=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 466 ++++++++++++++++-- package.json | 5 +- src/controllers/DevelopmentController.ts | 183 +++++-- src/entities/Development.ts | 2 +- src/entities/DevelopmentHistory.ts | 18 +- ..._table_developmentHistory_add_profileId.ts | 16 + ...ble_developmentHistory_add_trainingDays.ts | 16 + 7 files changed, 636 insertions(+), 70 deletions(-) create mode 100644 src/migration/1713163199894-update_table_developmentHistory_add_profileId.ts create mode 100644 src/migration/1713179439957-update_table_developmentHistory_add_trainingDays.ts diff --git a/package-lock.json b/package-lock.json index 3fd41e0..c77b04b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,12 +9,14 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@nestjs/platform-express": "^10.3.7", "@tsoa/runtime": "^6.0.0", "axios": "^1.6.8", "cors": "^2.8.5", "dotenv": "^16.3.1", "express": "^4.18.2", "fast-jwt": "^3.3.2", + "multer": "^1.4.5-lts.1", "mysql2": "^3.9.1", "node-cron": "^3.0.3", "promise.any": "^2.0.6", @@ -22,7 +24,8 @@ "swagger-ui-express": "^5.0.0", "tsoa": "^6.0.1", "typeorm": "^0.3.19", - "typeorm-cli": "^1.0.7" + "typeorm-cli": "^1.0.7", + "xlsx": "^0.18.5" }, "devDependencies": { "@types/cors": "^2.8.17", @@ -89,6 +92,15 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@lukeed/csprng": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@lukeed/csprng/-/csprng-1.1.0.tgz", + "integrity": "sha512-Z7C/xXCiGWsg0KuKsHTKJxbWhpI3Vs5GwLfOean7MGyVFGqdRgBbAjOCh6u4bbjPc/8MJ2pZmK/0DLdCbivLDA==", + "peer": true, + "engines": { + "node": ">=8" + } + }, "node_modules/@lukeed/ms": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@lukeed/ms/-/ms-2.0.2.tgz", @@ -97,6 +109,145 @@ "node": ">=8" } }, + "node_modules/@nestjs/common": { + "version": "10.3.7", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.3.7.tgz", + "integrity": "sha512-gKFtFzcJznrwsRYjtNZoPAvSOPYdNgxbTYoAyLTpoy393cIKgLmJTHu6ReH8/qIB9AaZLdGaFLkx98W/tFWFUw==", + "peer": true, + "dependencies": { + "iterare": "1.2.1", + "tslib": "2.6.2", + "uid": "2.0.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nest" + }, + "peerDependencies": { + "class-transformer": "*", + "class-validator": "*", + "reflect-metadata": "^0.1.12 || ^0.2.0", + "rxjs": "^7.1.0" + }, + "peerDependenciesMeta": { + "class-transformer": { + "optional": true + }, + "class-validator": { + "optional": true + } + } + }, + "node_modules/@nestjs/core": { + "version": "10.3.7", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.3.7.tgz", + "integrity": "sha512-hsdlnfiQ3kgqHL5k7js3CU0PV7hBJVi+LfFMgCkoagRxNMf67z0GFGeOV2jk5d65ssB19qdYsDa1MGVuEaoUpg==", + "hasInstallScript": true, + "peer": true, + "dependencies": { + "@nuxtjs/opencollective": "0.3.2", + "fast-safe-stringify": "2.1.1", + "iterare": "1.2.1", + "path-to-regexp": "3.2.0", + "tslib": "2.6.2", + "uid": "2.0.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nest" + }, + "peerDependencies": { + "@nestjs/common": "^10.0.0", + "@nestjs/microservices": "^10.0.0", + "@nestjs/platform-express": "^10.0.0", + "@nestjs/websockets": "^10.0.0", + "reflect-metadata": "^0.1.12 || ^0.2.0", + "rxjs": "^7.1.0" + }, + "peerDependenciesMeta": { + "@nestjs/microservices": { + "optional": true + }, + "@nestjs/platform-express": { + "optional": true + }, + "@nestjs/websockets": { + "optional": true + } + } + }, + "node_modules/@nestjs/core/node_modules/path-to-regexp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.2.0.tgz", + "integrity": "sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA==", + "peer": true + }, + "node_modules/@nestjs/platform-express": { + "version": "10.3.7", + "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.3.7.tgz", + "integrity": "sha512-noNJ+PyIxQJLCKfuXz0tcQtlVAynfLIuKy62g70lEZ86UrIqSrZFqvWs/rFUgkbT6J8H7Rmv11hASOnX+7M2rA==", + "dependencies": { + "body-parser": "1.20.2", + "cors": "2.8.5", + "express": "4.19.2", + "multer": "1.4.4-lts.1", + "tslib": "2.6.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nest" + }, + "peerDependencies": { + "@nestjs/common": "^10.0.0", + "@nestjs/core": "^10.0.0" + } + }, + "node_modules/@nestjs/platform-express/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/@nestjs/platform-express/node_modules/multer": { + "version": "1.4.4-lts.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.4-lts.1.tgz", + "integrity": "sha512-WeSGziVj6+Z2/MwQo3GvqzgR+9Uc+qt8SwHKh3gvNPiISKfsMfG4SvCOFYlxxgkXt7yIV2i1yczehm0EOKIxIg==", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/@nuxtjs/opencollective": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz", + "integrity": "sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==", + "peer": true, + "dependencies": { + "chalk": "^4.1.0", + "consola": "^2.15.0", + "node-fetch": "^2.6.1" + }, + "bin": { + "opencollective": "bin/opencollective.js" + }, + "engines": { + "node": ">=8.0.0", + "npm": ">=5.0.0" + } + }, "node_modules/@one-ini/wasm": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@one-ini/wasm/-/wasm-0.1.1.tgz", @@ -365,6 +516,14 @@ "node": ">=0.4.0" } }, + "node_modules/adler-32": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz", + "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/align-text": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", @@ -437,6 +596,11 @@ "node": ">= 6.0.0" } }, + "node_modules/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" + }, "node_modules/arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", @@ -594,12 +758,12 @@ "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" }, "node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dependencies": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -607,7 +771,7 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" }, @@ -665,6 +829,17 @@ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -706,6 +881,18 @@ "node": ">=0.10.0" } }, + "node_modules/cfb": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz", + "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", + "dependencies": { + "adler-32": "~1.3.0", + "crc-32": "~1.2.0" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -962,6 +1149,14 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/codepage": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", + "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -1004,6 +1199,20 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, "node_modules/config-chain": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz", @@ -1013,6 +1222,12 @@ "proto-list": "~1.2.1" } }, + "node_modules/consola": { + "version": "2.15.3", + "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz", + "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==", + "peer": true + }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -1033,9 +1248,9 @@ } }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "engines": { "node": ">= 0.6" } @@ -1062,6 +1277,17 @@ "node": ">= 0.10" } }, + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -1425,16 +1651,16 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -1492,6 +1718,12 @@ "node": ">=16 <22" } }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "peer": true + }, "node_modules/figures": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", @@ -1595,6 +1827,14 @@ "node": ">= 0.6" } }, + "node_modules/frac": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", + "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", @@ -2046,6 +2286,17 @@ "node": ">=4" } }, + "node_modules/inquirer/node_modules/rxjs": { + "version": "6.6.7", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", + "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", + "dependencies": { + "tslib": "^1.9.0" + }, + "engines": { + "npm": ">=2.0.0" + } + }, "node_modules/inquirer/node_modules/string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -2088,6 +2339,11 @@ "node": ">=6" } }, + "node_modules/inquirer/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + }, "node_modules/internal-slot": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.6.tgz", @@ -2389,6 +2645,15 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, + "node_modules/iterare": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/iterare/-/iterare-1.2.1.tgz", + "integrity": "sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==", + "peer": true, + "engines": { + "node": ">=6" + } + }, "node_modules/iterate-iterator": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/iterate-iterator/-/iterate-iterator-1.0.2.tgz", @@ -2692,6 +2957,34 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "node_modules/multer": { + "version": "1.4.5-lts.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", + "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/multer/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, "node_modules/mute-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", @@ -2814,6 +3107,26 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "peer": true, + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/nodemon": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.3.tgz", @@ -3168,9 +3481,9 @@ } }, "node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", @@ -3291,21 +3604,14 @@ } }, "node_modules/rxjs": { - "version": "6.6.7", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", - "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "peer": true, "dependencies": { - "tslib": "^1.9.0" - }, - "engines": { - "npm": ">=2.0.0" + "tslib": "^2.1.0" } }, - "node_modules/rxjs/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, "node_modules/safe-array-concat": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.0.tgz", @@ -3570,6 +3876,17 @@ "node": ">= 0.6" } }, + "node_modules/ssf": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz", + "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", + "dependencies": { + "frac": "~1.1.2" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -3589,6 +3906,14 @@ "node": ">= 0.4" } }, + "node_modules/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -3899,6 +4224,12 @@ "nodetouch": "bin/nodetouch.js" } }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "peer": true + }, "node_modules/ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", @@ -4036,6 +4367,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" + }, "node_modules/typeorm": { "version": "0.3.19", "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.19.tgz", @@ -4490,6 +4826,18 @@ "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", "integrity": "sha512-vb2s1lYx2xBtUgy+ta+b2J/GLVUR+wmpINwHePmPRhOsIVCG2wDzKJ0n14GslH1BifsqVzSOwQhRaCAsZ/nI4Q==" }, + "node_modules/uid": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/uid/-/uid-2.0.2.tgz", + "integrity": "sha512-u3xV3X7uzvi5b1MncmZo3i2Aw222Zk1keqLA1YkHldREkAhAqi65wuPfe7lHx8H/Wzy+8CE7S7uS3jekIM5s8g==", + "peer": true, + "dependencies": { + "@lukeed/csprng": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -4586,6 +4934,22 @@ "loose-envify": "^1.0.0" } }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "peer": true + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "peer": true, + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -4641,6 +5005,22 @@ "node": ">= 0.8.0" } }, + "node_modules/wmf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", + "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/word": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz", + "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", @@ -4732,6 +5112,26 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, + "node_modules/xlsx": { + "version": "0.18.5", + "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.18.5.tgz", + "integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==", + "dependencies": { + "adler-32": "~1.3.0", + "cfb": "~1.2.1", + "codepage": "~1.15.0", + "crc-32": "~1.2.1", + "ssf": "~0.11.2", + "wmf": "~1.0.1", + "word": "~0.3.0" + }, + "bin": { + "xlsx": "bin/xlsx.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/xml2js": { "version": "0.4.23", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", @@ -4752,6 +5152,14 @@ "node": ">=4.0" } }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index b530886..939e3e5 100644 --- a/package.json +++ b/package.json @@ -27,12 +27,14 @@ "typescript": "^5.3.3" }, "dependencies": { + "@nestjs/platform-express": "^10.3.7", "@tsoa/runtime": "^6.0.0", "axios": "^1.6.8", "cors": "^2.8.5", "dotenv": "^16.3.1", "express": "^4.18.2", "fast-jwt": "^3.3.2", + "multer": "^1.4.5-lts.1", "mysql2": "^3.9.1", "node-cron": "^3.0.3", "promise.any": "^2.0.6", @@ -40,6 +42,7 @@ "swagger-ui-express": "^5.0.0", "tsoa": "^6.0.1", "typeorm": "^0.3.19", - "typeorm-cli": "^1.0.7" + "typeorm-cli": "^1.0.7", + "xlsx": "^0.18.5" } } diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 50c7ef6..4e295ab 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -11,6 +11,7 @@ import { Path, Request, Query, + UploadedFile, } from "tsoa"; import { AppDataSource } from "../database/data-source"; import { In, Not } from "typeorm"; @@ -47,6 +48,10 @@ import { StrategyChild2 } from "../entities/StrategyChild2"; import { StrategyChild3 } from "../entities/StrategyChild3"; import { StrategyChild4 } from "../entities/StrategyChild4"; import { StrategyChild5 } from "../entities/StrategyChild5"; +import CallAPI from "../interfaces/call-api"; +import { UseInterceptors } from "@nestjs/common"; +import { FileInterceptor } from "@nestjs/platform-express"; +import * as xlsx from "xlsx"; @Route("api/v1/development/main") @Tags("Development") @@ -1572,13 +1577,21 @@ export class DevelopmentController extends Controller { const getDevelopment = await this.developmentHistoryRepository.find({ where: { developmentId: id }, relations: ["posLevel", "posType", "employeePosLevel", "employeePosType"], + order: { + isDone: "ASC", + citizenId: "ASC", + }, }); const _getDevelopment = getDevelopment.map((item) => ({ id: item.id, - citizenId: item.citizenId, + type: item.type, + idcard: item.citizenId, fullName: item.prefix + item.firstName + " " + item.lastName, + prefix: item.prefix, + firstName: item.firstName, + lastName: item.lastName, position: item.position, - posType: + posTypeName: item.type == "OFFICER" ? item.posType ? item.posType.posTypeName @@ -1586,7 +1599,7 @@ export class DevelopmentController extends Controller { : item.employeePosType ? item.employeePosType.posTypeName : null, - posLevel: + posLevelName: item.type == "OFFICER" ? item.posLevel ? item.posLevel.posLevelName @@ -1595,14 +1608,63 @@ export class DevelopmentController extends Controller { ? item.employeePosLevel.posLevelName : null, posExecutive: item.posExecutive, - root: item.root, - order: item.order, - dateOrder: item.dateOrder, + org: item.root, + trainingDays: item.trainingDays, + commandNumber: item.order, + commandDate: item.dateOrder, isDone: item.isDone, })); return new HttpSuccess(_getDevelopment); } + /** + * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab6 ส่งบันทึกทะเบียนประวัติ + * + * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab6 ส่งบันทึกทะเบียนประวัติ # + * + * @param {string} id Id โครงการ + */ + @Get("tab6/done/{id}") + async GetDevelopemtTab6DoneById( + @Path() id: string, + @Request() request: { user: Record }, + ) { + const getDevelopment = await this.developmentHistoryRepository.find({ + where: { developmentId: id, isDone: false, type: "OFFICER" }, + relations: ["development"], + }); + await Promise.all( + getDevelopment.map(async (x) => { + const _data = Object.assign(new DevelopmentHistory(), x); + await new CallAPI() + .PostData(request, "org/profile/training", { + profileId: x.profileId, + name: x.development == null ? null : x.development.projectName, + topic: x.development == null ? null : x.development.topicAcademic, + yearly: x.development == null ? null : x.development.year, + place: x.development == null ? null : x.development.addressAcademic, + duration: x.development == null ? null : x.development.totalDate, + department: x.development == null ? null : x.development.root, + numberOrder: x.order, + dateOrder: x.dateOrder, + startDate: x.development == null ? null : x.development.dateStart, + endDate: x.development == null ? null : x.development.dateEnd, + isDate: true, + }) + .then((x) => { + _data.isDone = true; + }) + .catch((x) => { + _data.isDone = false; + }); + _data.lastUpdateUserId = request.user.sub; + _data.lastUpdateFullName = request.user.name; + await this.developmentHistoryRepository.save(_data); + }), + ); + return new HttpSuccess(getDevelopment); + } + /** * API list หน่วยงาน * @@ -1630,48 +1692,93 @@ export class DevelopmentController extends Controller { * * @param {string} id Id โครงการ */ - @Get("zxczxc/{id}") + @Post("tab6/{id}") + @UseInterceptors(FileInterceptor("file")) async UploadUserDevelopemtById( @Path() id: string, + @UploadedFile() file: Express.Multer.File, @Request() request: { user: Record }, ) { const getDevelopment = await this.developmentRepository.findOne({ where: { id: id }, - relations: ["developmentHistory"], + relations: { + developmentHistorys: true, + }, }); if (!getDevelopment) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - await this.developmentHistoryRepository.remove(getDevelopment.developmentHistorys); + const workbook = xlsx.read(file.buffer, { type: "buffer" }); + const sheetName = workbook.SheetNames[0]; // Assuming we're reading the first sheet + const sheet = workbook.Sheets[sheetName]; + const getDevelopments = xlsx.utils.sheet_to_json(sheet); - // await Promise.all( - // positions.map(async (x) => { - // const data = Object.assign(new DevelopmentHistory(), x); - // if (x.posTypeId != null) { - // const checkId = await this.posTypeRepository.findOne({ - // where: { id: x.posTypeId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - // } - // } - // if (x.posLevelId != null) { - // const checkId = await this.posLevelRepository.findOne({ - // where: { id: x.posLevelId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - // } - // } - // data.developmentId = getDevelopment.id; - // data.createdUserId = request.user.sub; - // data.createdFullName = request.user.name; - // data.lastUpdateUserId = request.user.sub; - // data.lastUpdateFullName = request.user.name; - // await this.plannedGoalPositionRepository.save(data); - // }), - // ); - - return new HttpSuccess(); + await Promise.all( + getDevelopments.map(async (item: any) => { + if (item["รหัสประจำตัวประชาชน"] == undefined || item["รหัสประจำตัวประชาชน"].length != 13) + return; + const oldProfile = getDevelopment.developmentHistorys.find( + (x) => x.citizenId == item["รหัสประจำตัวประชาชน"], + ); + if (oldProfile != null) return; + if (item["ประเภท"] == undefined) return; + if (item["ประเภท"] == "ข้าราชการกรุงเทพมหานครสามัญ") { + await new CallAPI() + .GetData(request, `org/unauthorize/officer/citizen/${item["รหัสประจำตัวประชาชน"]}`) + .then(async (x: any) => { + let development = Object.assign(new DevelopmentHistory(), x); + development.order = + item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"] == undefined + ? null + : item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"]; + development.dateOrder = + item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"] == undefined + ? null + : new Date(item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"]); + development.trainingDays = + item["จำนวนวันที่อบรม"] == undefined ? null : item["จำนวนวันที่อบรม"]; + development.developmentId = id; + development.createdUserId = request.user.sub; + development.createdFullName = request.user.name; + development.lastUpdateUserId = request.user.sub; + development.lastUpdateFullName = request.user.name; + await this.developmentHistoryRepository.save(development); + }) + .catch((x) => { + return; + }); + } else { + await new CallAPI() + .GetData(request, `org/unauthorize/employee/citizen/${item["รหัสประจำตัวประชาชน"]}`) + .then(async (x: any) => { + let development = Object.assign(new DevelopmentHistory(), x); + development.order = + item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"] == undefined + ? null + : item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"]; + development.dateOrder = + item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"] == undefined + ? null + : new Date(item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"]); + development.trainingDays = + item["จำนวนวันที่อบรม"] == undefined ? null : item["จำนวนวันที่อบรม"]; + development.posLevelId = null; + development.posTypeId = null; + development.employeePosLevelId = x.posLevelId; + development.employeePosTypeId = x.posTypeId; + development.developmentId = id; + development.createdUserId = request.user.sub; + development.createdFullName = request.user.name; + development.lastUpdateUserId = request.user.sub; + development.lastUpdateFullName = request.user.name; + await this.developmentHistoryRepository.save(development); + }) + .catch((x) => { + return; + }); + } + }), + ); + return new HttpSuccess(getDevelopments); } } diff --git a/src/entities/Development.ts b/src/entities/Development.ts index dbbd06d..e56fe97 100644 --- a/src/entities/Development.ts +++ b/src/entities/Development.ts @@ -35,7 +35,7 @@ export class Development extends EntityBase { @Column({ nullable: true, - comment: "ชื่อย่ิหน่วยงาน", + comment: "ชื่อย่อหน่วยงาน", default: null, }) orgRootShortName: string; diff --git a/src/entities/DevelopmentHistory.ts b/src/entities/DevelopmentHistory.ts index 6e2ebca..c279e47 100644 --- a/src/entities/DevelopmentHistory.ts +++ b/src/entities/DevelopmentHistory.ts @@ -24,7 +24,7 @@ export class DevelopmentHistory extends EntityBase { @Column({ nullable: true, - comment: "ชื่อย่ิหน่วยงาน", + comment: "ชื่อย่อหน่วยงาน", default: null, }) orgRootShortName: string; @@ -36,6 +36,14 @@ export class DevelopmentHistory extends EntityBase { }) orgRevisionId: string; + @Column({ + nullable: true, + comment: "id profile", + length: 40, + default: null, + }) + profileId: string; + @Column({ nullable: true, comment: "ประเภทราชการ", @@ -155,6 +163,14 @@ export class DevelopmentHistory extends EntityBase { @JoinColumn({ name: "developmentId" }) development: Development; + @Column({ + nullable: true, + comment: "จำนวนวันที่อบรม", + default: null, + length: 255, + }) + trainingDays: string; + @Column({ nullable: true, comment: "เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ", diff --git a/src/migration/1713163199894-update_table_developmentHistory_add_profileId.ts b/src/migration/1713163199894-update_table_developmentHistory_add_profileId.ts new file mode 100644 index 0000000..32b0753 --- /dev/null +++ b/src/migration/1713163199894-update_table_developmentHistory_add_profileId.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevelopmentHistoryAddProfileId1713163199894 implements MigrationInterface { + name = 'UpdateTableDevelopmentHistoryAddProfileId1713163199894' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`profileId\` varchar(40) NULL COMMENT 'id profile'`); + await queryRunner.query(`ALTER TABLE \`development\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`development\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`profileId\``); + } + +} diff --git a/src/migration/1713179439957-update_table_developmentHistory_add_trainingDays.ts b/src/migration/1713179439957-update_table_developmentHistory_add_trainingDays.ts new file mode 100644 index 0000000..34f36e9 --- /dev/null +++ b/src/migration/1713179439957-update_table_developmentHistory_add_trainingDays.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevelopmentHistoryAddTrainingDays1713179439957 implements MigrationInterface { + name = 'UpdateTableDevelopmentHistoryAddTrainingDays1713179439957' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`trainingDays\` varchar(255) NULL COMMENT 'จำนวนวันที่อบรม'`); + await queryRunner.query(`ALTER TABLE \`developmentHistory\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentHistory\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`trainingDays\``); + } + +}