From 008add7398f7159ef5429320c28efb08e8c1053b Mon Sep 17 00:00:00 2001 From: kittapath Date: Mon, 16 Sep 2024 16:59:48 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=20order?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandSalaryController.ts | 4 ++-- src/controllers/CommandTypeController.ts | 4 ++-- src/entities/CommandType.ts | 7 +++++++ ...1726479252659-update_commandType_add_order.ts | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 src/migration/1726479252659-update_commandType_add_order.ts diff --git a/src/controllers/CommandSalaryController.ts b/src/controllers/CommandSalaryController.ts index c5002f29..d2873153 100644 --- a/src/controllers/CommandSalaryController.ts +++ b/src/controllers/CommandSalaryController.ts @@ -53,7 +53,7 @@ export class CommandSalaryController extends Controller { "createdFullName", "lastUpdateFullName", ], - order: { name: "ASC" }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(_commandSalary); } @@ -91,7 +91,7 @@ export class CommandSalaryController extends Controller { : `${commandSysId}`, }, ) - .orderBy("commandSalary.name", "ASC") + .orderBy("commandSalary.createdAt", "ASC") .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); diff --git a/src/controllers/CommandTypeController.ts b/src/controllers/CommandTypeController.ts index 5342c73a..8f15aa1c 100644 --- a/src/controllers/CommandTypeController.ts +++ b/src/controllers/CommandTypeController.ts @@ -59,7 +59,7 @@ export class CommandTypeController extends Controller { "createdFullName", "lastUpdateFullName", ], - order: { createdAt: "ASC" }, + order: { order: "ASC" }, }); return new HttpSuccess(_commandType); } @@ -85,7 +85,7 @@ export class CommandTypeController extends Controller { isActive == null || isActive == undefined ? null : `${isActive == true ? 1 : 0}`, }, ) - .orderBy("commandType.createdAt", "ASC") + .orderBy("commandType.order", "ASC") .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); diff --git a/src/entities/CommandType.ts b/src/entities/CommandType.ts index 8013d99d..d85a2a53 100644 --- a/src/entities/CommandType.ts +++ b/src/entities/CommandType.ts @@ -5,6 +5,13 @@ import { CommandSys } from "./CommandSys"; @Entity("commandType") export class CommandType extends EntityBase { + @Column({ + nullable: true, + comment: "ลำดับความสำคัญ", + default: null, + }) + order: number; + @Column({ nullable: true, comment: "ชื่อคำสั่ง", diff --git a/src/migration/1726479252659-update_commandType_add_order.ts b/src/migration/1726479252659-update_commandType_add_order.ts new file mode 100644 index 00000000..d512770a --- /dev/null +++ b/src/migration/1726479252659-update_commandType_add_order.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateCommandTypeAddOrder1726479252659 implements MigrationInterface { + name = 'UpdateCommandTypeAddOrder1726479252659' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`commandType\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`); + // 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 \`commandType\` DROP COLUMN \`order\``); + } + +}