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

@ -99,9 +99,8 @@ export class ProfileController extends Controller {
private profileFamilyFatherHistoryRepo = AppDataSource.getRepository(ProfileFamilyFatherHistory);
private trainingRepository = AppDataSource.getRepository(ProfileTraining);
private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline);
private educationRepository = AppDataSource.getRepository(ProfileEducation);
private salaryRepository = AppDataSource.getRepository(ProfileSalary);
private profileEducationRepository = AppDataSource.getRepository(ProfileEducation);
private profileEducationRepo = AppDataSource.getRepository(ProfileEducation);
private provinceRepo = AppDataSource.getRepository(Province);
private districtRepo = AppDataSource.getRepository(District);
private subDistrictRepo = AppDataSource.getRepository(SubDistrict);
@ -254,10 +253,10 @@ export class ProfileController extends Controller {
},
];
const educations = await this.educationRepository.find({
const educations = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileId: id },
order: { startDate: "ASC" },
order: { level: "ASC" },
});
const Education =
educations && educations.length > 0
@ -544,11 +543,11 @@ export class ProfileController extends Controller {
},
];
const education_raw = await this.educationRepository.find({
const education_raw = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileId: id },
// order: { lastUpdatedAt: "DESC" },
order: { createdAt: "ASC" },
order: { level: "ASC" },
});
const educations =
education_raw.length > 0
@ -5590,7 +5589,7 @@ export class ProfileController extends Controller {
// order: "DESC",
// },
profileEducations: {
createdAt: "DESC",
level: "ASC",
},
},
});
@ -5772,7 +5771,7 @@ export class ProfileController extends Controller {
salary: profile ? profile.amount : null,
education:
profile && profile.profileEducations.length > 0
? `${profile.profileEducations[0].degree ?? ""}/${profile.profileEducations[0].field ?? ""}`
? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
: "-",
};
@ -5829,7 +5828,7 @@ export class ProfileController extends Controller {
@Get("citizenid/position/{id}")
async getProfileByCitizenId(@Request() request: RequestWithUser, @Path() id: string) {
const profile = await this.profileRepo.findOne({
where: { citizenId: id, isActive: true },
where: { citizenId: id, isActive: true, profileEducations: { isUse: true } },
relations: [
"posLevel",
"posType",
@ -5840,11 +5839,15 @@ export class ProfileController extends Controller {
"current_holders.orgChild3",
"current_holders.orgChild4",
"profileSalary",
"profileEducations",
],
order: {
profileSalary: {
order: "DESC",
},
profileEducations: {
level: "ASC",
},
},
});
if (!profile) {
@ -5934,6 +5937,10 @@ export class ProfileController extends Controller {
amount: profile ? profile.amount : null,
positionSalaryAmount: profile ? profile.positionSalaryAmount : null,
mouthSalaryAmount: profile ? profile.mouthSalaryAmount : null,
education:
profile && profile.profileEducations.length > 0
? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
: "",
};
if (_profile.child4Id != null) {
@ -5984,7 +5991,7 @@ export class ProfileController extends Controller {
],
order: {
profileEducations: {
createdAt: "DESC",
level: "ASC",
},
},
});
@ -6073,7 +6080,7 @@ export class ProfileController 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 ?? ""}`
: "-",
};
@ -6396,9 +6403,9 @@ export class ProfileController extends Controller {
(x) => x.orgRevisionId == findRevision.id,
)?.posMasterNo;
const latestProfileEducation = await this.profileEducationRepository.findOne({
const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileId: item.id },
order: { endDate: "DESC" },
order: { level: "ASC" },
});
return {
@ -6444,28 +6451,6 @@ export class ProfileController 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,
};
}),
);
@ -7922,9 +7907,9 @@ export class ProfileController extends Controller {
(x) => x.orgRevisionId == findRevision.id,
)?.posMasterNo;
const latestProfileEducation = await this.profileEducationRepository.findOne({
const latestProfileEducation = await this.profileEducationRepo.findOne({
where: { profileId: item.id },
order: { endDate: "DESC" },
order: { level: "ASC" },
});
return {