เพิ่ม order

This commit is contained in:
kittapath 2024-09-16 16:59:48 +07:00
parent d3aa76b3f8
commit 008add7398
4 changed files with 27 additions and 4 deletions

View file

@ -53,7 +53,7 @@ export class CommandSalaryController extends Controller {
"createdFullName", "createdFullName",
"lastUpdateFullName", "lastUpdateFullName",
], ],
order: { name: "ASC" }, order: { createdAt: "ASC" },
}); });
return new HttpSuccess(_commandSalary); return new HttpSuccess(_commandSalary);
} }
@ -91,7 +91,7 @@ export class CommandSalaryController extends Controller {
: `${commandSysId}`, : `${commandSysId}`,
}, },
) )
.orderBy("commandSalary.name", "ASC") .orderBy("commandSalary.createdAt", "ASC")
.skip((page - 1) * pageSize) .skip((page - 1) * pageSize)
.take(pageSize) .take(pageSize)
.getManyAndCount(); .getManyAndCount();

View file

@ -59,7 +59,7 @@ export class CommandTypeController extends Controller {
"createdFullName", "createdFullName",
"lastUpdateFullName", "lastUpdateFullName",
], ],
order: { createdAt: "ASC" }, order: { order: "ASC" },
}); });
return new HttpSuccess(_commandType); return new HttpSuccess(_commandType);
} }
@ -85,7 +85,7 @@ export class CommandTypeController extends Controller {
isActive == null || isActive == undefined ? null : `${isActive == true ? 1 : 0}`, isActive == null || isActive == undefined ? null : `${isActive == true ? 1 : 0}`,
}, },
) )
.orderBy("commandType.createdAt", "ASC") .orderBy("commandType.order", "ASC")
.skip((page - 1) * pageSize) .skip((page - 1) * pageSize)
.take(pageSize) .take(pageSize)
.getManyAndCount(); .getManyAndCount();

View file

@ -5,6 +5,13 @@ import { CommandSys } from "./CommandSys";
@Entity("commandType") @Entity("commandType")
export class CommandType extends EntityBase { export class CommandType extends EntityBase {
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
default: null,
})
order: number;
@Column({ @Column({
nullable: true, nullable: true,
comment: "ชื่อคำสั่ง", comment: "ชื่อคำสั่ง",

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateCommandTypeAddOrder1726479252659 implements MigrationInterface {
name = 'UpdateCommandTypeAddOrder1726479252659'
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
// await queryRunner.query(`ALTER TABLE \`HR_POSITION_OFFICER\` DROP COLUMN \`FLAG_PERSON_TYPE\``);
await queryRunner.query(`ALTER TABLE \`commandType\` DROP COLUMN \`order\``);
}
}