From 963a76df10bddfe0690662bd4e0ef107d9486ee5 Mon Sep 17 00:00:00 2001 From: kittapath Date: Mon, 23 Sep 2024 16:16:59 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=9F=E0=B8=B4=E0=B8=A7=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 4 ++++ src/controllers/CommandSysController.ts | 18 +++++++++++++++--- src/entities/Command.ts | 7 +++++++ src/entities/CommandSys.ts | 7 +++++++ ...81490162-update_command_add_isAttachment.ts | 18 ++++++++++++++++++ 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 src/migration/1727081490162-update_command_add_isAttachment.ts diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 6a15956c..462df173 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -145,6 +145,10 @@ export class CommandController extends Controller { if (!commandType) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); } + command.detailHeader = commandType.detailHeader; + command.detailBody = commandType.detailBody; + command.detailFooter = commandType.detailFooter; + command.isAttachment = commandType.isAttachment; command.status = "DRAFT"; command.issue = commandType.name; command.createdUserId = request.user.sub; diff --git a/src/controllers/CommandSysController.ts b/src/controllers/CommandSysController.ts index 72a8a24d..316697af 100644 --- a/src/controllers/CommandSysController.ts +++ b/src/controllers/CommandSysController.ts @@ -39,8 +39,16 @@ export class CommandSysController extends Controller { @Get("list") async GetResult() { const _commandSys = await this.commandSysRepository.find({ - select: ["id", "sysName", "sysDescription", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"], - order: { id: "ASC" }, + select: [ + "id", + "sysName", + "sysDescription", + "createdAt", + "lastUpdatedAt", + "createdFullName", + "lastUpdateFullName", + ], + order: { order: "ASC" }, }); return new HttpSuccess(_commandSys); } @@ -79,7 +87,11 @@ export class CommandSysController extends Controller { ) { const _commandSys = Object.assign(new CommandSys(), requestBody); const checkName = await this.commandSysRepository.findOne({ - where: { id: requestBody.id,sysName: requestBody.sysName,sysDescription: requestBody.sysDescription }, + where: { + id: requestBody.id, + sysName: requestBody.sysName, + sysDescription: requestBody.sysDescription, + }, }); if (checkName) { diff --git a/src/entities/Command.ts b/src/entities/Command.ts index 28b61b3e..86db45f4 100644 --- a/src/entities/Command.ts +++ b/src/entities/Command.ts @@ -5,6 +5,7 @@ import { CommandSend } from "./CommandSend"; @Entity("command") export class Command extends EntityBase { + // NEW = ใหม่ // DRAFT = แบบร่าง // PENDING = รอผู้มีอำนาจ // WAITING = รอออกคำสั่ง @@ -87,6 +88,12 @@ export class Command extends EntityBase { }) commandTypeId: string; + @Column({ + comment: "สถานะบัญชีแนบท้าย", + default: true, + }) + isAttachment: boolean; + @ManyToOne(() => CommandType, (commandType) => commandType.commands) @JoinColumn({ name: "commandTypeId" }) commandType: CommandType; diff --git a/src/entities/CommandSys.ts b/src/entities/CommandSys.ts index 89ebeb61..cb74490d 100644 --- a/src/entities/CommandSys.ts +++ b/src/entities/CommandSys.ts @@ -59,6 +59,13 @@ export class CommandSys { }) sysDescription: string; + @Column({ + nullable: true, + comment: "ลำดับแสดงผล", + default: null, + }) + order: number; + @OneToMany(() => CommandType, (commandType) => commandType.commandTypeSys) commandTypes: CommandType[]; diff --git a/src/migration/1727081490162-update_command_add_isAttachment.ts b/src/migration/1727081490162-update_command_add_isAttachment.ts new file mode 100644 index 00000000..ac24f2d8 --- /dev/null +++ b/src/migration/1727081490162-update_command_add_isAttachment.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateCommandAddIsAttachment1727081490162 implements MigrationInterface { + name = 'UpdateCommandAddIsAttachment1727081490162' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`commandSys\` ADD \`order\` int NULL COMMENT 'ลำดับแสดงผล'`); + await queryRunner.query(`ALTER TABLE \`command\` ADD \`isAttachment\` tinyint NOT NULL COMMENT 'สถานะบัญชีแนบท้าย' DEFAULT 1`); + await queryRunner.query(`ALTER TABLE \`HR_POSITION_OFFICER\` ADD \`FLAG_PERSON_TYPE\` text NULL`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`HR_POSITION_OFFICER\` DROP COLUMN \`FLAG_PERSON_TYPE\``); + await queryRunner.query(`ALTER TABLE \`command\` DROP COLUMN \`isAttachment\``); + await queryRunner.query(`ALTER TABLE \`commandSys\` DROP COLUMN \`order\``); + } + +}