diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 618ed125..392b7924 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -1236,7 +1236,11 @@ export class PositionController extends Controller { @Request() request: RequestWithUser, ) { await new permission().PermissionUpdate(request, "SYS_ORG"); - const posMaster = await this.posMasterRepository.findOne({ where: { id: id } }); + const posMaster = await this.posMasterRepository.findOne({ + relations: ["positions"], + where: { id: id } + } + ); if (!posMaster) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง"); } @@ -1399,6 +1403,11 @@ export class PositionController extends Controller { match.positionIsSelected = x.positionIsSelected??false; return match }else{ + x.id = x.id ?? undefined; + x.posMasterId = posMaster.id; + x.positionName = x.posDictName; + x.positionField = x.posDictField; + x.posExecutiveId = x.posExecutiveId || null x.createdUserId = request.user.sub; x.createdFullName = request.user.name; x.lastUpdateUserId = request.user.sub; diff --git a/src/entities/PosDict.ts b/src/entities/PosDict.ts index a03fcbda..2a078c99 100644 --- a/src/entities/PosDict.ts +++ b/src/entities/PosDict.ts @@ -78,6 +78,9 @@ export class PosDict extends EntityBase { } export class CreatePosDict { + @Column() + id?: string | null; + @Column() posDictName: string | null; diff --git a/src/entities/PosMaster.ts b/src/entities/PosMaster.ts index bff30aae..59018baa 100644 --- a/src/entities/PosMaster.ts +++ b/src/entities/PosMaster.ts @@ -266,9 +266,6 @@ export class PosMaster extends EntityBase { } export class CreatePosMaster { - @Column() - id: string | null; - @Column() posMasterNoPrefix: string | null;