no message

This commit is contained in:
Kittapath 2024-03-15 11:31:23 +07:00
parent 1e465d049c
commit 36e8a796c7

View file

@ -178,45 +178,81 @@ export class EmployeePositionController extends Controller {
return new HttpSuccess();
}
// /**
// * API รายละเอียดข้อมูลตำแหน่งลูกจ้างประจำ
// *
// * @summary ORG_037 - รายละเอียดข้อมูลตำแหน่งลูกจ้างประจำ (ADMIN) #
// *
// */
// @Get("position/{id}")
// async GetEmpPositionById(@Path() id: string) {
// const empPosDict = await this.employeePosDictRepository.findOne({
// select: ["id", "posDictName", "posTypeId", "posLevelId"],
// where: { id: id },
// });
// if (!empPosDict) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานนี้");
// }
// const empPosType = await this.employeePosTypeRepository.findOne({
// select: ["id", "posTypeName", "posTypeRank", "posTypeShortName"],
// where: { id: empPosDict.posTypeId },
// });
// if (!empPosType) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงานนี้");
// }
// const empPosLevel = await this.employeePosLevelRepository.findOne({
// select: ["id", "posLevelName", "posLevelRank"],
// where: { id: empPosDict.posLevelId },
// });
// if (!empPosLevel) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งลูกจ้างประจำนี้");
// }
// const mapData = {
// id: empPosDict.id,
// posDictName: empPosDict.posDictName, //ชื่อตำแหน่ง
// posTypeId: empPosType.id,
// posTypeName: empPosType.posTypeName, //กลุ่มงาน
// posLeveId: empPosLevel.id,
// posLevelName: empPosLevel.posLevelName, //ระดับขั้นงาน
// };
// return new HttpSuccess(mapData);
// }
/**
* API
* API
*
* @summary ORG_037 - (ADMIN) #
*
*/
@Get("position/{id}")
async GetEmpPositionById(@Path() id: string) {
const empPosDict = await this.employeePosDictRepository.findOne({
select: ["id", "posDictName", "posTypeId", "posLevelId"],
where: { id: id },
async detailPosition(@Path() id: string) {
const posMaster = await this.employeePosMasterRepository.findOne({
where: { id },
});
if (!empPosDict) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานนี้");
if (!posMaster) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const empPosType = await this.employeePosTypeRepository.findOne({
select: ["id", "posTypeName", "posTypeRank", "posTypeShortName"],
where: { id: empPosDict.posTypeId },
const positions = await this.employeePositionRepository.find({
where: { posMasterId: posMaster.id },
relations: ["posType", "posLevel"],
order: { lastUpdatedAt: "ASC" },
});
if (!empPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงานนี้");
}
const empPosLevel = await this.employeePosLevelRepository.findOne({
select: ["id", "posLevelName", "posLevelRank"],
where: { id: empPosDict.posLevelId },
});
if (!empPosLevel) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งลูกจ้างประจำนี้");
}
const mapData = {
id: empPosDict.id,
posDictName: empPosDict.posDictName, //ชื่อตำแหน่ง
posTypeId: empPosType.id,
posTypeName: empPosType.posTypeName, //กลุ่มงาน
posLeveId: empPosLevel.id,
posLevelName: empPosLevel.posLevelName, //ระดับขั้นงาน
const formattedData = {
id: posMaster.id,
posMasterNoPrefix: posMaster.posMasterNoPrefix,
posMasterNo: posMaster.posMasterNo,
posMasterNoSuffix: posMaster.posMasterNoSuffix,
positions: positions.map((position) => ({
id: position.id,
positionName: position.positionName,
posTypeId: position.posTypeId,
posTypeName: position.posType == null ? null : position.posType.posTypeName,
posLevelId: position.posLevelId,
posLevelName: position.posLevel == null ? null : position.posLevel.posLevelName,
positionIsSelected: position.positionIsSelected,
})),
};
return new HttpSuccess(mapData);
return new HttpSuccess(formattedData);
}
/**