migrate (ตัด relation ฟิลด์ posType, posLevel, empPosType, empPosLevel)
This commit is contained in:
parent
60781ea254
commit
dbfc678e92
6 changed files with 255 additions and 178 deletions
|
|
@ -370,44 +370,44 @@ export class DevelopmentController extends Controller {
|
|||
await Promise.all(
|
||||
requestBody.positions.map(async (x) => {
|
||||
const _data = Object.assign(new PlannedGoalPosition(), x);
|
||||
if (x.posTypePlannedId != null) {
|
||||
let checkId:any
|
||||
if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
checkId = await this.empPosTypeRepository.findOne({
|
||||
where: { id: x.posTypePlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
|
||||
}
|
||||
}
|
||||
else {
|
||||
checkId = await this.posTypeRepository.findOne({
|
||||
where: { id: x.posTypePlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x.posLevelPlannedId != null) {
|
||||
let checkId:any
|
||||
if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
checkId = await this.empPosLevelRepository.findOne({
|
||||
where: { id: x.posLevelPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
|
||||
}
|
||||
}
|
||||
else {
|
||||
checkId = await this.posLevelRepository.findOne({
|
||||
where: { id: x.posLevelPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (x.posTypePlannedId != null) {
|
||||
// let checkId:any
|
||||
// if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
// checkId = await this.empPosTypeRepository.findOne({
|
||||
// where: { id: x.posTypePlannedId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// checkId = await this.posTypeRepository.findOne({
|
||||
// where: { id: x.posTypePlannedId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (x.posLevelPlannedId != null) {
|
||||
// let checkId:any
|
||||
// if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
// checkId = await this.empPosLevelRepository.findOne({
|
||||
// where: { id: x.posLevelPlannedId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// checkId = await this.posLevelRepository.findOne({
|
||||
// where: { id: x.posLevelPlannedId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
const before = structuredClone(development);
|
||||
_data.createdUserId = request.user.sub;
|
||||
_data.createdFullName = request.user.name;
|
||||
|
|
@ -492,32 +492,32 @@ export class DevelopmentController extends Controller {
|
|||
if (!development) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||
}
|
||||
if (requestBody.posTypeActualId != null) {
|
||||
// addLogSequence(request, {
|
||||
// action: "database",
|
||||
// status: "success",
|
||||
// description: "Get Position Type.",
|
||||
// });
|
||||
const checkId = await this.posTypeRepository.findOne({
|
||||
where: { id: requestBody.posTypeActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
|
||||
}
|
||||
}
|
||||
if (requestBody.posLevelActualId != null) {
|
||||
// addLogSequence(request, {
|
||||
// action: "database",
|
||||
// status: "success",
|
||||
// description: "Get Position Level.",
|
||||
// });
|
||||
const checkId = await this.posLevelRepository.findOne({
|
||||
where: { id: requestBody.posLevelActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||
}
|
||||
}
|
||||
// if (requestBody.posTypeActualId != null) {
|
||||
// // addLogSequence(request, {
|
||||
// // action: "database",
|
||||
// // status: "success",
|
||||
// // description: "Get Position Type.",
|
||||
// // });
|
||||
// const checkId = await this.posTypeRepository.findOne({
|
||||
// where: { id: requestBody.posTypeActualId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
|
||||
// }
|
||||
// }
|
||||
// if (requestBody.posLevelActualId != null) {
|
||||
// // addLogSequence(request, {
|
||||
// // action: "database",
|
||||
// // status: "success",
|
||||
// // description: "Get Position Level.",
|
||||
// // });
|
||||
// const checkId = await this.posLevelRepository.findOne({
|
||||
// where: { id: requestBody.posLevelActualId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||
// }
|
||||
// }
|
||||
const before = structuredClone(development);
|
||||
const data = Object.assign(new ActualGoal(), requestBody);
|
||||
data.createdUserId = request.user.sub;
|
||||
|
|
@ -633,44 +633,44 @@ export class DevelopmentController extends Controller {
|
|||
await Promise.all(
|
||||
requestBody.positions.map(async (x) => {
|
||||
const _data = Object.assign(new PlannedGoalPosition(), x);
|
||||
if (x.posTypePlannedId != null) {
|
||||
let checkId:any
|
||||
if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
checkId = await this.empPosTypeRepository.findOne({
|
||||
where: { id: x.posTypePlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
|
||||
}
|
||||
}
|
||||
else {
|
||||
checkId = await this.posTypeRepository.findOne({
|
||||
where: { id: x.posTypePlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x.posLevelPlannedId != null) {
|
||||
let checkId:any
|
||||
if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
checkId = await this.empPosLevelRepository.findOne({
|
||||
where: { id: x.posLevelPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
|
||||
}
|
||||
}
|
||||
else {
|
||||
checkId = await this.posLevelRepository.findOne({
|
||||
where: { id: x.posLevelPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (x.posTypePlannedId != null) {
|
||||
// let checkId:any
|
||||
// if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
// checkId = await this.empPosTypeRepository.findOne({
|
||||
// where: { id: x.posTypePlannedId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// checkId = await this.posTypeRepository.findOne({
|
||||
// where: { id: x.posTypePlannedId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (x.posLevelPlannedId != null) {
|
||||
// let checkId:any
|
||||
// if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
// checkId = await this.empPosLevelRepository.findOne({
|
||||
// where: { id: x.posLevelPlannedId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// checkId = await this.posLevelRepository.findOne({
|
||||
// where: { id: x.posLevelPlannedId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
_data.createdUserId = request.user.sub;
|
||||
_data.createdFullName = request.user.name;
|
||||
_data.lastUpdateUserId = request.user.sub;
|
||||
|
|
@ -759,32 +759,32 @@ export class DevelopmentController extends Controller {
|
|||
if (!development) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||
}
|
||||
if (requestBody.posTypeActualId != null) {
|
||||
// addLogSequence(request, {
|
||||
// action: "database",
|
||||
// status: "success",
|
||||
// description: "Get Position Type.",
|
||||
// });
|
||||
const checkId = await this.posTypeRepository.findOne({
|
||||
where: { id: requestBody.posTypeActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
|
||||
}
|
||||
}
|
||||
if (requestBody.posLevelActualId != null) {
|
||||
// addLogSequence(request, {
|
||||
// action: "database",
|
||||
// status: "success",
|
||||
// description: "Get Position Level.",
|
||||
// });
|
||||
const checkId = await this.posLevelRepository.findOne({
|
||||
where: { id: requestBody.posLevelActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||
}
|
||||
}
|
||||
// if (requestBody.posTypeActualId != null) {
|
||||
// // addLogSequence(request, {
|
||||
// // action: "database",
|
||||
// // status: "success",
|
||||
// // description: "Get Position Type.",
|
||||
// // });
|
||||
// const checkId = await this.posTypeRepository.findOne({
|
||||
// where: { id: requestBody.posTypeActualId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
|
||||
// }
|
||||
// }
|
||||
// if (requestBody.posLevelActualId != null) {
|
||||
// // addLogSequence(request, {
|
||||
// // action: "database",
|
||||
// // status: "success",
|
||||
// // description: "Get Position Level.",
|
||||
// // });
|
||||
// const checkId = await this.posLevelRepository.findOne({
|
||||
// where: { id: requestBody.posLevelActualId },
|
||||
// });
|
||||
// if (!checkId) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||
// }
|
||||
// }
|
||||
const before = structuredClone(development);
|
||||
Object.assign(development, requestBody);
|
||||
development.lastUpdateUserId = request.user.sub;
|
||||
|
|
@ -2164,17 +2164,18 @@ export class DevelopmentController extends Controller {
|
|||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT");
|
||||
const getDevelopment = await this.developmentRepository.findOne({
|
||||
where: { id: id },
|
||||
//posTypeActual
|
||||
relations: [
|
||||
"developmentActualPeoples",
|
||||
"developmentPlannedPeoples",
|
||||
"developmentActualGoals",
|
||||
"developmentActualGoals.posTypeActual",
|
||||
"developmentActualGoals.posLevelActual",
|
||||
// "developmentActualGoals.posTypeActual",
|
||||
// "developmentActualGoals.posLevelActual",
|
||||
"developmentActualGoals",
|
||||
"developmentPlannedGoals",
|
||||
"developmentPlannedGoals.plannedGoalPositions",
|
||||
"developmentPlannedGoals.plannedGoalPositions.posTypePlanned",
|
||||
"developmentPlannedGoals.plannedGoalPositions.posLevelPlanned",
|
||||
// "developmentPlannedGoals.plannedGoalPositions.posTypePlanned",
|
||||
// "developmentPlannedGoals.plannedGoalPositions.posLevelPlanned",
|
||||
],
|
||||
});
|
||||
if (!getDevelopment) {
|
||||
|
|
@ -2212,10 +2213,12 @@ export class DevelopmentController extends Controller {
|
|||
groupTarget: x.groupTarget,
|
||||
groupTargetSub: x.groupTargetSub,
|
||||
position: x.position,
|
||||
posTypeId: x.posTypeActualId,
|
||||
posType: x.posTypeActual == null ? null : x.posTypeActual.posTypeName,
|
||||
posLevelId: x.posLevelActualId,
|
||||
posLevel: x.posLevelActual == null ? null : x.posLevelActual.posLevelName,
|
||||
// posTypeId: x.posTypeActualId,
|
||||
// posType: x.posTypeActual == null ? null : x.posTypeActual.posTypeName,
|
||||
// posLevelId: x.posLevelActualId,
|
||||
// posLevel: x.posLevelActual == null ? null : x.posLevelActual.posLevelName,
|
||||
posType: x.posTypeActual,
|
||||
posLevel: x.posLevelActual,
|
||||
type: x.type,
|
||||
amount: x.amount,
|
||||
})),
|
||||
|
|
@ -2237,10 +2240,12 @@ export class DevelopmentController extends Controller {
|
|||
id: y.id,
|
||||
position: y.position,
|
||||
posExecutive: y.posExecutive,
|
||||
posTypeId: y.posTypePlannedId,
|
||||
posType: y.posTypePlanned == null ? null : y.posTypePlanned.posTypeName,
|
||||
posLevelId: y.posLevelPlannedId,
|
||||
posLevel: y.posLevelPlanned == null ? null : y.posLevelPlanned.posLevelName,
|
||||
// posTypeId: y.posTypePlannedId,
|
||||
// posType: y.posTypePlanned == null ? null : y.posTypePlanned.posTypeName,
|
||||
// posLevelId: y.posLevelPlannedId,
|
||||
// posLevel: y.posLevelPlanned == null ? null : y.posLevelPlanned.posLevelName,
|
||||
posType: y.posTypePlanned,
|
||||
posLevel: y.posLevelPlanned,
|
||||
})),
|
||||
amount: x.amount,
|
||||
})),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue