member related data commands
This commit is contained in:
parent
ade837b5ab
commit
58d863e5e0
26 changed files with 1115 additions and 9 deletions
|
@ -11,8 +11,43 @@ import MemberExecutivePositionService from "../../service/memberExecutivePositio
|
|||
import MemberExecutivePositionFactory from "../../factory/admin/memberExecutivePosition";
|
||||
import CommunicationService from "../../service/communicationService";
|
||||
import CommunicationFactory from "../../factory/admin/communication";
|
||||
import { CreateMemberCommand, DeleteMemberCommand, UpdateMemberCommand } from "../../command/memberCommand";
|
||||
import {
|
||||
CreateMemberCommand,
|
||||
DeleteMemberCommand,
|
||||
UpdateMemberCommand,
|
||||
UpdateMemberNewsletterCommand,
|
||||
} from "../../command/memberCommand";
|
||||
import MemberCommandHandler from "../../command/memberCommandHandler";
|
||||
import {
|
||||
CreateMembershipCommand,
|
||||
DeleteMembershipCommand,
|
||||
UpdateMembershipCommand,
|
||||
} from "../../command/membershipCommand";
|
||||
import MembershipCommandHandler from "../../command/membershipCommandHandler";
|
||||
import {
|
||||
CreateMemberAwardCommand,
|
||||
DeleteMemberAwardCommand,
|
||||
UpdateMemberAwardCommand,
|
||||
} from "../../command/memberAwardCommand";
|
||||
import MemberAwardCommandHandler from "../../command/memberAwardCommandHandler";
|
||||
import {
|
||||
CreateMemberExecutivePositionCommand,
|
||||
DeleteMemberExecutivePositionCommand,
|
||||
UpdateMemberExecutivePositionCommand,
|
||||
} from "../../command/memberExecutivePositionCommand";
|
||||
import MemberExecutivePositionCommandHandler from "../../command/memberExecutivePositionCommandHandler";
|
||||
import {
|
||||
CreateMemberQualificationCommand,
|
||||
DeleteMemberQualificationCommand,
|
||||
UpdateMemberQualificationCommand,
|
||||
} from "../../command/memberQualificationCommand";
|
||||
import MemberQualificationCommandHandler from "../../command/memberQualificationCommandHandler";
|
||||
import {
|
||||
CreateCommunicationCommand,
|
||||
DeleteCommunicationCommand,
|
||||
UpdateCommunicationCommand,
|
||||
} from "../../command/communicationCommand";
|
||||
import CommunicationCommandHandler from "../../command/communicationCommandHandler";
|
||||
|
||||
/**
|
||||
* @description get all members
|
||||
|
@ -59,6 +94,20 @@ export async function getMembershipsByMember(req: Request, res: Response): Promi
|
|||
res.json(MembershipFactory.mapToBase(memberships));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get membership by member and record
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getMembershipByMemberAndRecord(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.id);
|
||||
let membership = await MembershipService.getById(memberId, recordId);
|
||||
|
||||
res.json(MembershipFactory.mapToSingle(membership));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get awards by member
|
||||
* @param req {Request} Express req object
|
||||
|
@ -72,6 +121,20 @@ export async function getAwardsByMember(req: Request, res: Response): Promise<an
|
|||
res.json(MemberAwardFactory.mapToBase(awards));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get award by member and record
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getAwardByMemberAndRecord(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.id);
|
||||
let award = await MemberAwardService.getById(memberId, recordId);
|
||||
|
||||
res.json(MemberAwardFactory.mapToSingle(award));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get qualifications by member
|
||||
* @param req {Request} Express req object
|
||||
|
@ -85,6 +148,20 @@ export async function getQualificationsByMember(req: Request, res: Response): Pr
|
|||
res.json(MemberQualificationFactory.mapToBase(qualifications));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get qualification by member and record
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getQualificationByMemberAndRecord(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.id);
|
||||
let qualification = await MemberQualificationService.getById(memberId, recordId);
|
||||
|
||||
res.json(MemberQualificationFactory.mapToSingle(qualification));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get executive positions by member
|
||||
* @param req {Request} Express req object
|
||||
|
@ -98,6 +175,20 @@ export async function getExecutivePositionsByMember(req: Request, res: Response)
|
|||
res.json(MemberExecutivePositionFactory.mapToBase(positions));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get executive position by member and record
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getExecutivePositionByMemberAndRecord(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.id);
|
||||
let position = await MemberExecutivePositionService.getById(memberId, recordId);
|
||||
|
||||
res.json(MemberExecutivePositionFactory.mapToSingle(position));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get communications by member
|
||||
* @param req {Request} Express req object
|
||||
|
@ -111,6 +202,20 @@ export async function getCommunicationsByMember(req: Request, res: Response): Pr
|
|||
res.json(CommunicationFactory.mapToBase(communications));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get communication by member and record
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getCommunicationByMemberAndRecord(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.id);
|
||||
let communication = await CommunicationService.getById(memberId, recordId);
|
||||
|
||||
res.json(CommunicationFactory.mapToSingle(communication));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description create member
|
||||
* @param req {Request} Express req object
|
||||
|
@ -144,6 +249,17 @@ export async function createMember(req: Request, res: Response): Promise<any> {
|
|||
*/
|
||||
export async function addMembershipToMember(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const internalId = req.body.internalId;
|
||||
const start = req.body.start;
|
||||
const statusId = req.body.statusId;
|
||||
|
||||
let createMembership: CreateMembershipCommand = {
|
||||
internalId,
|
||||
start,
|
||||
memberId,
|
||||
statusId,
|
||||
};
|
||||
await MembershipCommandHandler.create(createMembership);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
@ -156,6 +272,19 @@ export async function addMembershipToMember(req: Request, res: Response): Promis
|
|||
*/
|
||||
export async function addAwardToMember(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const given = req.body.given;
|
||||
const note = req.body.note;
|
||||
const date = req.body.date;
|
||||
const awardId = req.body.awardId;
|
||||
|
||||
let createMemberAward: CreateMemberAwardCommand = {
|
||||
given,
|
||||
note,
|
||||
date,
|
||||
memberId,
|
||||
awardId,
|
||||
};
|
||||
await MemberAwardCommandHandler.create(createMemberAward);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
@ -168,6 +297,17 @@ export async function addAwardToMember(req: Request, res: Response): Promise<any
|
|||
*/
|
||||
export async function addQualificationToMember(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const note = req.body.note;
|
||||
const start = req.body.start;
|
||||
const qualificationId = req.body.qualificationId;
|
||||
|
||||
let createMemberQualification: CreateMemberQualificationCommand = {
|
||||
note,
|
||||
start,
|
||||
memberId,
|
||||
qualificationId,
|
||||
};
|
||||
await MemberQualificationCommandHandler.create(createMemberQualification);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
@ -180,6 +320,19 @@ export async function addQualificationToMember(req: Request, res: Response): Pro
|
|||
*/
|
||||
export async function addExecutivePositionToMember(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const note = req.body.note;
|
||||
const start = req.body.start;
|
||||
const end = req.body.end || null;
|
||||
const executivePositionId = req.body.executivePositionId;
|
||||
|
||||
let createMemberExecutivePosition: CreateMemberExecutivePositionCommand = {
|
||||
note,
|
||||
start,
|
||||
end,
|
||||
memberId,
|
||||
executivePositionId,
|
||||
};
|
||||
await MemberExecutivePositionCommandHandler.create(createMemberExecutivePosition);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
@ -192,6 +345,36 @@ export async function addExecutivePositionToMember(req: Request, res: Response):
|
|||
*/
|
||||
export async function addCommunicationToMember(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const preferred = req.body.preferred;
|
||||
const mobile = req.body.mobile;
|
||||
const email = req.body.email;
|
||||
const city = req.body.city;
|
||||
const street = req.body.street;
|
||||
const streetNumber = req.body.streetNumber;
|
||||
const streetNumberAddition = req.body.streetNumberAddition;
|
||||
const typeId = req.body.typeId;
|
||||
const isNewsletterMain = req.body.isNewsletterMain;
|
||||
|
||||
let createCommunication: CreateCommunicationCommand = {
|
||||
preferred,
|
||||
mobile,
|
||||
email,
|
||||
city,
|
||||
street,
|
||||
streetNumber,
|
||||
streetNumberAddition,
|
||||
memberId,
|
||||
typeId,
|
||||
};
|
||||
let id = await CommunicationCommandHandler.create(createCommunication);
|
||||
|
||||
if (isNewsletterMain) {
|
||||
let updateNewsletter: UpdateMemberNewsletterCommand = {
|
||||
id: memberId,
|
||||
communicationId: id,
|
||||
};
|
||||
await MemberCommandHandler.updateNewsletter(updateNewsletter);
|
||||
}
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
@ -232,6 +415,22 @@ export async function updateMemberById(req: Request, res: Response): Promise<any
|
|||
export async function updateMembershipOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.recordId);
|
||||
const internalId = req.body.internalId;
|
||||
const start = req.body.start;
|
||||
const end = req.body.end || null;
|
||||
const terminationReason = req.body.terminationReason;
|
||||
const statusId = req.body.statusId;
|
||||
|
||||
let updateMembership: UpdateMembershipCommand = {
|
||||
id: recordId,
|
||||
internalId,
|
||||
start,
|
||||
end,
|
||||
terminationReason,
|
||||
memberId,
|
||||
statusId,
|
||||
};
|
||||
await MembershipCommandHandler.update(updateMembership);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
@ -245,6 +444,20 @@ export async function updateMembershipOfMember(req: Request, res: Response): Pro
|
|||
export async function updateAwardOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.recordId);
|
||||
const given = req.body.given;
|
||||
const note = req.body.note;
|
||||
const date = req.body.date;
|
||||
const awardId = req.body.awardId;
|
||||
|
||||
let updateMemberAward: UpdateMemberAwardCommand = {
|
||||
id: recordId,
|
||||
given,
|
||||
note,
|
||||
date,
|
||||
memberId,
|
||||
awardId,
|
||||
};
|
||||
await MemberAwardCommandHandler.update(updateMemberAward);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
@ -258,6 +471,22 @@ export async function updateAwardOfMember(req: Request, res: Response): Promise<
|
|||
export async function updateQualificationOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.recordId);
|
||||
const note = req.body.note;
|
||||
const start = req.body.start;
|
||||
const end = req.body.end || null;
|
||||
const terminationReason = req.body.terminationReason;
|
||||
const qualificationId = req.body.qualificationId;
|
||||
|
||||
let updateMemberQualification: UpdateMemberQualificationCommand = {
|
||||
id: recordId,
|
||||
note,
|
||||
start,
|
||||
end,
|
||||
terminationReason,
|
||||
memberId,
|
||||
qualificationId,
|
||||
};
|
||||
await MemberQualificationCommandHandler.update(updateMemberQualification);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
@ -271,6 +500,20 @@ export async function updateQualificationOfMember(req: Request, res: Response):
|
|||
export async function updateExecutivePositionOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.recordId);
|
||||
const note = req.body.note;
|
||||
const start = req.body.start;
|
||||
const end = req.body.end || null;
|
||||
const executivePositionId = req.body.executivePositionId;
|
||||
|
||||
let updateMemberExecutivePosition: UpdateMemberExecutivePositionCommand = {
|
||||
id: recordId,
|
||||
note,
|
||||
start,
|
||||
end,
|
||||
memberId,
|
||||
executivePositionId,
|
||||
};
|
||||
await MemberExecutivePositionCommandHandler.update(updateMemberExecutivePosition);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
@ -284,6 +527,36 @@ export async function updateExecutivePositionOfMember(req: Request, res: Respons
|
|||
export async function updateCommunicationOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.recordId);
|
||||
const preferred = req.body.preferred;
|
||||
const mobile = req.body.mobile;
|
||||
const email = req.body.email;
|
||||
const city = req.body.city;
|
||||
const street = req.body.street;
|
||||
const streetNumber = req.body.streetNumber;
|
||||
const streetNumberAddition = req.body.streetNumberAddition;
|
||||
const typeId = req.body.typeId;
|
||||
const isNewsletterMain = req.body.isNewsletterMain;
|
||||
|
||||
let updateCommunication: UpdateCommunicationCommand = {
|
||||
id: recordId,
|
||||
preferred,
|
||||
mobile,
|
||||
email,
|
||||
city,
|
||||
street,
|
||||
streetNumber,
|
||||
streetNumberAddition,
|
||||
memberId,
|
||||
};
|
||||
await CommunicationCommandHandler.update(updateCommunication);
|
||||
|
||||
if (isNewsletterMain) {
|
||||
let updateNewsletter: UpdateMemberNewsletterCommand = {
|
||||
id: memberId,
|
||||
communicationId: recordId,
|
||||
};
|
||||
await MemberCommandHandler.updateNewsletter(updateNewsletter);
|
||||
}
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
@ -315,6 +588,12 @@ export async function deleteMembershipOfMember(req: Request, res: Response): Pro
|
|||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.recordId);
|
||||
|
||||
let deleteMembership: DeleteMembershipCommand = {
|
||||
id: recordId,
|
||||
memberId,
|
||||
};
|
||||
await MembershipCommandHandler.delete(deleteMembership);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
|
@ -328,6 +607,12 @@ export async function deleteAwardOfMember(req: Request, res: Response): Promise<
|
|||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.recordId);
|
||||
|
||||
let deleteMemberAward: DeleteMemberAwardCommand = {
|
||||
id: recordId,
|
||||
memberId,
|
||||
};
|
||||
await MemberAwardCommandHandler.delete(deleteMemberAward);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
|
@ -341,6 +626,12 @@ export async function deleteQualificationOfMember(req: Request, res: Response):
|
|||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.recordId);
|
||||
|
||||
let deleteMemberQualification: DeleteMemberQualificationCommand = {
|
||||
id: recordId,
|
||||
memberId,
|
||||
};
|
||||
await MemberQualificationCommandHandler.delete(deleteMemberQualification);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
|
@ -354,6 +645,12 @@ export async function deleteExecutivePositionOfMember(req: Request, res: Respons
|
|||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.recordId);
|
||||
|
||||
let deleteMemberExecutivePosition: DeleteMemberExecutivePositionCommand = {
|
||||
id: recordId,
|
||||
memberId,
|
||||
};
|
||||
await MemberExecutivePositionCommandHandler.delete(deleteMemberExecutivePosition);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
|
@ -367,5 +664,11 @@ export async function deleteCommunicationOfMember(req: Request, res: Response):
|
|||
const memberId = parseInt(req.params.memberId);
|
||||
const recordId = parseInt(req.params.recordId);
|
||||
|
||||
let deleteCommunication: DeleteCommunicationCommand = {
|
||||
id: recordId,
|
||||
memberId,
|
||||
};
|
||||
await CommunicationCommandHandler.delete(deleteCommunication);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue