education controller, service, command

This commit is contained in:
Julian Krauser 2025-06-03 15:20:46 +02:00
parent 5368a96d0f
commit fded8a663a
29 changed files with 884 additions and 5 deletions

View file

@ -49,6 +49,14 @@ import {
import CommunicationCommandHandler from "../../../command/club/member/communicationCommandHandler";
import { PdfExport } from "../../../helpers/pdfExport";
import { PermissionModule } from "../../../type/permissionTypes";
import MemberEducationFactory from "../../../factory/admin/club/member/memberEducation";
import MemberEducationService from "../../../service/club/member/memberEducationService";
import {
CreateMemberEducationCommand,
DeleteMemberEducationCommand,
UpdateMemberEducationCommand,
} from "../../../command/club/member/memberEducationCommand";
import MemberEducationCommandHandler from "../../../command/club/member/memberEducationCommandHandler";
/**
* @description get all members
@ -276,6 +284,33 @@ export async function getQualificationByMemberAndRecord(req: Request, res: Respo
res.json(MemberQualificationFactory.mapToSingle(qualification));
}
/**
* @description get educations by member
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getEducationsByMember(req: Request, res: Response): Promise<any> {
const memberId = req.params.memberId;
let educations = await MemberEducationService.getAll(memberId);
res.json(MemberEducationFactory.mapToBase(educations));
}
/**
* @description get education by member and record
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getEducationByMemberAndRecord(req: Request, res: Response): Promise<any> {
const memberId = req.params.memberId;
const recordId = parseInt(req.params.id);
let education = await MemberEducationService.getById(memberId, recordId);
res.json(MemberEducationFactory.mapToSingle(education));
}
/**
* @description get executive positions by member
* @param req {Request} Express req object
@ -343,6 +378,7 @@ export async function createMember(req: Request, res: Response): Promise<any> {
const nameaffix = req.body.nameaffix;
const birthdate = req.body.birthdate;
const internalId = req.body.internalId || null;
const note = req.body.note || null;
let createMember: CreateMemberCommand = {
salutationId,
@ -351,6 +387,7 @@ export async function createMember(req: Request, res: Response): Promise<any> {
nameaffix,
birthdate,
internalId,
note,
};
let memberId = await MemberCommandHandler.create(createMember);
@ -426,6 +463,33 @@ export async function addQualificationToMember(req: Request, res: Response): Pro
res.sendStatus(204);
}
/**
* @description add education to member
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function addEducationToMember(req: Request, res: Response): Promise<any> {
const memberId = req.params.memberId;
const note = req.body.note;
const place = req.body.place;
const start = req.body.start;
const end = req.body.end || null;
const educationId = req.body.educationId;
let createMemberEducation: CreateMemberEducationCommand = {
note,
start,
end,
place,
memberId,
educationId,
};
await MemberEducationCommandHandler.create(createMemberEducation);
res.sendStatus(204);
}
/**
* @description add executive positions to member
* @param req {Request} Express req object
@ -504,6 +568,7 @@ export async function updateMemberById(req: Request, res: Response): Promise<any
const nameaffix = req.body.nameaffix;
const birthdate = req.body.birthdate;
const internalId = req.body.internalId || null;
const note = req.body.note || null;
let updateMember: UpdateMemberCommand = {
id: memberId,
@ -513,6 +578,7 @@ export async function updateMemberById(req: Request, res: Response): Promise<any
nameaffix,
birthdate,
internalId,
note,
};
await MemberCommandHandler.update(updateMember);
@ -602,6 +668,35 @@ export async function updateQualificationOfMember(req: Request, res: Response):
res.sendStatus(204);
}
/**
* @description update education of member
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function updateEducationOfMember(req: Request, res: Response): Promise<any> {
const memberId = req.params.memberId;
const recordId = parseInt(req.params.recordId);
const start = req.body.start;
const end = req.body.end || null;
const note = req.body.note;
const place = req.body.place;
const educationId = req.body.educationId;
let updateMemberEducation: UpdateMemberEducationCommand = {
id: recordId,
start,
end,
note,
place,
memberId,
educationId,
};
await MemberEducationCommandHandler.update(updateMemberEducation);
res.sendStatus(204);
}
/**
* @description update executive position of member
* @param req {Request} Express req object
@ -742,6 +837,25 @@ export async function deleteQualificationOfMember(req: Request, res: Response):
res.sendStatus(204);
}
/**
* @description delete education from member
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function deleteEducationsOfMember(req: Request, res: Response): Promise<any> {
const memberId = req.params.memberId;
const recordId = parseInt(req.params.recordId);
let deleteMemberEducation: DeleteMemberEducationCommand = {
id: recordId,
memberId,
};
await MemberEducationCommandHandler.delete(deleteMemberEducation);
res.sendStatus(204);
}
/**
* @description delete executive position from member
* @param req {Request} Express req object