Compare commits
No commits in common. "d3870b4c8ddc976130c9c34917ebf17060a1d16c" and "0bbe22e9ae2bf841f52491b9c95c1026b8c4a9a1" have entirely different histories.
d3870b4c8d
...
0bbe22e9ae
10 changed files with 36 additions and 192 deletions
|
@ -90,19 +90,6 @@ export async function getMemberById(req: Request, res: Response): Promise<any> {
|
||||||
res.json(MemberFactory.mapToSingle(member));
|
res.json(MemberFactory.mapToSingle(member));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description get member statistics by id
|
|
||||||
* @param req {Request} Express req object
|
|
||||||
* @param res {Response} Express res object
|
|
||||||
* @returns {Promise<*>}
|
|
||||||
*/
|
|
||||||
export async function getMemberStatisticsById(req: Request, res: Response): Promise<any> {
|
|
||||||
const memberId = parseInt(req.params.id);
|
|
||||||
let member = await MemberService.getStatisticsById(memberId);
|
|
||||||
|
|
||||||
res.json(MemberFactory.mapToMemberStatistic(member));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description get memberships by member
|
* @description get memberships by member
|
||||||
* @param req {Request} Express req object
|
* @param req {Request} Express req object
|
||||||
|
@ -116,19 +103,6 @@ export async function getMembershipsByMember(req: Request, res: Response): Promi
|
||||||
res.json(MembershipFactory.mapToBase(memberships));
|
res.json(MembershipFactory.mapToBase(memberships));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description get member statistics by id
|
|
||||||
* @param req {Request} Express req object
|
|
||||||
* @param res {Response} Express res object
|
|
||||||
* @returns {Promise<*>}
|
|
||||||
*/
|
|
||||||
export async function getMembershipStatisticsById(req: Request, res: Response): Promise<any> {
|
|
||||||
const memberId = parseInt(req.params.memberId);
|
|
||||||
let member = await MembershipService.getStatisticsById(memberId);
|
|
||||||
|
|
||||||
res.json(MembershipFactory.mapToBaseStatistics(member));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description get membership by member and record
|
* @description get membership by member and record
|
||||||
* @param req {Request} Express req object
|
* @param req {Request} Express req object
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { member } from "../../../../entity/club/member/member";
|
import { member } from "../../../../entity/club/member/member";
|
||||||
import { MemberStatisticsViewModel, MemberViewModel } from "../../../../viewmodel/admin/club/member/member.models";
|
import { MemberViewModel } from "../../../../viewmodel/admin/club/member/member.models";
|
||||||
import { memberView } from "../../../../views/memberView";
|
|
||||||
import CommunicationFactory from "./communication";
|
import CommunicationFactory from "./communication";
|
||||||
import MembershipFactory from "./membership";
|
import MembershipFactory from "./membership";
|
||||||
|
|
||||||
|
@ -41,23 +40,4 @@ export default abstract class MemberFactory {
|
||||||
public static mapToBase(records: Array<member>): Array<MemberViewModel> {
|
public static mapToBase(records: Array<member>): Array<MemberViewModel> {
|
||||||
return records.map((r) => this.mapToSingle(r));
|
return records.map((r) => this.mapToSingle(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description map view record to MemberMembershipStatisticsViewModel
|
|
||||||
* @param {memberView} record
|
|
||||||
* @returns {MemberStatisticsViewModel}
|
|
||||||
*/
|
|
||||||
public static mapToMemberStatistic(record: memberView): MemberStatisticsViewModel {
|
|
||||||
return {
|
|
||||||
id: record.id,
|
|
||||||
salutation: record.salutation,
|
|
||||||
firstname: record.firstname,
|
|
||||||
lastname: record.lastname,
|
|
||||||
nameaffix: record.nameaffix,
|
|
||||||
birthdate: record.birthdate,
|
|
||||||
todayAge: record.todayAge,
|
|
||||||
ageThisYear: record.ageThisYear,
|
|
||||||
exactAge: record.exactAge,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
import { membership } from "../../../../entity/club/member/membership";
|
import { membership } from "../../../../entity/club/member/membership";
|
||||||
import {
|
import { MembershipViewModel } from "../../../../viewmodel/admin/club/member/membership.models";
|
||||||
MembershipStatisticsViewModel,
|
|
||||||
MembershipViewModel,
|
|
||||||
} from "../../../../viewmodel/admin/club/member/membership.models";
|
|
||||||
import { membershipView } from "../../../../views/membershipsView";
|
|
||||||
|
|
||||||
export default abstract class MembershipFactory {
|
export default abstract class MembershipFactory {
|
||||||
/**
|
/**
|
||||||
|
@ -30,33 +26,4 @@ export default abstract class MembershipFactory {
|
||||||
public static mapToBase(records: Array<membership>): Array<MembershipViewModel> {
|
public static mapToBase(records: Array<membership>): Array<MembershipViewModel> {
|
||||||
return records.map((r) => this.mapToSingle(r));
|
return records.map((r) => this.mapToSingle(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description map view record to MembershipStatisticsViewModel
|
|
||||||
* @param {membershipView} record
|
|
||||||
* @returns {MembershipStatisticsViewModel}
|
|
||||||
*/
|
|
||||||
public static mapToSingleStatistic(record: membershipView): MembershipStatisticsViewModel {
|
|
||||||
return {
|
|
||||||
durationInDays: record.durationInDays,
|
|
||||||
durationInYears: record.durationInYears,
|
|
||||||
status: record.status,
|
|
||||||
statusId: record.statusId,
|
|
||||||
memberId: record.memberId,
|
|
||||||
memberSalutation: record.memberSalutation,
|
|
||||||
memberFirstname: record.memberFirstname,
|
|
||||||
memberLastname: record.memberLastname,
|
|
||||||
memberNameaffix: record.memberNameaffix,
|
|
||||||
memberBirthdate: record.memberBirthdate,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description map records to MembershipStatisticsViewModel
|
|
||||||
* @param {Array<membershipView>} records
|
|
||||||
* @returns {Array<MembershipStatisticsViewModel>}
|
|
||||||
*/
|
|
||||||
public static mapToBaseStatistics(records: Array<membershipView>): Array<MembershipStatisticsViewModel> {
|
|
||||||
return records.map((r) => this.mapToSingleStatistic(r));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,6 @@ import {
|
||||||
getMemberById,
|
getMemberById,
|
||||||
getMembershipByMemberAndRecord,
|
getMembershipByMemberAndRecord,
|
||||||
getMembershipsByMember,
|
getMembershipsByMember,
|
||||||
getMembershipStatisticsById,
|
|
||||||
getMemberStatisticsById,
|
|
||||||
getQualificationByMemberAndRecord,
|
getQualificationByMemberAndRecord,
|
||||||
getQualificationsByMember,
|
getQualificationsByMember,
|
||||||
updateAwardOfMember,
|
updateAwardOfMember,
|
||||||
|
@ -46,10 +44,6 @@ router.get("/:id", async (req: Request, res: Response) => {
|
||||||
await getMemberById(req, res);
|
await getMemberById(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/:id/statistics", async (req: Request, res: Response) => {
|
|
||||||
await getMemberStatisticsById(req, res);
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get("/print/namelist", async (req: Request, res: Response) => {
|
router.get("/print/namelist", async (req: Request, res: Response) => {
|
||||||
await createMemberPrintoutList(req, res);
|
await createMemberPrintoutList(req, res);
|
||||||
});
|
});
|
||||||
|
@ -58,10 +52,6 @@ router.get("/:memberId/memberships", async (req: Request, res: Response) => {
|
||||||
await getMembershipsByMember(req, res);
|
await getMembershipsByMember(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/:memberId/memberships/statistics", async (req: Request, res: Response) => {
|
|
||||||
await getMembershipStatisticsById(req, res);
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get("/:memberId/membership/:id", async (req: Request, res: Response) => {
|
router.get("/:memberId/membership/:id", async (req: Request, res: Response) => {
|
||||||
await getMembershipByMemberAndRecord(req, res);
|
await getMembershipByMemberAndRecord(req, res);
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { dataSource } from "../../../data-source";
|
||||||
import { member } from "../../../entity/club/member/member";
|
import { member } from "../../../entity/club/member/member";
|
||||||
import { membership } from "../../../entity/club/member/membership";
|
import { membership } from "../../../entity/club/member/membership";
|
||||||
import InternalException from "../../../exceptions/internalException";
|
import InternalException from "../../../exceptions/internalException";
|
||||||
import { memberView } from "../../../views/memberView";
|
|
||||||
|
|
||||||
export default abstract class MemberService {
|
export default abstract class MemberService {
|
||||||
/**
|
/**
|
||||||
|
@ -133,25 +132,6 @@ export default abstract class MemberService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description get member statistics by id
|
|
||||||
* @param {number} id
|
|
||||||
* @returns {Promise<memberView>}
|
|
||||||
*/
|
|
||||||
static async getStatisticsById(id: number): Promise<memberView> {
|
|
||||||
return await dataSource
|
|
||||||
.getRepository(memberView)
|
|
||||||
.createQueryBuilder("memberView")
|
|
||||||
.where("memberView.id = :id", { id: id })
|
|
||||||
.getOneOrFail()
|
|
||||||
.then((res) => {
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
throw new InternalException("memberView not found by id", err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description get members where membership is setz
|
* @description get members where membership is setz
|
||||||
* @returns {Promise<member>}
|
* @returns {Promise<member>}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { dataSource } from "../../../data-source";
|
import { dataSource } from "../../../data-source";
|
||||||
import { membership } from "../../../entity/club/member/membership";
|
import { membership } from "../../../entity/club/member/membership";
|
||||||
import InternalException from "../../../exceptions/internalException";
|
import InternalException from "../../../exceptions/internalException";
|
||||||
import { membershipView } from "../../../views/membershipsView";
|
|
||||||
|
|
||||||
export default abstract class MembershipService {
|
export default abstract class MembershipService {
|
||||||
/**
|
/**
|
||||||
|
@ -46,23 +45,4 @@ export default abstract class MembershipService {
|
||||||
throw new InternalException("member membership not found by id", err);
|
throw new InternalException("member membership not found by id", err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description get membership statistics by memberId
|
|
||||||
* @param {number} memberId
|
|
||||||
* @returns {Promise<Array<membershipView>>}
|
|
||||||
*/
|
|
||||||
static async getStatisticsById(memberId: number): Promise<Array<membershipView>> {
|
|
||||||
return await dataSource
|
|
||||||
.getRepository(membershipView)
|
|
||||||
.createQueryBuilder("membershipView")
|
|
||||||
.where("membershipView.memberId = :memberId", { memberId: memberId })
|
|
||||||
.getMany()
|
|
||||||
.then((res) => {
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
throw new InternalException("membershipView not found by id", err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,15 +16,3 @@ export interface MemberViewModel {
|
||||||
smsAlarming?: Array<CommunicationViewModel>;
|
smsAlarming?: Array<CommunicationViewModel>;
|
||||||
preferredCommunication?: Array<CommunicationViewModel>;
|
preferredCommunication?: Array<CommunicationViewModel>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MemberStatisticsViewModel {
|
|
||||||
id: number;
|
|
||||||
salutation: Salutation;
|
|
||||||
firstname: string;
|
|
||||||
lastname: string;
|
|
||||||
nameaffix: string;
|
|
||||||
birthdate: Date;
|
|
||||||
todayAge: number;
|
|
||||||
ageThisYear: number;
|
|
||||||
exactAge: string;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import { Salutation } from "../../../../enums/salutation";
|
|
||||||
|
|
||||||
export interface MembershipViewModel {
|
export interface MembershipViewModel {
|
||||||
id: number;
|
id: number;
|
||||||
start: Date;
|
start: Date;
|
||||||
|
@ -8,16 +6,3 @@ export interface MembershipViewModel {
|
||||||
status: string;
|
status: string;
|
||||||
statusId: number;
|
statusId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MembershipStatisticsViewModel {
|
|
||||||
durationInDays: number;
|
|
||||||
durationInYears: string;
|
|
||||||
status: string;
|
|
||||||
statusId: number;
|
|
||||||
memberId: number;
|
|
||||||
memberSalutation: Salutation;
|
|
||||||
memberFirstname: string;
|
|
||||||
memberLastname: string;
|
|
||||||
memberNameaffix: string;
|
|
||||||
memberBirthdate: Date;
|
|
||||||
}
|
|
||||||
|
|
|
@ -43,5 +43,5 @@ export class memberView {
|
||||||
ageThisYear: number;
|
ageThisYear: number;
|
||||||
|
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
exactAge: string;
|
exactAge: Date;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ export class membershipView {
|
||||||
durationInDays: number;
|
durationInDays: number;
|
||||||
|
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
durationInYears: string;
|
durationInYears: Date;
|
||||||
|
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
status: string;
|
status: string;
|
||||||
|
|
Loading…
Reference in a new issue