service to memberdata

This commit is contained in:
Julian Krauser 2024-09-15 14:03:15 +02:00
parent c543d4e4ed
commit e455b5c8f6
6 changed files with 88 additions and 102 deletions

View file

@ -1,6 +1,6 @@
import { dataSource } from "../data-source"; import { dataSource } from "../data-source";
import { award } from "../entity/award"; import { award } from "../entity/award";
import { user } from "../entity/user"; import { member } from "../entity/member";
import InternalException from "../exceptions/internalException"; import InternalException from "../exceptions/internalException";
export default abstract class AwardService { export default abstract class AwardService {
@ -29,7 +29,7 @@ export default abstract class AwardService {
return await dataSource return await dataSource
.getRepository(award) .getRepository(award)
.createQueryBuilder("award") .createQueryBuilder("award")
.andWhere("award.id = :id", { id: id }) .where("award.id = :id", { id: id })
.getOneOrFail() .getOneOrFail()
.then((res) => { .then((res) => {
return res; return res;
@ -39,22 +39,22 @@ export default abstract class AwardService {
}); });
} }
// /** /**
// * @description get members assigned to award * @description get members assigned to award
// * @returns {Promise<Array<member>>} * @returns {Promise<Array<member>>}
// */ */
// static async getMembersByAwardId(id: number): Promise<Array<member>> { static async getMembersByAwardId(id: number): Promise<Array<member>> {
// return await dataSource return await dataSource
// .getRepository(award) .getRepository(award)
// .createQueryBuilder("award") .createQueryBuilder("award")
// .leftJoinAndSelect("award.members", "members") .leftJoinAndSelect("award.members", "members")
// .andWhere("award.id = :id", { id: id }) .where("award.id = :id", { id: id })
// .getOneOrFail() .getOneOrFail()
// .then((res) => { .then((res) => {
// return []; return [];
// }) })
// .catch((err) => { .catch((err) => {
// throw new InternalException("award assigned members not found by id", err); throw new InternalException("award assigned members not found by id", err);
// }); });
// } }
} }

View file

