service to memberdata
This commit is contained in:
parent
c543d4e4ed
commit
e455b5c8f6
6 changed files with 88 additions and 102 deletions
|
@ -1,6 +1,6 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { award } from "../entity/award";
|
||||
import { user } from "../entity/user";
|
||||
import { member } from "../entity/member";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
||||
export default abstract class AwardService {
|
||||
|
@ -29,7 +29,7 @@ export default abstract class AwardService {
|
|||
return await dataSource
|
||||
.getRepository(award)
|
||||
.createQueryBuilder("award")
|
||||
.andWhere("award.id = :id", { id: id })
|
||||
.where("award.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
|
@ -39,22 +39,22 @@ export default abstract class AwardService {
|
|||
});
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @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")
|
||||
// .andWhere("award.id = :id", { id: id })
|
||||
// .getOneOrFail()
|
||||
// .then((res) => {
|
||||
// return [];
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// throw new InternalException("award assigned members 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ export default abstract class CommunicationService {
|
|||
.getRepository(communication)
|
||||
.createQueryBuilder("communication")
|
||||
.leftJoin("communication.user", "user")
|
||||
.andWhere("user.id = :id", { id: userId })
|
||||
.where("user.id = :id", { id: userId })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { communication } from "../entity/communication";
|
||||
import { communicationType } from "../entity/communicationType";
|
||||
import { user } from "../entity/user";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
||||
export default abstract class CommunicationTypeService {
|
||||
|
@ -30,7 +28,7 @@ export default abstract class CommunicationTypeService {
|
|||
return await dataSource
|
||||
.getRepository(communicationType)
|
||||
.createQueryBuilder("communicationType")
|
||||
.andWhere("communicationType.id = :id", { id: id })
|
||||
.where("communicationType.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
|
@ -39,23 +37,4 @@ export default abstract class CommunicationTypeService {
|
|||
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);
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { executivePosition } from "../entity/executivePosition";
|
||||
import { user } from "../entity/user";
|
||||
import { memberExecutivePositions } from "../entity/memberExecutivePositions";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
||||
export default abstract class ExecutivePositionService {
|
||||
|
@ -29,7 +29,7 @@ export default abstract class ExecutivePositionService {
|
|||
return await dataSource
|
||||
.getRepository(executivePosition)
|
||||
.createQueryBuilder("executivePosition")
|
||||
.andWhere("executivePosition.id = :id", { id: id })
|
||||
.where("executivePosition.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
|
@ -39,22 +39,23 @@ export default abstract class ExecutivePositionService {
|
|||
});
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @description get members assigned to executivePosition
|
||||
// * @returns {Promise<Array<user>>}
|
||||
// */
|
||||
// static async getMembersByexecutivePositionId(id: number): Promise<Array<member>> {
|
||||
// return await dataSource
|
||||
// .getRepository(executivePosition)
|
||||
// .createQueryBuilder("executivePosition")
|
||||
// .leftJoinAndSelect("executivePosition.members", "members")
|
||||
// .andWhere("executivePosition.id = :id", { id: id })
|
||||
// .getOneOrFail()
|
||||
// .then((res) => {
|
||||
// return [];
|
||||
// })
|
||||
// .catch(() => {
|
||||
// throw new InternalException("executivePosition assigned members not found by id");
|
||||
// });
|
||||
// }
|
||||
/**
|
||||
* @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");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { membershipStatus } from "../entity/membershipStatus";
|
||||
import { user } from "../entity/user";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
import { membership } from "../entity/membership";
|
||||
|
||||
export default abstract class MembershipStatusService {
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ export default abstract class MembershipStatusService {
|
|||
return await dataSource
|
||||
.getRepository(membershipStatus)
|
||||
.createQueryBuilder("membershipStatus")
|
||||
.andWhere("membershipStatus.id = :id", { id: id })
|
||||
.where("membershipStatus.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
|
@ -39,22 +39,26 @@ export default abstract class MembershipStatusService {
|
|||
});
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @description get members assigned to membershipStatus
|
||||
// * @returns {Promise<Array<members>>}
|
||||
// */
|
||||
// static async getMembersBymembershipStatusId(id: number): Promise<Array<members>> {
|
||||
// return await dataSource
|
||||
// .getRepository(membershipStatus)
|
||||
// .createQueryBuilder("membershipStatus")
|
||||
// .leftJoinAndSelect("membershipStatus.members", "members")
|
||||
// .andWhere("membershipStatus.id = :id", { id: id })
|
||||
// .getOneOrFail()
|
||||
// .then((res) => {
|
||||
// return [];
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// throw new InternalException("membershipStatus assigned members 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { memberQualifications } from "../entity/memberQualifications";
|
||||
import { qualification } from "../entity/qualification";
|
||||
import { user } from "../entity/user";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
@ -29,7 +30,7 @@ export default abstract class QualificationService {
|
|||
return await dataSource
|
||||
.getRepository(qualification)
|
||||
.createQueryBuilder("qualification")
|
||||
.andWhere("qualification.id = :id", { id: id })
|
||||
.where("qualification.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
|
@ -39,22 +40,23 @@ export default abstract class QualificationService {
|
|||
});
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @description get members assigned to qualification
|
||||
// * @returns {Promise<Array<member>>}
|
||||
// */
|
||||
// static async getMembersByqualificationId(id: number): Promise<Array<member>> {
|
||||
// return await dataSource
|
||||
// .getRepository(qualification)
|
||||
// .createQueryBuilder("qualification")
|
||||
// .leftJoinAndSelect("qualification.members", "members")
|
||||
// .andWhere("qualification.id = :id", { id: id })
|
||||
// .getOneOrFail()
|
||||
// .then((res) => {
|
||||
// return [];
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// throw new InternalException("qualification assigned members 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue