Migration add fields isDeleted #210

This commit is contained in:
harid 2026-02-12 11:47:53 +07:00
parent 3c9e3a1bb6
commit 65e3740cc2
82 changed files with 499 additions and 180 deletions

View file

@ -322,8 +322,8 @@ export class ProfileController extends Controller {
];
const educations = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileId: id },
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"],
where: { profileId: id, isDeleted: false },
order: { level: "ASC" },
});
const Education =
@ -575,8 +575,8 @@ export class ProfileController extends Controller {
let _child4 = child4?.orgChild4Name;
const cert_raw = await this.certificateRepository.find({
where: { profileId: id },
select: ["certificateType", "issuer", "certificateNo", "issueDate"],
select: ["certificateType", "issuer", "certificateNo", "issueDate", "isDeleted"],
where: { profileId: id, isDeleted: false },
order: { createdAt: "ASC" },
});
const certs =
@ -596,8 +596,8 @@ export class ProfileController extends Controller {
},
];
const training_raw = await this.trainingRepository.find({
select: ["startDate", "endDate", "place", "department", "name"],
where: { profileId: id },
select: ["startDate", "endDate", "place", "department", "name", "isDeleted"],
where: { profileId: id, isDeleted: false },
order: { createdAt: "ASC" },
});
const trainings =
@ -633,8 +633,8 @@ export class ProfileController extends Controller {
];
const discipline_raw = await this.disciplineRepository.find({
select: ["refCommandDate", "refCommandNo", "detail"],
where: { profileId: id },
select: ["refCommandDate", "refCommandNo", "detail", "isDeleted"],
where: { profileId: id, isDeleted: false },
order: { createdAt: "ASC" },
});
const disciplines =
@ -655,8 +655,8 @@ export class ProfileController extends Controller {
];
const education_raw = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileId: id },
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"],
where: { profileId: id, isDeleted: false },
// order: { lastUpdatedAt: "DESC" },
order: { level: "ASC" },
});
@ -756,7 +756,7 @@ export class ProfileController extends Controller {
insigniaType: true,
},
},
where: { profileId: id },
where: { profileId: id, isDeleted: false },
order: { receiveDate: "ASC" },
});
const insignias =
@ -796,7 +796,7 @@ export class ProfileController extends Controller {
const leave_raw = await this.profileLeaveRepository.find({
relations: { leaveType: true },
where: { profileId: id },
where: { profileId: id, isDeleted: false },
order: { dateLeaveStart: "ASC" },
});
const leaves =
@ -1052,8 +1052,8 @@ export class ProfileController extends Controller {
let _child4 = child4?.orgChild4Name;
const cert_raw = await this.certificateRepository.find({
where: { profileId: id },
select: ["certificateType", "issuer", "certificateNo", "issueDate", "expireDate"],
select: ["certificateType", "issuer", "certificateNo", "issueDate", "expireDate", "isDeleted"],
where: { profileId: id, isDeleted: false },
order: { createdAt: "ASC" },
});
const certs =
@ -1087,8 +1087,8 @@ export class ProfileController extends Controller {
},
];
const training_raw = await this.trainingRepository.find({
select: ["place", "department", "name", "duration"],
where: { profileId: id },
select: ["place", "department", "name", "duration", "isDeleted"],
where: { profileId: id, isDeleted: false },
order: { createdAt: "ASC" },
});
const trainings =
@ -1109,8 +1109,8 @@ export class ProfileController extends Controller {
];
const discipline_raw = await this.disciplineRepository.find({
select: ["refCommandDate", "refCommandNo", "detail", "level"],
where: { profileId: id },
select: ["refCommandDate", "refCommandNo", "detail", "level", "isDeleted"],
where: { profileId: id, isDeleted: false },
order: { createdAt: "ASC" },
});
const disciplines =
@ -1135,6 +1135,7 @@ export class ProfileController extends Controller {
const education_raw = await this.profileEducationRepo
.createQueryBuilder("education")
.where("education.profileId = :profileId", { profileId: id })
.andWhere("education.isDeleted = :isDeleted", { isDeleted: false })
.orderBy("CASE WHEN education.isEducation = true THEN 1 ELSE 2 END", "ASC")
.addOrderBy("education.level", "ASC")
.getMany();
@ -1245,13 +1246,14 @@ export class ProfileController extends Controller {
"page",
"refCommandDate",
"note",
"isDeleted"
],
relations: {
insignia: {
insigniaType: true,
},
},
where: { profileId: id },
where: { profileId: id, isDeleted: false },
order: { receiveDate: "ASC" },
});
const insignias =
@ -1294,6 +1296,7 @@ export class ProfileController extends Controller {
.createQueryBuilder("profileLeave")
.leftJoinAndSelect("profileLeave.leaveType", "leaveType")
.select([
"profileLeave.isDeleted",
"profileLeave.leaveTypeId",
"leaveType.name as name",
"leaveType.code as code",
@ -1303,6 +1306,7 @@ export class ProfileController extends Controller {
])
.addSelect("SUM(profileLeave.leaveDays)", "totalLeaveDays")
.where("profileLeave.profileId = :profileId", { profileId: id })
.andWhere("profileLeave.isDeleted = :isDeleted", { isDeleted: false })
.andWhere("profileLeave.status = :status", { status: "approve" })
.groupBy("profileLeave.leaveTypeId")
.orderBy("code", "ASC")
@ -1354,6 +1358,7 @@ export class ProfileController extends Controller {
.createQueryBuilder("profileLeave")
.leftJoinAndSelect("profileLeave.leaveType", "leaveType")
.select([
"profileLeave.isDeleted AS isDeleted",
"profileLeave.dateLeaveStart AS dateLeaveStart",
"profileLeave.dateLeaveEnd AS dateLeaveEnd",
"profileLeave.leaveDays AS leaveDays",
@ -1361,6 +1366,7 @@ export class ProfileController extends Controller {
"leaveType.name as name",
])
.where("profileLeave.profileId = :profileId", { profileId: id })
.andWhere("profileLeave.isDeleted = :isDeleted", { isDeleted: false })
.andWhere("leaveType.code IN (:...codes)", { codes: ["LV-008", "LV-009", "LV-010"] })
.andWhere("profileLeave.status = :status", { status: "approve" })
.orderBy("leaveType.code", "ASC")
@ -1387,7 +1393,7 @@ export class ProfileController extends Controller {
},
];
const children_raw = await this.profileChildrenRepository.find({
where: { profileId: id },
where: { profileId: id, isDeleted: false },
});
const children =
children_raw.length > 0
@ -1410,7 +1416,7 @@ export class ProfileController extends Controller {
},
];
const changeName_raw = await this.changeNameRepository.find({
where: { profileId: id },
where: { profileId: id, isDeleted: false },
order: { createdAt: "ASC" },
});
const changeName =
@ -1504,13 +1510,13 @@ export class ProfileController extends Controller {
];
const actposition_raw = await this.profileActpositionRepo.find({
select: ["dateStart", "dateEnd", "position"],
select: ["dateStart", "dateEnd", "position", "isDeleted"],
where: { profileId: id, isDeleted: false },
order: { createdAt: "ASC" },
});
const assistance_raw = await this.profileAssistanceRepository.find({
select: ["dateStart", "dateEnd", "commandName", "agency", "document"],
where: { profileId: id },
select: ["dateStart", "dateEnd", "commandName", "agency", "document", "isDeleted"],
where: { profileId: id, isDeleted: false },
order: { createdAt: "ASC" },
});
@ -1566,7 +1572,7 @@ export class ProfileController extends Controller {
];
const actposition = [..._actposition, ..._assistance];
const duty_raw = await this.dutyRepository.find({
where: { profileId: id },
where: { profileId: id, isDeleted: false },
order: { createdAt: "ASC" },
});
const duty =
@ -1593,7 +1599,7 @@ export class ProfileController extends Controller {
},
];
const assessments_raw = await this.profileAssessmentsRepository.find({
where: { profileId: id },
where: { profileId: id, isDeleted: false },
order: { createdAt: "ASC" },
});
const assessments =
@ -9093,7 +9099,7 @@ export class ProfileController extends Controller {
)?.posMasterNo;
const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileId: item.id },
where: { profileId: item.id, isDeleted: false },
order: { level: "ASC" },
});
@ -11106,7 +11112,7 @@ export class ProfileController extends Controller {
}
const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileId: item.id },
where: { profileId: item.id, isDeleted: false },
order: { level: "ASC" },
});