member routes and controller base
This commit is contained in:
parent
5fdfdcbd1f
commit
93e27ab440
15 changed files with 531 additions and 133 deletions
|
@ -29,18 +29,6 @@ export async function getAwardById(req: Request, res: Response): Promise<any> {
|
|||
res.json(AwardFactory.mapToSingle(award));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get members assigned to award by id
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getAwardAssignedMembers(req: Request, res: Response): Promise<any> {
|
||||
const awardId = parseInt(req.params.id);
|
||||
|
||||
res.json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description create new award
|
||||
* @param req {Request} Express req object
|
||||
|
|
|
@ -33,18 +33,6 @@ export async function getExecutivePositionById(req: Request, res: Response): Pro
|
|||
res.json(ExecutivePositionFactory.mapToSingle(position));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get members assigned to executivePosition by id
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getExecutivePositionAssignedMembers(req: Request, res: Response): Promise<any> {
|
||||
const executivePositionId = parseInt(req.params.id);
|
||||
|
||||
res.json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description create new executivePosition
|
||||
* @param req {Request} Express req object
|
||||
|
|
312
src/controller/admin/memberController.ts
Normal file
312
src/controller/admin/memberController.ts
Normal file
|
@ -0,0 +1,312 @@
|
|||
import { Request, Response } from "express";
|
||||
import MemberService from "../../service/memberService";
|
||||
import MemberFactory from "../../factory/admin/member";
|
||||
|
||||
/**
|
||||
* @description get all members
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getAllMembers(req: Request, res: Response): Promise<any> {
|
||||
let members = await MemberService.getAll();
|
||||
|
||||
res.json(MemberFactory.mapToBase(members));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get member by id
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getMemberById(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.id);
|
||||
let member = await MemberService.getById(memberid);
|
||||
|
||||
res.json(MemberFactory.mapToSingle(member));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get memberships by member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getMembershipsByMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
|
||||
res.json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get awards by member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getAwardsByMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
|
||||
res.json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get qualifications by member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getQualificationsByMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
|
||||
res.json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get executive positions by member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getExecutivePositionsByMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
|
||||
res.json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get communications by member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getCommunicationsByMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
|
||||
res.json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description create member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function createMember(req: Request, res: Response): Promise<any> {
|
||||
res.status(200).send(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description add memberships to member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function addMembershipToMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description add awards to member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function addAwardToMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description add qualifications to member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function addQualificationToMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description add executive positions to member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function addExecutivePositionToMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description add communications to member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function addCommunicationToMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description update member by id
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function updateMemberById(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.id);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description update membership of member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function updateMembershipOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
const membershipId = parseInt(req.params.membershipId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description update award of member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function updateAwardOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
const awardId = parseInt(req.params.awardId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description update qualification of member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function updateQualificationOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
const qualificationId = parseInt(req.params.qualificationId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description update executive position of member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function updateExecutivePositionOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
const positionId = parseInt(req.params.positionId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description update communication of member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function updateCommunicationOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
const communicationId = parseInt(req.params.communicationId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description delete member by id
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function deleteMemberById(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.id);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description delete membership from member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function deleteMembershipOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
const membershipId = parseInt(req.params.membershipId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description delete award from member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function deleteAwardOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
const awardId = parseInt(req.params.awardId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description delete qualification from member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function deleteQualificationOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
const qualificationId = parseInt(req.params.qualificationId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description delete executive position from member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function deleteExecutivePositionOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
const positionId = parseInt(req.params.positionId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description delete communication from member
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function deleteCommunicationOfMember(req: Request, res: Response): Promise<any> {
|
||||
const memberid = parseInt(req.params.memberId);
|
||||
const communicationId = parseInt(req.params.communicationId);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
|
@ -33,18 +33,6 @@ export async function getMembershipStatusById(req: Request, res: Response): Prom
|
|||
res.json(MembershipStatusFactory.mapToSingle(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get members assigned to membershipStatus by id
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getMembershipStatusAssignedMembers(req: Request, res: Response): Promise<any> {
|
||||
const membershipStatusId = parseInt(req.params.id);
|
||||
|
||||
res.json({});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description create new membershipStatus
|
||||
* @param req {Request} Express req object
|
||||
|
|
|
@ -33,18 +33,6 @@ export async function getQualificationById(req: Request, res: Response): Promise
|
|||
res.json(QualificationFactory.mapToSingle(qualification));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get members assigned to qualification by id
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getQualificationAssignedMembers(req: Request, res: Response): Promise<any> {
|
||||
const qualificationId = parseInt(req.params.id);
|
||||
|
||||
res.json({});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description create new qualification
|
||||
* @param req {Request} Express req object
|
||||
|
|
29
src/factory/admin/member.ts
Normal file
29
src/factory/admin/member.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { member } from "../../entity/member";
|
||||
import { MemberViewModel } from "../../viewmodel/admin/member.models";
|
||||
|
||||
export default abstract class MemberFactory {
|
||||
/**
|
||||
* @description map record to member
|
||||
* @param {member} record
|
||||
* @returns {MemberViewModel}
|
||||
*/
|
||||
public static mapToSingle(record: member): MemberViewModel {
|
||||
return {
|
||||
id: record.id,
|
||||
salutation: record.salutation,
|
||||
firstname: record.firstname,
|
||||
lastname: record.lastname,
|
||||
nameaffix: record.nameaffix,
|
||||
birthdate: record.birthdate,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description map records to member
|
||||
* @param {Array<member>} records
|
||||
* @returns {Array<MemberViewModel>}
|
||||
*/
|
||||
public static mapToBase(records: Array<member>): Array<MemberViewModel> {
|
||||
return records.map((r) => this.mapToSingle(r));
|
||||
}
|
||||
}
|
|
@ -7,6 +7,8 @@ import executivePosition from "./executivePosition";
|
|||
import membershipStatus from "./membershipStatus";
|
||||
import qualification from "./qualification";
|
||||
|
||||
import member from "./member";
|
||||
|
||||
import role from "./role";
|
||||
import user from "./user";
|
||||
|
||||
|
@ -30,6 +32,8 @@ router.use(
|
|||
);
|
||||
router.use("/qualification", PermissionHelper.passCheckMiddleware("read", "settings", "qualification"), qualification);
|
||||
|
||||
router.use("/member", PermissionHelper.passCheckMiddleware("read", "club", "member"), member);
|
||||
|
||||
router.use("/role", PermissionHelper.passCheckMiddleware("read", "user", "role"), role);
|
||||
router.use("/user", PermissionHelper.passCheckMiddleware("read", "user", "user"), user);
|
||||
|
||||
|
|
132
src/routes/admin/member.ts
Normal file
132
src/routes/admin/member.ts
Normal file
|
@ -0,0 +1,132 @@
|
|||
import express, { Request, Response } from "express";
|
||||
import {
|
||||
addAwardToMember,
|
||||
addCommunicationToMember,
|
||||
addExecutivePositionToMember,
|
||||
addMembershipToMember,
|
||||
addQualificationToMember,
|
||||
createMember,
|
||||
deleteAwardOfMember,
|
||||
deleteCommunicationOfMember,
|
||||
deleteExecutivePositionOfMember,
|
||||
deleteMemberById,
|
||||
deleteMembershipOfMember,
|
||||
deleteQualificationOfMember,
|
||||
getAllMembers,
|
||||
getAwardsByMember,
|
||||
getCommunicationsByMember,
|
||||
getExecutivePositionsByMember,
|
||||
getMemberById,
|
||||
getMembershipsByMember,
|
||||
getQualificationsByMember,
|
||||
updateAwardOfMember,
|
||||
updateCommunicationOfMember,
|
||||
updateExecutivePositionOfMember,
|
||||
updateMemberById,
|
||||
updateMembershipOfMember,
|
||||
updateQualificationOfMember,
|
||||
} from "../../controller/admin/memberController";
|
||||
|
||||
var router = express.Router({ mergeParams: true });
|
||||
|
||||
router.get("/", async (req: Request, res: Response) => {
|
||||
await getAllMembers(req, res);
|
||||
});
|
||||
|
||||
router.get("/:id", async (req: Request, res: Response) => {
|
||||
await getMemberById(req, res);
|
||||
});
|
||||
|
||||
router.get("/:memberId/memberships", async (req: Request, res: Response) => {
|
||||
await getMembershipsByMember(req, res);
|
||||
});
|
||||
|
||||
router.get("/:memberId/awards", async (req: Request, res: Response) => {
|
||||
await getAwardsByMember(req, res);
|
||||
});
|
||||
|
||||
router.get("/:memberId/qualifications", async (req: Request, res: Response) => {
|
||||
await getQualificationsByMember(req, res);
|
||||
});
|
||||
|
||||
router.get("/:memberId/positions", async (req: Request, res: Response) => {
|
||||
await getExecutivePositionsByMember(req, res);
|
||||
});
|
||||
|
||||
router.get("/:memberId/communications", async (req: Request, res: Response) => {
|
||||
await getCommunicationsByMember(req, res);
|
||||
});
|
||||
|
||||
router.post("/", async (req: Request, res: Response) => {
|
||||
await createMember(req, res);
|
||||
});
|
||||
|
||||
router.post("/:memberId/membership", async (req: Request, res: Response) => {
|
||||
await addMembershipToMember(req, res);
|
||||
});
|
||||
|
||||
router.post("/:memberId/award", async (req: Request, res: Response) => {
|
||||
await addAwardToMember(req, res);
|
||||
});
|
||||
|
||||
router.post("/:memberId/qualification", async (req: Request, res: Response) => {
|
||||
await addQualificationToMember(req, res);
|
||||
});
|
||||
|
||||
router.post("/:memberId/position", async (req: Request, res: Response) => {
|
||||
await addExecutivePositionToMember(req, res);
|
||||
});
|
||||
|
||||
router.post("/:memberId/communication", async (req: Request, res: Response) => {
|
||||
await addCommunicationToMember(req, res);
|
||||
});
|
||||
|
||||
router.patch("/:id", async (req: Request, res: Response) => {
|
||||
await updateMemberById(req, res);
|
||||
});
|
||||
|
||||
router.patch("/:memberId/membership/:membershipId", async (req: Request, res: Response) => {
|
||||
await updateMembershipOfMember(req, res);
|
||||
});
|
||||
|
||||
router.patch("/:memberId/award/:awardId", async (req: Request, res: Response) => {
|
||||
await updateAwardOfMember(req, res);
|
||||
});
|
||||
|
||||
router.patch("/:memberId/qualification/:qualificationId", async (req: Request, res: Response) => {
|
||||
await updateQualificationOfMember(req, res);
|
||||
});
|
||||
|
||||
router.patch("/:memberId/position/:positionId", async (req: Request, res: Response) => {
|
||||
await updateExecutivePositionOfMember(req, res);
|
||||
});
|
||||
|
||||
router.patch("/:memberId/communication/:communicationId", async (req: Request, res: Response) => {
|
||||
await updateCommunicationOfMember(req, res);
|
||||
});
|
||||
|
||||
router.delete("/:id", async (req: Request, res: Response) => {
|
||||
await deleteMemberById(req, res);
|
||||
});
|
||||
|
||||
router.delete("/:memberId/membership/:membershipId", async (req: Request, res: Response) => {
|
||||
await deleteMembershipOfMember(req, res);
|
||||
});
|
||||
|
||||
router.delete("/:memberId/award/:awardId", async (req: Request, res: Response) => {
|
||||
await deleteAwardOfMember(req, res);
|
||||
});
|
||||
|
||||
router.delete("/:memberId/qualification/:qualificationId", async (req: Request, res: Response) => {
|
||||
await deleteQualificationOfMember(req, res);
|
||||
});
|
||||
|
||||
router.delete("/:memberId/position/:positionId", async (req: Request, res: Response) => {
|
||||
await deleteExecutivePositionOfMember(req, res);
|
||||
});
|
||||
|
||||
router.delete("/:memberId/communication/:communicationId", async (req: Request, res: Response) => {
|
||||
await deleteCommunicationOfMember(req, res);
|
||||
});
|
||||
|
||||
export default router;
|
|
@ -38,23 +38,4 @@ export default abstract class AwardService {
|
|||
throw new InternalException("award not found by id", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get members assigned to award
|
||||
* @returns {Promise<Array<member>>}
|
||||
*/
|
||||
static async getMembersByAwardId(id: number): Promise<Array<member>> {
|
||||
return await dataSource
|
||||
.getRepository(award)
|
||||
.createQueryBuilder("award")
|
||||
.leftJoinAndSelect("award.members", "members")
|
||||
.where("award.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return [];
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("award assigned members not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,24 +38,4 @@ export default abstract class ExecutivePositionService {
|
|||
throw new InternalException("executivePosition not found by id", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get members assigned to executivePosition
|
||||
* @returns {Promise<Array<memberExecutivePositions>>}
|
||||
*/
|
||||
static async getMembersByexecutivePositionId(id: number): Promise<Array<memberExecutivePositions>> {
|
||||
return await dataSource
|
||||
.getRepository(executivePosition)
|
||||
.createQueryBuilder("executivePosition")
|
||||
.leftJoinAndSelect("executivePosition.members", "memberExecutivePositions")
|
||||
.leftJoinAndSelect("memberExecutivePositions.member", "member")
|
||||
.where("executivePosition.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res.members;
|
||||
})
|
||||
.catch(() => {
|
||||
throw new InternalException("executivePosition assigned members not found by id");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
41
src/service/memberService.ts
Normal file
41
src/service/memberService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { member } from "../entity/member";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
||||
export default abstract class MemberService {
|
||||
/**
|
||||
* @description get all members
|
||||
* @returns {Promise<Array<member>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<member>> {
|
||||
return await dataSource
|
||||
.getRepository(member)
|
||||
.createQueryBuilder("member")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("members not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get member by id
|
||||
* @param {number} id
|
||||
* @returns {Promise<Array<member>>}
|
||||
*/
|
||||
static async getById(id: number): Promise<member> {
|
||||
return await dataSource
|
||||
.getRepository(member)
|
||||
.createQueryBuilder("member")
|
||||
.where("member.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -38,27 +38,4 @@ export default abstract class MembershipStatusService {
|
|||
throw new InternalException("membershipStatus not found by id", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get active memberships assigned to membershipStatus
|
||||
* @returns {Promise<Array<membership>>}
|
||||
*/
|
||||
static async getMembersBymembershipStatusId(id: number): Promise<Array<membership>> {
|
||||
return await dataSource
|
||||
.getRepository(membershipStatus)
|
||||
.createQueryBuilder("membershipStatus")
|
||||
.leftJoinAndSelect("membershipStatus.memberships", "memberships")
|
||||
.leftJoinAndSelect("memberships.member", "member")
|
||||
.where("membershipStatus.id = :id", { id: id })
|
||||
.andWhere("membership.start <= :start", { start: new Date() })
|
||||
.andWhere("membership.end >= :end", { end: new Date() })
|
||||
.orWhere("membership.end IS NULL")
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res.memberships;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("membershipStatus assigned members not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,24 +39,4 @@ export default abstract class QualificationService {
|
|||
throw new InternalException("qualification not found by id", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get members assigned to qualification
|
||||
* @returns {Promise<Array<memberQualifications>>}
|
||||
*/
|
||||
static async getMembersByqualificationId(id: number): Promise<Array<memberQualifications>> {
|
||||
return await dataSource
|
||||
.getRepository(qualification)
|
||||
.createQueryBuilder("qualification")
|
||||
.leftJoinAndSelect("qualification.members", "memberQualifications")
|
||||
.leftJoinAndSelect("memberQualifications.members", "members")
|
||||
.where("qualification.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res.members;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("qualification assigned members not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export type PermissionSection = "club" | "settings" | "user";
|
||||
|
||||
export type PermissionModule =
|
||||
| "members"
|
||||
| "member"
|
||||
| "calendar"
|
||||
| "newsletter"
|
||||
| "protocoll"
|
||||
|
@ -36,7 +36,7 @@ export type SectionsAndModulesObject = {
|
|||
|
||||
export const permissionSections: Array<PermissionSection> = ["club", "settings", "user"];
|
||||
export const permissionModules: Array<PermissionModule> = [
|
||||
"members",
|
||||
"member",
|
||||
"calendar",
|
||||
"newsletter",
|
||||
"protocoll",
|
||||
|
@ -50,7 +50,7 @@ export const permissionModules: Array<PermissionModule> = [
|
|||
];
|
||||
export const permissionTypes: Array<PermissionType> = ["read", "create", "update", "delete"];
|
||||
export const sectionsAndModules: SectionsAndModulesObject = {
|
||||
club: ["members", "calendar", "newsletter", "protocoll"],
|
||||
club: ["member", "calendar", "newsletter", "protocoll"],
|
||||
settings: ["qualification", "award", "executive_position", "communication", "membership_status"],
|
||||
user: ["user", "role"],
|
||||
};
|
||||
|
|
10
src/viewmodel/admin/member.models.ts
Normal file
10
src/viewmodel/admin/member.models.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { Salutation } from "../../enums/salutation";
|
||||
|
||||
export interface MemberViewModel {
|
||||
id: number;
|
||||
salutation: Salutation;
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
nameaffix: string;
|
||||
birthdate: Date;
|
||||
}
|
Loading…
Reference in a new issue