@ -12,7 +12,7 @@ export default abstract class CommunicationService {
.getRepository(communication) .getRepository(communication)
.createQueryBuilder("communication") .createQueryBuilder("communication")
.leftJoin("communication.user", "user") .leftJoin("communication.user", "user")
.andWhere("user.id = :id", { id: userId }) .where("user.id = :id", { id: userId })
.getOneOrFail() .getOneOrFail()
.then((res) => { .then((res) => {
return res; return res;

View file

@ -1,7 +1,5 @@
import { dataSource } from "../data-source"; import { dataSource } from "../data-source";
import { communication } from "../entity/communication";
import { communicationType } from "../entity/communicationType"; import { communicationType } from "../entity/communicationType";
import { user } from "../entity/user";
import InternalException from "../exceptions/internalException"; import InternalException from "../exceptions/internalException";
export default abstract class CommunicationTypeService { export default abstract class CommunicationTypeService {
@ -30,7 +28,7 @@ export default abstract class CommunicationTypeService {
return await dataSource return await dataSource
.getRepository(communicationType) .getRepository(communicationType)
.createQueryBuilder("communicationType") .createQueryBuilder("communicationType")
.andWhere("communicationType.id = :id", { id: id }) .where("communicationType.id = :id", { id: id })
.getOneOrFail() .getOneOrFail()
.then((res) => { .then((res) => {
return res; return res;
@ -39,23 +37,4 @@ export default abstract class CommunicationTypeService {
throw new InternalException("communicationType not found by id", err); throw new InternalException("communicationType not found by id", err);
}); });
} }
// /**
// * @description get members assigned to communicationType
// * @returns {Promise<Array<member>>}
// */
// static async getMembersBycommunicationTypeId(id: number): Promise<Array<member>> {
// return await dataSource
// .getRepository(communicationType)
// .createQueryBuilder("communicationType")
// .leftJoinAndSelect("communicationType.members", "members")
// .andWhere("communicationType.id = :id", { id: id })
// .getOneOrFail()
// .then((res) => {
// return [];
// })
// .catch((err) => {
// throw new InternalException("communicationType assigned members not found by id", err);
// });
// }
} }

View file

@ -1,6 +1,6 @@
import { dataSource } from "../data-source"; import { dataSource } from "../data-source";
import { executivePosition } from "../entity/executivePosition"; import { executivePosition } from "../entity/executivePosition";
import { user } from "../entity/user"; import { memberExecutivePositions } from "../entity/memberExecutivePositions";
import InternalException from "../exceptions/internalException"; import InternalException from "../exceptions/internalException";
export default abstract class ExecutivePositionService { export default abstract class ExecutivePositionService {
@ -29,7 +29,7 @@ export default abstract class ExecutivePositionService {
return await dataSource return await dataSource
.getRepository(executivePosition) .getRepository(executivePosition)
.createQueryBuilder("executivePosition") .createQueryBuilder("executivePosition")
.andWhere("executivePosition.id = :id", { id: id }) .where("executivePosition.id = :id", { id: id })
.getOneOrFail() .getOneOrFail()
.then((res) => { .then((res) => {
return res; return res;
@ -39,22 +39,23 @@ export default abstract class ExecutivePositionService {
}); });
} }
// /** /**
// * @description get members assigned to executivePosition * @description get members assigned to executivePosition
// * @returns {Promise<Array<user>>} * @returns {Promise<Array<memberExecutivePositions>>}
// */ */
// static async getMembersByexecutivePositionId(id: number): Promise<Array<member>> { static async getMembersByexecutivePositionId(id: number): Promise<Array<memberExecutivePositions>> {
// return await dataSource return await dataSource
// .getRepository(executivePosition) .getRepository(executivePosition)
// .createQueryBuilder("executivePosition") .createQueryBuilder("executivePosition")
// .leftJoinAndSelect("executivePosition.members", "members") .leftJoinAndSelect("executivePosition.members", "memberExecutivePositions")
// .andWhere("executivePosition.id = :id", { id: id }) .leftJoinAndSelect("memberExecutivePositions.member", "member")
// .getOneOrFail() .where("executivePosition.id = :id", { id: id })
// .then((res) => { .getOneOrFail()
// return []; .then((res) => {
// }) return res.members;
// .catch(() => { })
// throw new InternalException("executivePosition assigned members not found by id"); .catch(() => {
// }); throw new InternalException("executivePosition assigned members not found by id");
// } });
}
} }

View file

@ -1,7 +1,7 @@
import { dataSource } from "../data-source"; import { dataSource } from "../data-source";
import { membershipStatus } from "../entity/membershipStatus"; import { membershipStatus } from "../entity/membershipStatus";
import { user } from "../entity/user";
import InternalException from "../exceptions/internalException"; import InternalException from "../exceptions/internalException";
import { membership } from "../entity/membership";
export default abstract class MembershipStatusService { export default abstract class MembershipStatusService {
/** /**
@ -29,7 +29,7 @@ export default abstract class MembershipStatusService {
return await dataSource return await dataSource
.getRepository(membershipStatus) .getRepository(membershipStatus)
.createQueryBuilder("membershipStatus") .createQueryBuilder("membershipStatus")
.andWhere("membershipStatus.id = :id", { id: id }) .where("membershipStatus.id = :id", { id: id })
.getOneOrFail() .getOneOrFail()
.then((res) => { .then((res) => {
return res; return res;
@ -39,22 +39,26 @@ export default abstract class MembershipStatusService {
}); });
} }
// /** /**
// * @description get members assigned to membershipStatus * @description get active memberships assigned to membershipStatus
// * @returns {Promise<Array<members>>} * @returns {Promise<Array<membership>>}
// */ */
// static async getMembersBymembershipStatusId(id: number): Promise<Array<members>> { static async getMembersBymembershipStatusId(id: number): Promise<Array<membership>> {
// return await dataSource return await dataSource
// .getRepository(membershipStatus) .getRepository(membershipStatus)
// .createQueryBuilder("membershipStatus") .createQueryBuilder("membershipStatus")
// .leftJoinAndSelect("membershipStatus.members", "members") .leftJoinAndSelect("membershipStatus.memberships", "memberships")
// .andWhere("membershipStatus.id = :id", { id: id }) .leftJoinAndSelect("memberships.member", "member")
// .getOneOrFail() .where("membershipStatus.id = :id", { id: id })
// .then((res) => { .andWhere("membership.start <= :start", { start: new Date() })
// return []; .andWhere("membership.end >= :end", { end: new Date() })
// }) .orWhere("membership.end IS NULL")
// .catch((err) => { .getOneOrFail()
// throw new InternalException("membershipStatus assigned members not found by id", err); .then((res) => {
// }); return res.memberships;
// } })
.catch((err) => {
throw new InternalException("membershipStatus assigned members not found by id", err);
});
}
} }

View file

@ -1,4 +1,5 @@
import { dataSource } from "../data-source"; import { dataSource } from "../data-source";
import { memberQualifications } from "../entity/memberQualifications";
import { qualification } from "../entity/qualification"; import { qualification } from "../entity/qualification";
import { user } from "../entity/user"; import { user } from "../entity/user";
import InternalException from "../exceptions/internalException"; import InternalException from "../exceptions/internalException";
@ -29,7 +30,7 @@ export default abstract class QualificationService {
return await dataSource return await dataSource
.getRepository(qualification) .getRepository(qualification)
.createQueryBuilder("qualification") .createQueryBuilder("qualification")
.andWhere("qualification.id = :id", { id: id }) .where("qualification.id = :id", { id: id })
.getOneOrFail() .getOneOrFail()
.then((res) => { .then((res) => {
return res; return res;
@ -39,22 +40,23 @@ export default abstract class QualificationService {
}); });
} }
// /** /**
// * @description get members assigned to qualification * @description get members assigned to qualification
// * @returns {Promise<Array<member>>} * @returns {Promise<Array<memberQualifications>>}
// */ */
// static async getMembersByqualificationId(id: number): Promise<Array<member>> { static async getMembersByqualificationId(id: number): Promise<Array<memberQualifications>> {
// return await dataSource return await dataSource
// .getRepository(qualification) .getRepository(qualification)
// .createQueryBuilder("qualification") .createQueryBuilder("qualification")
// .leftJoinAndSelect("qualification.members", "members") .leftJoinAndSelect("qualification.members", "memberQualifications")
// .andWhere("qualification.id = :id", { id: id }) .leftJoinAndSelect("memberQualifications.members", "members")
// .getOneOrFail() .where("qualification.id = :id", { id: id })
// .then((res) => { .getOneOrFail()
// return []; .then((res) => {
// }) return res.members;
// .catch((err) => { })
// throw new InternalException("qualification assigned members not found by id", err); .catch((err) => {
// }); throw new InternalException("qualification assigned members not found by id", err);
// } });
}
} }