search position

This commit is contained in:
kittapath 2025-01-06 17:34:47 +07:00
parent c7d7732fb6
commit 4b05629c29

View file

@ -337,6 +337,64 @@ export class PositionController extends Controller {
return new HttpSuccess(posDict.id);
}
/**
* API
*
* @summary ORG_029 - (ADMIN) #32
*
*/
@Post("position/search")
async findPositionSearch(
@Body()
requestBody: {
posLevel: string;
posType: string;
},
) {
let findPosDict = await this.posDictRepository.find({
relations: ["posType", "posLevel"],
where: {
posTypeId: requestBody.posType,
posLevelId: requestBody.posLevel,
},
order: {
posDictName: "ASC",
createdAt: "DESC",
posType: {
posTypeRank: "ASC",
createdAt: "DESC",
},
posLevel: {
posLevelRank: "ASC",
createdAt: "DESC",
},
},
});
const mapDataPosDict = await Promise.all(
findPosDict.map(async (item: any) => {
return {
id: item.id,
positionName: item.posDictName,
positionField: item.posDictField,
posTypeId: item.posTypeId,
posTypeName: item.posType == null ? null : item.posType.posTypeName,
posLevelId: item.posLevelId,
posLevelName: item.posLevel == null ? null : item.posLevel.posLevelName,
positionExecutiveField: item.posDictExecutiveField,
positionArea: item.posDictArea,
isSpecial: item.isSpecial,
positionIsSelected: false,
createdAt: item.createdAt,
lastUpdatedAt: item.lastUpdatedAt,
lastUpdateFullName: item.lastUpdateFullName,
};
}),
);
return new HttpSuccess(mapDataPosDict);
}
/**
* API
*