From 7fca1e320bec2c348ec97f113a82b0ff58156eef Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 14 Jun 2024 13:27:02 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20relation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ChangePositionController.ts | 19 +++++++++++++++++++ src/entities/AuthRole.ts | 8 ++++---- src/entities/EmployeePosMaster.ts | 2 +- src/entities/PosMaster.ts | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/controllers/ChangePositionController.ts b/src/controllers/ChangePositionController.ts index 3e224b28..294ff7f6 100644 --- a/src/controllers/ChangePositionController.ts +++ b/src/controllers/ChangePositionController.ts @@ -178,6 +178,25 @@ export class ChangePositionController extends Controller { return new HttpSuccess({ data: changePosition, total }); } + /** + * API รายการรายชื่อผู้ที่ย้ายสับเปลี่ยนตำแหน่ง สถานะเลือกตำแหน่งแล้ว + * + * @summary รายการรายชื่อผู้ที่ย้ายสับเปลี่ยนตำแหน่ง สถานะเลือกตำแหน่งแล้ว (ADMIN) + * + */ + @Get("pending") + async getProfilePending() { + const profiles = await this.changePositionRepository.find({ + relations: ["profileChangePosition"], + where: { + profileChangePosition: { + status: "PENDING" + } + } + }); + return new HttpSuccess(profiles); + } + /** * API รายละเอียดรอบย้ายสับเปลี่ยนตำแหน่ง * diff --git a/src/entities/AuthRole.ts b/src/entities/AuthRole.ts index cb688bd4..8ee0b4a1 100644 --- a/src/entities/AuthRole.ts +++ b/src/entities/AuthRole.ts @@ -25,11 +25,11 @@ export class AuthRole extends EntityBase { @OneToMany(() => AuthRoleAttr, (authRoleAttr) => authRoleAttr.authRoleAttrForRole) authRoles: AuthRoleAttr[]; - @OneToOne(() => PosMaster, (posMaster) => posMaster.authRole) - posMaster: PosMaster; + @OneToMany(() => PosMaster, (posMaster) => posMaster.authRole) + posMaster: PosMaster[]; - @OneToOne(() => EmployeePosMaster, (posMasters) => posMasters.authRole) - posMasters: EmployeePosMaster; + @OneToMany(() => EmployeePosMaster, (posMasters) => posMasters.authRole) + posMasterEmp: EmployeePosMaster[]; } export class CreateAuthRole { diff --git a/src/entities/EmployeePosMaster.ts b/src/entities/EmployeePosMaster.ts index 9bec1b67..3b8a59d3 100644 --- a/src/entities/EmployeePosMaster.ts +++ b/src/entities/EmployeePosMaster.ts @@ -180,7 +180,7 @@ export class EmployeePosMaster extends EntityBase { }) authRoleId: string; - @OneToOne(() => AuthRole, (authRole) => authRole.posMasters) + @ManyToOne(() => AuthRole, (authRole) => authRole.posMasterEmp) @JoinColumn({ name: "authRoleId" }) authRole: AuthRole; diff --git a/src/entities/PosMaster.ts b/src/entities/PosMaster.ts index 521bec87..856d56c1 100644 --- a/src/entities/PosMaster.ts +++ b/src/entities/PosMaster.ts @@ -179,7 +179,7 @@ export class PosMaster extends EntityBase { }) authRoleId: string; - @OneToOne(() => AuthRole, (authRole) => authRole.posMaster) + @ManyToOne(() => AuthRole, (authRole) => authRole.posMaster) @JoinColumn({ name: "authRoleId" }) authRole: AuthRole;