Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
35ba5b91f3
1 changed files with 35 additions and 7 deletions
|
|
@ -703,10 +703,10 @@ export class PositionController extends Controller {
|
||||||
body: {
|
body: {
|
||||||
id: string;
|
id: string;
|
||||||
type: number;
|
type: number;
|
||||||
// isAll: boolean;
|
isAll: boolean;
|
||||||
// page: number;
|
page: number;
|
||||||
// pageSize: number;
|
pageSize: number;
|
||||||
// keyword?: string;
|
keyword?: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -736,10 +736,38 @@ export class PositionController extends Controller {
|
||||||
|
|
||||||
const posMaster = await this.posMasterRepository.find({
|
const posMaster = await this.posMasterRepository.find({
|
||||||
where: typeCondition,
|
where: typeCondition,
|
||||||
// relations: ["position"]
|
|
||||||
});
|
});
|
||||||
|
if (!posMaster || posMaster.length === 0 ) {
|
||||||
return new HttpSuccess(posMaster);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
const formattedData = await Promise.all(posMaster.map(async (posMaster) => {
|
||||||
|
const positions = await this.positionRepository.find({
|
||||||
|
where: { posMasterId: posMaster.id },
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: posMaster.id,
|
||||||
|
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||||
|
posMasterNo: posMaster.posMasterNo,
|
||||||
|
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||||
|
positions: positions.map((position) => ({
|
||||||
|
id: position.id,
|
||||||
|
positionName: position.positionName,
|
||||||
|
positionField: position.positionField,
|
||||||
|
posTypeId: position.posTypeId,
|
||||||
|
posTypeName: position.posType == null ? null : position.posType.posTypeName,
|
||||||
|
posLevelId: position.posLevelId,
|
||||||
|
posLevelName: position.posLevel == null ? null : position.posLevel.posLevelName,
|
||||||
|
posExecutiveId: position.posExecutiveId,
|
||||||
|
posExecutiveName:
|
||||||
|
position.posExecutive == null ? null : position.posExecutive.posExecutiveName,
|
||||||
|
positionExecutiveField: position.positionExecutiveField,
|
||||||
|
positionArea: position.positionArea,
|
||||||
|
positionIsSelected: position.positionIsSelected,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
return new HttpSuccess(formattedData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue