From a47c804969ab0f388a0032e0c1ed037da273a78d Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 24 Mar 2025 17:59:47 +0700 Subject: [PATCH] sort and add field --- .../ProfileSalaryTempController.ts | 16 +++++++++++++- src/entities/CommandCode.ts | 21 +++++++++++++++++++ src/entities/ProfileSalary.ts | 16 ++++++++++++++ src/entities/ProfileSalaryTemp.ts | 17 +++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/controllers/ProfileSalaryTempController.ts b/src/controllers/ProfileSalaryTempController.ts index a44bc40e..7d3d1698 100644 --- a/src/controllers/ProfileSalaryTempController.ts +++ b/src/controllers/ProfileSalaryTempController.ts @@ -158,10 +158,24 @@ export class ProfileSalaryTempController extends Controller { ); }), ) + // .andWhere( + // rootId != undefined && + // rootId != null + // ? `current_holders.orgRootId = :rootId` + // : "1=1", + // { + // rootId: rootId, + // } + // ) .andWhere("current_holders.orgRootId = :rootId", { rootId: rootId, }) - .orderBy("current_holders.posMasterNo", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") + .addOrderBy("orgChild1.orgChild1Order", "ASC") + .addOrderBy("orgChild2.orgChild2Order", "ASC") + .addOrderBy("orgChild3.orgChild3Order", "ASC") + .addOrderBy("orgChild4.orgChild4Order", "ASC") + .addOrderBy("current_holders.posMasterNo", "ASC") // .orderBy(`${sortBy}`, sort) .skip((page - 1) * pageSize) .take(pageSize) diff --git a/src/entities/CommandCode.ts b/src/entities/CommandCode.ts index 3372fc8c..f19fa894 100644 --- a/src/entities/CommandCode.ts +++ b/src/entities/CommandCode.ts @@ -17,6 +17,21 @@ export class CommandCode extends EntityBase { default: null, }) code: number; + + @Column({ + nullable: true, + comment: "ลำดับ", + default: null, + }) + order: number; + + @Column({ + nullable: true, + comment: "คำสั่ง", + length: 255, + default: null, + }) + caption: string; } export class CreateCommandCode { @@ -25,6 +40,12 @@ export class CreateCommandCode { @Column() code: number; + + @Column() + order: number; + + @Column() + caption: string; } export type UpdateCommandCode = Partial; diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 7c86759d..24506238 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -256,6 +256,22 @@ export class ProfileSalary extends EntityBase { }) commandId: string; + @Column({ + nullable: true, + length: 255, + comment: "หน่วยงานที่ออกคำสั่ง", + default: null, + }) + posNumCodeSit: string; + + @Column({ + nullable: true, + length: 255, + comment: "หน่วยงานที่ออกคำสั่ง(ตัวย่อ)", + default: null, + }) + posNumCodeSitAbb: string; + @ManyToOne(() => Command, (command) => command.profileSalarys) @JoinColumn({ name: "commandId" }) command: Command; diff --git a/src/entities/ProfileSalaryTemp.ts b/src/entities/ProfileSalaryTemp.ts index 96a3a93f..42d13d70 100644 --- a/src/entities/ProfileSalaryTemp.ts +++ b/src/entities/ProfileSalaryTemp.ts @@ -277,6 +277,23 @@ export class ProfileSalaryTemp extends EntityBase { }) salaryId: string; + @Column({ + nullable: true, + length: 255, + comment: "หน่วยงานที่ออกคำสั่ง", + default: null, + }) + posNumCodeSit: string; + + @Column({ + nullable: true, + length: 255, + comment: "หน่วยงานที่ออกคำสั่ง(ตัวย่อ)", + default: null, + }) + posNumCodeSitAbb: string; + + @ManyToOne(() => ProfileSalary, (profileSalary) => profileSalary.profileSalaryTemps) @JoinColumn({ name: "salaryId" }) profileSalary: ProfileSalary;