education controller, service, command
This commit is contained in:
parent
5368a96d0f
commit
fded8a663a
29 changed files with 884 additions and 5 deletions
|
@ -8,6 +8,7 @@ import DatabaseActionException from "../exceptions/databaseActionException";
|
|||
import { availableTemplates } from "../type/templateTypes";
|
||||
import SettingHelper from "./settingsHelper";
|
||||
import { LoginRoutineEnum } from "../enums/loginRoutineEnum";
|
||||
import { education } from "../entity/configuration/education";
|
||||
|
||||
export type BackupSection =
|
||||
| "member"
|
||||
|
@ -55,6 +56,7 @@ export default abstract class BackupHelper {
|
|||
"member_executive_positions",
|
||||
"membership",
|
||||
"communication",
|
||||
"member_educations",
|
||||
],
|
||||
memberBase: [
|
||||
"award",
|
||||
|
@ -63,6 +65,7 @@ export default abstract class BackupHelper {
|
|||
"membership_status",
|
||||
"communication_type",
|
||||
"salutation",
|
||||
"education",
|
||||
],
|
||||
protocol: [
|
||||
"protocol",
|
||||
|
@ -246,6 +249,8 @@ export default abstract class BackupHelper {
|
|||
.leftJoin("positions.executivePosition", "executivePosition")
|
||||
.leftJoin("member.qualifications", "qualifications")
|
||||
.leftJoin("qualifications.qualification", "qualification")
|
||||
.leftJoin("member.educations", "educations")
|
||||
.leftJoin("educations.education", "education")
|
||||
.select([
|
||||
...(collectIds ? ["member.id"] : []),
|
||||
"member.firstname",
|
||||
|
@ -253,6 +258,7 @@ export default abstract class BackupHelper {
|
|||
"member.nameaffix",
|
||||
"member.birthdate",
|
||||
"member.internalId",
|
||||
"member.note",
|
||||
])
|
||||
.addSelect(["salutation.salutation"])
|
||||
.addSelect([
|
||||
|
@ -280,6 +286,14 @@ export default abstract class BackupHelper {
|
|||
"qualification.qualification",
|
||||
"qualification.description",
|
||||
])
|
||||
.addSelect([
|
||||
"educations.start",
|
||||
"educations.end",
|
||||
"educations.place",
|
||||
"educations.note",
|
||||
"education.education",
|
||||
"education.description",
|
||||
])
|
||||
.getMany();
|
||||
}
|
||||
private static async getMemberBase(): Promise<{ [key: string]: Array<any> }> {
|
||||
|
@ -294,6 +308,7 @@ export default abstract class BackupHelper {
|
|||
qualification: await dataSource
|
||||
.getRepository("qualification")
|
||||
.find({ select: { qualification: true, description: true } }),
|
||||
education: await dataSource.getRepository("education").find({ select: { education: true, description: true } }),
|
||||
};
|
||||
}
|
||||
private static async getProtocol(collectIds: boolean): Promise<Array<any>> {
|
||||
|
@ -344,6 +359,7 @@ export default abstract class BackupHelper {
|
|||
"newsletter.newsletterText",
|
||||
"newsletter.newsletterSignatur",
|
||||
"newsletter.isSent",
|
||||
"newsletter.createdAt",
|
||||
])
|
||||
.addSelect(["dates.calendarId", "dates.diffTitle", "dates.diffDescription"])
|
||||
.addSelect(["recipients.memberId"])
|
||||
|
@ -534,6 +550,13 @@ export default abstract class BackupHelper {
|
|||
.map((d) => ({ ...d, id: undefined })),
|
||||
"qualification"
|
||||
),
|
||||
education: uniqBy(
|
||||
data
|
||||
.map((d) => (d.education ?? []).map((c: any) => c.education))
|
||||
.flat()
|
||||
.map((d) => ({ ...d, id: undefined })),
|
||||
"education"
|
||||
),
|
||||
});
|
||||
|
||||
let salutation = await this.transactionManager.getRepository("salutation").find();
|
||||
|
@ -541,6 +564,7 @@ export default abstract class BackupHelper {
|
|||
let membership = await this.transactionManager.getRepository("membership_status").find();
|
||||
let award = await this.transactionManager.getRepository("award").find();
|
||||
let qualification = await this.transactionManager.getRepository("qualification").find();
|
||||
let education = await this.transactionManager.getRepository("education").find();
|
||||
let position = await this.transactionManager.getRepository("executive_position").find();
|
||||
let dataWithMappedIds = data.map((d) => ({
|
||||
...d,
|
||||
|
@ -583,6 +607,13 @@ export default abstract class BackupHelper {
|
|||
id: qualification.find((iq) => iq.qualification == q.qualification.qualification)?.id ?? undefined,
|
||||
},
|
||||
})),
|
||||
educations: (d.educations ?? []).map((e: any) => ({
|
||||
...e,
|
||||
education: {
|
||||
...e.education,
|
||||
id: education.find((id) => id.education == e.education.education)?.id ?? undefined,
|
||||
},
|
||||
})),
|
||||
}));
|
||||
await this.transactionManager.getRepository("member").save(dataWithMappedIds);
|
||||
}
|
||||
|
@ -593,6 +624,7 @@ export default abstract class BackupHelper {
|
|||
let award = await this.transactionManager.getRepository("award").find();
|
||||
let qualification = await this.transactionManager.getRepository("qualification").find();
|
||||
let position = await this.transactionManager.getRepository("executive_position").find();
|
||||
let education = await this.transactionManager.getRepository("education").find();
|
||||
|
||||
await this.transactionManager
|
||||
.createQueryBuilder()
|
||||
|
@ -634,10 +666,19 @@ export default abstract class BackupHelper {
|
|||
.insert()
|
||||
.into("qualification")
|
||||
.values(
|
||||
(data?.["qualification"] ?? []).filter((d) => !qualification.map((q) => q.award).includes(d.qualification))
|
||||
(data?.["qualification"] ?? []).filter(
|
||||
(d) => !qualification.map((q) => q.qualification).includes(d.qualification)
|
||||
)
|
||||
)
|
||||
.orIgnore()
|
||||
.execute();
|
||||
await this.transactionManager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into("education")
|
||||
.values((data?.["education"] ?? []).filter((d) => !education.map((q) => q.education).includes(d.education)))
|
||||
.orIgnore()
|
||||
.execute();
|
||||
}
|
||||
private static async setProtocol(data: Array<any>, collectedIds: boolean): Promise<void> {
|
||||
let members = await this.transactionManager.getRepository("member").find();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue