diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 3be43dca..42b9ad40 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -690,4 +690,58 @@ export class PositionController extends Controller { return error; } } + + /** + * API รายการอัตรากำลัง + * + * @summary ORG_053 - รายการอัตรากำลัง (ADMIN) #56 + * + */ + @Post("master/list") + async list( + @Body() + body: { + id: string; + type: number; + // isAll: boolean; + // page: number; + // pageSize: number; + // keyword?: string; + }, + ) { + try { + let typeCondition: any = {}; + + if (body.type === 0) { + typeCondition = { + orgRootId: body.id, + }; + } else if (body.type === 1) { + typeCondition = { + orgChild1Id: body.id, + }; + } else if (body.type === 2) { + typeCondition = { + orgChild2Id: body.id, + }; + } else if (body.type === 3) { + typeCondition = { + orgChild3Id: body.id, + }; + } else if (body.type === 4) { + typeCondition = { + orgChild4Id: body.id, + }; + } + + const posMaster = await this.posMasterRepository.find({ + where: typeCondition, + // relations: ["position"] + }); + + return new HttpSuccess(posMaster); + } catch (error) { + return error; + } + } } diff --git a/src/entities/PosMaster.ts b/src/entities/PosMaster.ts index 674860c1..2dbfa956 100644 --- a/src/entities/PosMaster.ts +++ b/src/entities/PosMaster.ts @@ -148,15 +148,15 @@ export class PosMaster extends EntityBase { orgChild1: OrgChild1; @ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.posMasters) - @JoinColumn({ name: "orgChild2" }) + @JoinColumn({ name: "orgChild2Id" }) orgChild2: OrgChild2; @ManyToOne(() => OrgChild3, (orgChild3) => orgChild3.posMasters) - @JoinColumn({ name: "orgChild3OrgChild3Id" }) + @JoinColumn({ name: "orgChild3Id" }) orgChild3: OrgChild3; @ManyToOne(() => OrgChild4, (orgChild4) => orgChild4.posMasters) - @JoinColumn({ name: "orgChild4" }) + @JoinColumn({ name: "orgChild4Id" }) orgChild4: OrgChild4; @OneToMany(() => Position, (position) => position.posMaster)