sort edu by level

This commit is contained in:
kittapath 2025-01-06 23:58:24 +07:00
parent 4b05629c29
commit 587fe5d5b6
11 changed files with 229 additions and 266 deletions

View file

@ -91,7 +91,6 @@ export class ProfileEmployeeController extends Controller {
private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather);
private trainingRepository = AppDataSource.getRepository(ProfileTraining);
private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline);
private educationRepository = AppDataSource.getRepository(ProfileEducation);
private salaryRepository = AppDataSource.getRepository(ProfileSalary);
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
private child1Repository = AppDataSource.getRepository(OrgChild1);
@ -105,7 +104,7 @@ export class ProfileEmployeeController extends Controller {
private employmentHistoryRepository = AppDataSource.getRepository(
ProfileEmployeeEmploymentHistory,
);
private profileEducationRepository = AppDataSource.getRepository(ProfileEducation);
private profileEducationRepo = AppDataSource.getRepository(ProfileEducation);
private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave);
private positionRepository = AppDataSource.getRepository(Position);
@ -226,10 +225,10 @@ export class ProfileEmployeeController extends Controller {
let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`;
let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`;
const educations = await this.educationRepository.find({
const educations = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileEmployeeId: id },
order: { lastUpdatedAt: "DESC" },
order: { level: "ASC" },
});
const Education =
educations && educations.length > 0
@ -512,11 +511,11 @@ export class ProfileEmployeeController extends Controller {
},
];
const education_raw = await this.educationRepository.find({
const education_raw = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileEmployeeId: id },
// order: { lastUpdatedAt: "DESC" },
order: { createdAt: "ASC" },
order: { level: "ASC" },
});
const educations =
education_raw.length > 0
@ -2462,9 +2461,9 @@ export class ProfileEmployeeController extends Controller {
(x) => x.orgRevisionId == findRevision.id,
)?.posMasterNo;
const latestProfileEducation = await this.profileEducationRepository.findOne({
const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileEmployeeId: item.id },
order: { endDate: "DESC" },
order: { level: "ASC" },
});
return {
@ -2510,28 +2509,6 @@ export class ProfileEmployeeController extends Controller {
latestProfileEducation != null && latestProfileEducation.educationLevel != null
? latestProfileEducation.educationLevel
: null,
// ? {
// id: latestProfileEducation.id,
// degree: latestProfileEducation.degree,
// country: latestProfileEducation.country,
// duration: latestProfileEducation.duration,
// durationYear: latestProfileEducation.durationYear,
// field: latestProfileEducation.field,
// finishDate: latestProfileEducation.finishDate,
// fundName: latestProfileEducation.fundName,
// gpa: latestProfileEducation.gpa,
// institute: latestProfileEducation.institute,
// other: latestProfileEducation.other,
// startDate: latestProfileEducation.startDate,
// endDate: latestProfileEducation.endDate,
// educationLevel: latestProfileEducation.educationLevel,
// positionPath: latestProfileEducation.positionPath,
// positionPathId: latestProfileEducation.positionPathId,
// isDate: latestProfileEducation.isDate,
// isEducation: latestProfileEducation.isEducation,
// note: latestProfileEducation.note,
// }
// : null,
};
}),
);
@ -4103,9 +4080,9 @@ export class ProfileEmployeeController extends Controller {
(x) => x.orgRevisionId == findRevision.id,
)?.posMasterNo;
const latestProfileEducation = await this.profileEducationRepository.findOne({
const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileEmployeeId: item.id },
order: { endDate: "DESC" },
order: { level: "ASC" },
});
return {
@ -4169,7 +4146,7 @@ export class ProfileEmployeeController extends Controller {
// order: "DESC",
// },
profileEducations: {
createdAt: "DESC",
level: "ASC",
},
},
});
@ -4295,7 +4272,7 @@ export class ProfileEmployeeController extends Controller {
salary: profile.amount,
education:
profile && profile.profileEducations.length > 0
? `${profile.profileEducations[0].degree ?? ""}/${profile.profileEducations[0].field ?? ""}`
? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
: "-",
};