From f6c726baa5dd02594bf9f4379d0d284621d068a0 Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 23 Feb 2026 15:06:32 +0700 Subject: [PATCH] =?UTF-8?q?Migrate=20=E0=B8=AD=E0=B8=B1=E0=B8=95=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=81=E0=B8=B3=E0=B8=A5=E0=B8=B1=E0=B8=87=E0=B8=A5?= =?UTF-8?q?=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=9B?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=88=E0=B8=B3=20=E0=B9=80=E0=B8=9E?= =?UTF-8?q?=E0=B8=B4=E0=B9=88=E0=B8=A1=E0=B9=80=E0=B8=A1=E0=B8=99=E0=B8=B9?= =?UTF-8?q?=E0=B8=84=E0=B8=B1=E0=B8=94=E0=B8=A5=E0=B8=AD=E0=B8=81/?= =?UTF-8?q?=E0=B8=88=E0=B8=B1=E0=B8=94=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=95?= =?UTF-8?q?=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87=E0=B8=95?= =?UTF-8?q?=E0=B8=B4=E0=B8=94=E0=B9=80=E0=B8=87=E0=B8=B7=E0=B9=88=E0=B8=AD?= =?UTF-8?q?=E0=B8=99=E0=B9=84=E0=B8=82=20#2316=20&&=20Fix=20Bug=20?= =?UTF-8?q?=E0=B8=81=E0=B8=94=E0=B8=A5=E0=B8=9A=E0=B8=96=E0=B8=B2=E0=B8=A7?= =?UTF-8?q?=E0=B8=A3=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= =?UTF-8?q?=E0=B9=81=E0=B8=A5=E0=B9=89=E0=B8=A7=20error=20#216?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 1 + src/controllers/EmployeePositionController.ts | 31 +++++++++++++++++++ src/entities/EmployeePosMaster.ts | 14 +++++++++ ...te_empPosMaster_add_fields_isCondition_.ts | 20 ++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 src/migration/1771832659308-update_empPosMaster_add_fields_isCondition_.ts diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 579d791d..d9428e27 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1244,6 +1244,7 @@ export class CommandController extends Controller { await this.commandSendCCRepository.delete({ commandSendId: In(commandSend.map((x) => x.id)) }); await this.commandReciveRepository.delete({ commandId: command.id }); await this.commandSendRepository.delete({ commandId: command.id }); + await this.commandOperatorRepository.delete({ commandId: command.id }); await this.commandRepository.delete(command.id); return new HttpSuccess(); } diff --git a/src/controllers/EmployeePositionController.ts b/src/controllers/EmployeePositionController.ts index 8007ac42..9baec79b 100644 --- a/src/controllers/EmployeePositionController.ts +++ b/src/controllers/EmployeePositionController.ts @@ -940,6 +940,35 @@ export class EmployeePositionController extends Controller { return new HttpSuccess(posMaster.id); } + /** + * @summary แก้ไขตำแหน่งเงื่อนไข ลูกจ้างประจำ (ADMIN) + */ + @Put("master/position-condition/{id}") + async updatePositionCondition( + @Path() id: string, + @Body() + requestBody: { + isCondition: boolean | null; + conditionReason: string | null; + }, + @Request() request: RequestWithUser, + ) { + await new permission().PermissionUpdate(request, "SYS_POS_CONDITION"); + const posMaster = await this.employeePosMasterRepository.findOne({ + where: { id: id }, + }); + if (!posMaster) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); + } + + Object.assign(posMaster, requestBody); + posMaster.lastUpdateUserId = request.user.sub; + posMaster.lastUpdateFullName = request.user.name; + posMaster.lastUpdatedAt = new Date(); + await this.employeePosMasterRepository.save(posMaster); + return new HttpSuccess(); + } + /** * API รายละเอียดอัตรากำลัง * @@ -1369,6 +1398,8 @@ export class EmployeePositionController extends Controller { profilePoslevel: level == null || type == null ? null : `${type.posTypeShortName} ${level.posLevelName}`, authRoleId: posMaster.authRoleId, + isCondition: posMaster.isCondition, + conditionReason: posMaster.conditionReason, authRoleName: authRoleName == null || authRoleName.roleName == null ? null : authRoleName.roleName, positions: positions.map((position) => ({ diff --git a/src/entities/EmployeePosMaster.ts b/src/entities/EmployeePosMaster.ts index c1f0e143..d76b3e01 100644 --- a/src/entities/EmployeePosMaster.ts +++ b/src/entities/EmployeePosMaster.ts @@ -193,6 +193,20 @@ export class EmployeePosMaster extends EntityBase { }) authRoleId: string; + @Column({ + comment: "ตำแหน่งติดเงื่อนไข", + default: false, + }) + isCondition: boolean; + + @Column({ + nullable: true, + comment: "หมายเหตุตำแหน่งติดเงื่อนไข", + type: "text", + default: null, + }) + conditionReason: string; + @ManyToOne(() => AuthRole, (authRole) => authRole.posMasterEmps) @JoinColumn({ name: "authRoleId" }) authRole: AuthRole; diff --git a/src/migration/1771832659308-update_empPosMaster_add_fields_isCondition_.ts b/src/migration/1771832659308-update_empPosMaster_add_fields_isCondition_.ts new file mode 100644 index 00000000..98246b62 --- /dev/null +++ b/src/migration/1771832659308-update_empPosMaster_add_fields_isCondition_.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateEmpPosMasterAddFieldsIsCondition_1771832659308 implements MigrationInterface { + name = 'UpdateEmpPosMasterAddFieldsIsCondition_1771832659308' + + public async up(queryRunner: QueryRunner): Promise { + + await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD \`isCondition\` tinyint NOT NULL COMMENT 'ตำแหน่งติดเงื่อนไข' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD \`conditionReason\` text NULL COMMENT 'หมายเหตุตำแหน่งติดเงื่อนไข'`); + + } + + public async down(queryRunner: QueryRunner): Promise { + + await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP COLUMN \`conditionReason\``); + await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP COLUMN \`isCondition\``); + + } + +}