From 879b6bfd0b2b96b285ef53d3702f4cbf5a017744 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 18 Apr 2025 13:18:11 +0700 Subject: [PATCH] update field and api update duty --- src/controllers/DirectorController.ts | 28 +++++++++++++++++++++++++++ src/entities/Director.ts | 6 ++++++ src/entities/Evaluation.ts | 15 ++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/src/controllers/DirectorController.ts b/src/controllers/DirectorController.ts index dfb3b23..fd63984 100644 --- a/src/controllers/DirectorController.ts +++ b/src/controllers/DirectorController.ts @@ -193,6 +193,34 @@ export class DirectorController { } } + /** + * API สำหรับแก้ไขรายละเอียดกรรมการ + * + * @summary แก้ไขรายละเอียดกรรมการ (ADMIN) + * + */ + @Put("duty/{id}") + async updateDuty(@Path() id: string, @Body() body:{duty: string} , @Request() request: RequestWithUser) { + try { + await new permission().PermissionUpdate(request, "SYS_EVA_INFO"); + let director = await this.directorRepository.findOneBy({ id }); + if (!director) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกรรมการ"); + } + const before = structuredClone(director); + director.duty = body?.duty; + director.lastUpdateUserId = request.user.sub; + director.lastUpdateFullName = request.user.name; + director.lastUpdatedAt = new Date(); + await this.directorRepository.save(director, { data: request }); + setLogDataDiff(request, { before, after: director }); + return new HttpSuccess(); + } catch (error: any) { + if (error instanceof HttpError) { + throw error; + } else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error); + } + } /** * API สำหรับแก้ไขรายละเอียดกรรมการ * diff --git a/src/entities/Director.ts b/src/entities/Director.ts index dd6a209..2710d23 100644 --- a/src/entities/Director.ts +++ b/src/entities/Director.ts @@ -25,6 +25,9 @@ export class Director extends EntityBase { @Column({ nullable: true, comment: "ตำแหน่ง" }) position: string; + @Column({ nullable: true, comment: "หน้าที่" }) + duty: string; + @ManyToMany(() => Evaluation, (evaluation) => evaluation.directors) evaluations: Evaluation[]; } @@ -47,5 +50,8 @@ export class CreateDirector { @Column() position: string; + + // @Column() + // duty?: string; } export type UpdateDirector = Partial; diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index b7e1daf..2a1934e 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -199,6 +199,21 @@ export class Evaluation extends EntityBase { @Column({ nullable: true, comment: "ตำแหน่ง ผู้บังคับบัญชาชั้นต้น (จัดเตรียมเอกสารเล่ม 2)" }) commanderPositionDoc2: string; + + @Column({ nullable: true, comment: "สังกัดปัจุบัน ผู้บังคับบัญชาชั้นต้น" }) + commanderOrg: string; + @Column({ nullable: true, comment: "สังกัดเดิม ผู้บังคับบัญชาชั้นต้น" }) + commanderOrgOld: string; + @Column({ nullable: true, comment: "ตำแหน่งเดิม ผู้บังคับบัญชาชั้นต้น" }) + commanderPositionOld: string; + + @Column({ nullable: true, comment: "สังกัดปัจุบัน ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ" }) + commanderAboveOrg: string; + @Column({ nullable: true, comment: "สังกัดเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ" }) + commanderAboveOrgOld: string; + @Column({ nullable: true, comment: "ตำแหน่งเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ" }) + commanderAbovePositionOld: string; + @Column({ nullable: true, comment: "ชื่อ-นามสกุล ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ (จัดเตรียมเอกสารเล่ม 2)",