folder structure
This commit is contained in:
parent
5d3f8ea46a
commit
84e2ec72ac
242 changed files with 635 additions and 635 deletions
86
src/service/club/calendarService.ts
Normal file
86
src/service/club/calendarService.ts
Normal file
|
@ -0,0 +1,86 @@
|
|||
import { dataSource } from "../../data-source";
|
||||
import { calendar } from "../../entity/club/calendar";
|
||||
import InternalException from "../../exceptions/internalException";
|
||||
|
||||
export default abstract class CalendarService {
|
||||
/**
|
||||
* @description get all calendars
|
||||
* @returns {Promise<Array<calendar>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<calendar>> {
|
||||
return await dataSource
|
||||
.getRepository(calendar)
|
||||
.createQueryBuilder("calendar")
|
||||
.leftJoinAndSelect("calendar.type", "type")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("calendars not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get calendar by id
|
||||
* @returns {Promise<calendar>}
|
||||
*/
|
||||
static async getById(id: string): Promise<calendar> {
|
||||
return await dataSource
|
||||
.getRepository(calendar)
|
||||
.createQueryBuilder("calendar")
|
||||
.leftJoinAndSelect("calendar.type", "type")
|
||||
.where("calendar.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("calendar not found by id", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get calendar by types
|
||||
* @returns {Promise<Array<calendar>>}
|
||||
*/
|
||||
static async getByTypes(types: Array<number>, addNscdr: boolean = false): Promise<Array<calendar>> {
|
||||
const query = dataSource
|
||||
.getRepository(calendar)
|
||||
.createQueryBuilder("calendar")
|
||||
.leftJoinAndSelect("calendar.type", "type")
|
||||
.where("type.id IN (:...types)", { types: types });
|
||||
|
||||
if (addNscdr) {
|
||||
query.orWhere("type.nscdr = :nscdr", { nscdr: true });
|
||||
}
|
||||
|
||||
return await query
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("calendars not found by types", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get calendar by types nscdr
|
||||
* @returns {Promise<Array<calendar>>}
|
||||
*/
|
||||
static async getByTypeNSCDR(): Promise<Array<calendar>> {
|
||||
return await dataSource
|
||||
.getRepository(calendar)
|
||||
.createQueryBuilder("calendar")
|
||||
.leftJoinAndSelect("calendar.type", "type")
|
||||
.where("type.nscdr = :nscdr", { nscdr: true })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("calendars not found by type nscdr", err);
|
||||
});
|
||||
}
|
||||
}
|
61
src/service/club/member/communicationService.ts
Normal file
61
src/service/club/member/communicationService.ts
Normal file
|
@ -0,0 +1,61 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { communication } from "../../../entity/club/member/communication";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class CommunicationService {
|
||||
/**
|
||||
* @description get all by member id
|
||||
* @param {number} memberId
|
||||
* @returns {Promise<Array<communication>>}
|
||||
*/
|
||||
static async getAll(memberId: number): Promise<Array<communication>> {
|
||||
return await dataSource
|
||||
.getRepository(communication)
|
||||
.createQueryBuilder("communication")
|
||||
.leftJoinAndSelect("communication.type", "communicationType")
|
||||
.leftJoinAndSelect("communication.member", "member")
|
||||
.leftJoinAndSelect("member.sendNewsletter", "sendNewsletter")
|
||||
.where("communication.memberId = :memberId", { memberId: memberId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member communications not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get all by memberId and recordId
|
||||
* @param {number} memberId
|
||||
* @param {number} recordId
|
||||
* @returns {Promise<communication>}
|
||||
*/
|
||||
static async getById(memberId: number, recordId: number): Promise<communication> {
|
||||
return await dataSource
|
||||
.getRepository(communication)
|
||||
.createQueryBuilder("communication")
|
||||
.leftJoinAndSelect("communication.type", "communicationType")
|
||||
.leftJoinAndSelect("communication.member", "member")
|
||||
.leftJoinAndSelect("member.sendNewsletter", "sendNewsletter")
|
||||
.where("communication.memberId = :memberId", { memberId: memberId })
|
||||
.andWhere("communication.id = :recordId", { recordId: recordId })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member communication not found by id", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get available columns for self made com type
|
||||
* @returns {Array<string>}
|
||||
*/
|
||||
static getAvailableColumnsForCommunication(): Array<string> {
|
||||
let metadata = dataSource.getMetadata(communication);
|
||||
let columns = metadata.columns.map((c) => c.propertyName);
|
||||
return columns.filter((c) => !["id", "preferred", "isSMSAlarming", "type", "member"].includes(c));
|
||||
}
|
||||
}
|
47
src/service/club/member/memberAwardService.ts
Normal file
47
src/service/club/member/memberAwardService.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { memberAwards } from "../../../entity/club/member/memberAwards";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class MemberAwardService {
|
||||
/**
|
||||
* @description get all by member id
|
||||
* @param {number} memberId
|
||||
* @returns {Promise<Array<memberAwards>>}
|
||||
*/
|
||||
static async getAll(memberId: number): Promise<Array<memberAwards>> {
|
||||
return await dataSource
|
||||
.getRepository(memberAwards)
|
||||
.createQueryBuilder("memberAwards")
|
||||
.leftJoinAndSelect("memberAwards.award", "award")
|
||||
.where("memberAwards.memberId = :memberId", { memberId: memberId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member awards not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get by memberId and recordId
|
||||
* @param {number} memberId
|
||||
* @param {number} recordId
|
||||
* @returns {Promise<Array<member>>}
|
||||
*/
|
||||
static async getById(memberId: number, recordId: number): Promise<memberAwards> {
|
||||
return await dataSource
|
||||
.getRepository(memberAwards)
|
||||
.createQueryBuilder("memberAwards")
|
||||
.leftJoinAndSelect("memberAwards.award", "award")
|
||||
.where("memberAwards.memberId = :memberId", { memberId: memberId })
|
||||
.andWhere("memberAwards.id = :recordId", { recordId: recordId })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member award not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
49
src/service/club/member/memberExecutivePositionService.ts
Normal file
49
src/service/club/member/memberExecutivePositionService.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { memberExecutivePositions } from "../../../entity/club/member/memberExecutivePositions";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class MemberExecutivePositionService {
|
||||
/**
|
||||
* @description get all by member id
|
||||
* @param {number} memberId
|
||||
* @returns {Promise<Array<memberExecutivePositions>>}
|
||||
*/
|
||||
static async getAll(memberId: number): Promise<Array<memberExecutivePositions>> {
|
||||
return await dataSource
|
||||
.getRepository(memberExecutivePositions)
|
||||
.createQueryBuilder("memberExecutivePositions")
|
||||
.leftJoinAndSelect("memberExecutivePositions.executivePosition", "executivePosition")
|
||||
.where("memberExecutivePositions.memberId = :memberId", { memberId: memberId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member executivePositions not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get by memberId and recordId
|
||||
* @param {number} memberId
|
||||
* @param {number} recordId
|
||||
* @returns {Promise<Array<member>>}
|
||||
*/
|
||||
static async getById(memberId: number, recordId: number): Promise<memberExecutivePositions> {
|
||||
return await dataSource
|
||||
.getRepository(memberExecutivePositions)
|
||||
.createQueryBuilder("memberExecutivePositions")
|
||||
.leftJoinAndSelect("memberExecutivePositions.executivePosition", "executivePosition")
|
||||
.where("memberExecutivePositions.memberId = :memberId", { memberId: memberId })
|
||||
.andWhere("memberExecutivePositions.id = :recordId", {
|
||||
recordId: recordId,
|
||||
})
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member executivePosition not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
47
src/service/club/member/memberQualificationService.ts
Normal file
47
src/service/club/member/memberQualificationService.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { memberQualifications } from "../../../entity/club/member/memberQualifications";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class MemberQualificationService {
|
||||
/**
|
||||
* @description get all by member id
|
||||
* @param {number} memberId
|
||||
* @returns {Promise<Array<memberQualifications>>}
|
||||
*/
|
||||
static async getAll(memberId: number): Promise<Array<memberQualifications>> {
|
||||
return await dataSource
|
||||
.getRepository(memberQualifications)
|
||||
.createQueryBuilder("memberQualifications")
|
||||
.leftJoinAndSelect("memberQualifications.qualification", "qualification")
|
||||
.where("memberQualifications.memberId = :memberId", { memberId: memberId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member qualifications not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get by memberId and recordId
|
||||
* @param {number} memberId
|
||||
* @param {number} recordId
|
||||
* @returns {Promise<Array<member>>}
|
||||
*/
|
||||
static async getById(memberId: number, recordId: number): Promise<memberQualifications> {
|
||||
return await dataSource
|
||||
.getRepository(memberQualifications)
|
||||
.createQueryBuilder("memberQualifications")
|
||||
.leftJoinAndSelect("memberQualifications.qualification", "qualification")
|
||||
.where("memberQualifications.memberId = :memberId", { memberId: memberId })
|
||||
.andWhere("memberQualifications.id = :recordId", { recordId: recordId })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member qualification not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
155
src/service/club/member/memberService.ts
Normal file
155
src/service/club/member/memberService.ts
Normal file
|
@ -0,0 +1,155 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { member } from "../../../entity/club/member/member";
|
||||
import { membership } from "../../../entity/club/member/membership";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class MemberService {
|
||||
/**
|
||||
* @description get all members
|
||||
* @returns {Promise<[Array<member>, number]>}
|
||||
*/
|
||||
static async getAll(offset: number = 0, count: number = 25, search: string = ""): Promise<[Array<member>, number]> {
|
||||
let query = dataSource
|
||||
.getRepository(member)
|
||||
.createQueryBuilder("member")
|
||||
.leftJoinAndMapOne(
|
||||
"member.firstMembershipEntry",
|
||||
"member.memberships",
|
||||
"membership_first",
|
||||
"membership_first.memberId = member.id AND membership_first.start = (SELECT MIN(m.start) FROM membership m WHERE m.memberId = member.id)"
|
||||
)
|
||||
.leftJoinAndMapOne(
|
||||
"member.lastMembershipEntry",
|
||||
"member.memberships",
|
||||
"membership_last",
|
||||
"membership_last.memberId = member.id AND membership_last.start = (SELECT MAX(m.start) FROM membership m WHERE m.memberId = member.id)"
|
||||
)
|
||||
.leftJoinAndSelect("membership_first.status", "status_first")
|
||||
.leftJoinAndSelect("membership_last.status", "status_last")
|
||||
.leftJoinAndSelect("member.sendNewsletter", "sendNewsletter")
|
||||
.leftJoinAndSelect("sendNewsletter.type", "communicationtype")
|
||||
.leftJoinAndMapMany(
|
||||
"member.preferredCommunication",
|
||||
"member.communications",
|
||||
"preferredCommunication",
|
||||
"preferredCommunication.preferred = 1"
|
||||
)
|
||||
.leftJoinAndSelect("preferredCommunication.type", "communicationtype_preferred")
|
||||
.leftJoinAndMapMany("member.smsAlarming", "member.communications", "smsAlarming", "smsAlarming.isSMSAlarming = 1")
|
||||
.leftJoinAndSelect("smsAlarming.type", "communicationtype_smsAlarming");
|
||||
|
||||
if (search != "") {
|
||||
search.split(" ").forEach((term, index) => {
|
||||
const searchQuery = `%${term}%`;
|
||||
const dynamic = "searchQuery" + Math.random().toString(36).substring(2);
|
||||
if (index == 0) {
|
||||
query = query.where(`member.firstname LIKE :${dynamic} OR member.lastname LIKE :${dynamic}`, {
|
||||
[dynamic]: searchQuery,
|
||||
});
|
||||
} else {
|
||||
query = query.orWhere(`member.firstname LIKE :${dynamic} OR member.lastname LIKE :${dynamic}`, {
|
||||
[dynamic]: searchQuery,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return await query
|
||||
.offset(offset)
|
||||
.limit(count)
|
||||
.orderBy("member.lastname")
|
||||
.addOrderBy("member.firstname")
|
||||
.addOrderBy("member.nameaffix")
|
||||
.getManyAndCount()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("members not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get member by id
|
||||
* @param {number} id
|
||||
* @returns {Promise<member>}
|
||||
*/
|
||||
static async getById(id: number): Promise<member> {
|
||||
return await dataSource
|
||||
.getRepository(member)
|
||||
.createQueryBuilder("member")
|
||||
.leftJoinAndMapOne(
|
||||
"member.firstMembershipEntry",
|
||||
"member.memberships",
|
||||
"membership_first",
|
||||
"membership_first.memberId = member.id AND membership_first.start = (SELECT MIN(m.start) FROM membership m WHERE m.memberId = member.id)"
|
||||
)
|
||||
.leftJoinAndMapOne(
|
||||
"member.lastMembershipEntry",
|
||||
"member.memberships",
|
||||
"membership_last",
|
||||
"membership_last.memberId = member.id AND membership_last.start = (SELECT MAX(m.start) FROM membership m WHERE m.memberId = member.id)"
|
||||
)
|
||||
.leftJoinAndSelect("membership_first.status", "status_first")
|
||||
.leftJoinAndSelect("membership_last.status", "status_last")
|
||||
.leftJoinAndSelect("member.sendNewsletter", "sendNewsletter")
|
||||
.leftJoinAndSelect("sendNewsletter.type", "communicationtype")
|
||||
.leftJoinAndMapMany(
|
||||
"member.preferredCommunication",
|
||||
"member.communications",
|
||||
"preferredCommunication",
|
||||
"preferredCommunication.preferred = 1"
|
||||
)
|
||||
|
||||
.leftJoinAndMapMany("member.smsAlarming", "member.communications", "smsAlarming", "smsAlarming.isSMSAlarming = 1")
|
||||
.leftJoinAndSelect("smsAlarming.type", "communicationtype_smsAlarming")
|
||||
.leftJoinAndSelect("preferredCommunication.type", "communicationtype_preferred")
|
||||
.where("member.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member not found by id", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get members where membership is setz
|
||||
* @returns {Promise<member>}
|
||||
*/
|
||||
static async getByRunningMembership(): Promise<Array<member>> {
|
||||
return await dataSource
|
||||
.getRepository(member)
|
||||
.createQueryBuilder("member")
|
||||
.leftJoinAndSelect("member.memberships", "membership")
|
||||
.where("membership.end IS NULL")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member not found by id", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get newsletter by member by id
|
||||
* @param {number} id
|
||||
* @returns {Promise<member>}
|
||||
*/
|
||||
static async getNewsletterById(id: number): Promise<member> {
|
||||
return await dataSource
|
||||
.getRepository(member)
|
||||
.createQueryBuilder("member")
|
||||
.leftJoinAndSelect("member.sendNewsletter", "sendNewsletter")
|
||||
.where("member.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
48
src/service/club/member/membershipService.ts
Normal file
48
src/service/club/member/membershipService.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { membership } from "../../../entity/club/member/membership";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class MembershipService {
|
||||
/**
|
||||
* @description get all by member id
|
||||
* @param {number} memberId
|
||||
* @returns {Promise<Array<membership>>}
|
||||
*/
|
||||
static async getAll(memberId: number): Promise<Array<membership>> {
|
||||
return await dataSource
|
||||
.getRepository(membership)
|
||||
.createQueryBuilder("membership")
|
||||
.leftJoinAndSelect("membership.status", "membershipStatus")
|
||||
.where("membership.memberId = :memberId", { memberId: memberId })
|
||||
.orderBy("membership.start", "DESC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member memberships not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get by memberId and recordId
|
||||
* @param {number} memberId
|
||||
* @param {number} recordId
|
||||
* @returns {Promise<Array<member>>}
|
||||
*/
|
||||
static async getById(memberId: number, recordId: number): Promise<membership> {
|
||||
return await dataSource
|
||||
.getRepository(membership)
|
||||
.createQueryBuilder("membership")
|
||||
.leftJoinAndSelect("membership.status", "membershipStatus")
|
||||
.where("membership.memberId = :memberId", { memberId: memberId })
|
||||
.andWhere("membership.id = :recordId", { recordId: recordId })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("member membership not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
27
src/service/club/newsletter/newsletterDatesService.ts
Normal file
27
src/service/club/newsletter/newsletterDatesService.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { newsletterDates } from "../../../entity/club/newsletter/newsletterDates";
|
||||
import { member } from "../../../entity/club/member/member";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class NewsletterDatesService {
|
||||
/**
|
||||
* @description get all newsletterDates
|
||||
* @returns {Promise<Array<newsletterDates>>}
|
||||
*/
|
||||
static async getAll(newsletterId: number): Promise<Array<newsletterDates>> {
|
||||
return await dataSource
|
||||
.getRepository(newsletterDates)
|
||||
.createQueryBuilder("newsletterDates")
|
||||
.leftJoinAndSelect("newsletterDates.calendar", "calendar")
|
||||
.leftJoinAndSelect("calendar.type", "type")
|
||||
.leftJoinAndSelect("newsletterDates.newsletter", "newsletter")
|
||||
.where("newsletterDates.newsletterId = :id", { id: newsletterId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("newsletterDatess not found", err);
|
||||
});
|
||||
}
|
||||
}
|
28
src/service/club/newsletter/newsletterRecipientsService.ts
Normal file
28
src/service/club/newsletter/newsletterRecipientsService.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { newsletterRecipients } from "../../../entity/club/newsletter/newsletterRecipients";
|
||||
import { member } from "../../../entity/club/member/member";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class NewsletterRecipientsService {
|
||||
/**
|
||||
* @description get all newsletterRecipients
|
||||
* @returns {Promise<Array<newsletterRecipients>>}
|
||||
*/
|
||||
static async getAll(newsletterId: number): Promise<Array<newsletterRecipients>> {
|
||||
return await dataSource
|
||||
.getRepository(newsletterRecipients)
|
||||
.createQueryBuilder("newsletterRecipients")
|
||||
.leftJoinAndSelect("newsletterRecipients.member", "member")
|
||||
.leftJoinAndSelect("member.sendNewsletter", "sendNewsletter")
|
||||
.leftJoinAndSelect("sendNewsletter.type", "communicationtype")
|
||||
.leftJoinAndSelect("newsletterRecipients.newsletter", "newsletter")
|
||||
.where("newsletterRecipients.newsletterId = :id", { id: newsletterId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("newsletterRecipients not found", err);
|
||||
});
|
||||
}
|
||||
}
|
43
src/service/club/newsletter/newsletterService.ts
Normal file
43
src/service/club/newsletter/newsletterService.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { newsletter } from "../../../entity/club/newsletter/newsletter";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class NewsletterService {
|
||||
/**
|
||||
* @description get all newsletters
|
||||
* @returns {Promise<[Array<newsletter>, number]>}
|
||||
*/
|
||||
static async getAll(offset: number = 0, count: number = 25): Promise<[Array<newsletter>, number]> {
|
||||
return await dataSource
|
||||
.getRepository(newsletter)
|
||||
.createQueryBuilder("newsletter")
|
||||
.offset(offset)
|
||||
.limit(count)
|
||||
.getManyAndCount()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("newsletters not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get newsletter by id
|
||||
* @returns {Promise<newsletter>}
|
||||
*/
|
||||
static async getById(id: number): Promise<newsletter> {
|
||||
return await dataSource
|
||||
.getRepository(newsletter)
|
||||
.createQueryBuilder("newsletter")
|
||||
.leftJoinAndSelect("newsletter.recipientsByQuery", "query")
|
||||
.where("newsletter.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("newsletter not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/club/protocol/protocolAgendaService.ts
Normal file
41
src/service/club/protocol/protocolAgendaService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { protocolAgenda } from "../../../entity/club/protocol/protocolAgenda";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class ProtocolAgendaService {
|
||||
/**
|
||||
* @description get all protocolAgendas
|
||||
* @returns {Promise<Array<protocolAgenda>>}
|
||||
*/
|
||||
static async getAll(protocolId: number): Promise<Array<protocolAgenda>> {
|
||||
return await dataSource
|
||||
.getRepository(protocolAgenda)
|
||||
.createQueryBuilder("protocolAgenda")
|
||||
.where("protocolAgenda.protocolId = :protocolId", { protocolId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolAgendas not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get protocolAgenda by id
|
||||
* @returns {Promise<protocolAgenda>}
|
||||
*/
|
||||
static async getById(id: number): Promise<protocolAgenda> {
|
||||
return await dataSource
|
||||
.getRepository(protocolAgenda)
|
||||
.createQueryBuilder("protocolAgenda")
|
||||
.where("protocolAgenda.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolAgenda not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/club/protocol/protocolDecisionService.ts
Normal file
41
src/service/club/protocol/protocolDecisionService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { protocolDecision } from "../../../entity/club/protocol/protocolDecision";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class ProtocolDecisionService {
|
||||
/**
|
||||
* @description get all protocolDecisionss
|
||||
* @returns {Promise<Array<protocolDecision>>}
|
||||
*/
|
||||
static async getAll(protocolId: number): Promise<Array<protocolDecision>> {
|
||||
return await dataSource
|
||||
.getRepository(protocolDecision)
|
||||
.createQueryBuilder("protocolDecisions")
|
||||
.where("protocolDecisions.protocolId = :protocolId", { protocolId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolDecisions not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get protocolDecision by id
|
||||
* @returns {Promise<protocolDecision>}
|
||||
*/
|
||||
static async getById(id: number): Promise<protocolDecision> {
|
||||
return await dataSource
|
||||
.getRepository(protocolDecision)
|
||||
.createQueryBuilder("protocolDecisions")
|
||||
.where("protocolDecisions.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolDecision not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
24
src/service/club/protocol/protocolPrecenseService.ts
Normal file
24
src/service/club/protocol/protocolPrecenseService.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { protocolPresence } from "../../../entity/club/protocol/protocolPresence";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class ProtocolPresenceService {
|
||||
/**
|
||||
* @description get all protocolPresences
|
||||
* @returns {Promise<Array<protocolPresence>>}
|
||||
*/
|
||||
static async getAll(protocolId: number): Promise<Array<protocolPresence>> {
|
||||
return await dataSource
|
||||
.getRepository(protocolPresence)
|
||||
.createQueryBuilder("protocolPresence")
|
||||
.leftJoinAndSelect("protocolPresence.member", "member")
|
||||
.where("protocolPresence.protocolId = :protocolId", { protocolId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolPresence not found", err);
|
||||
});
|
||||
}
|
||||
}
|
60
src/service/club/protocol/protocolPrintoutService.ts
Normal file
60
src/service/club/protocol/protocolPrintoutService.ts
Normal file
|
@ -0,0 +1,60 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { protocolPrintout } from "../../../entity/club/protocol/protocolPrintout";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class ProtocolPrintoutService {
|
||||
/**
|
||||
* @description get all protocolPrintouts
|
||||
* @returns {Promise<Array<protocolPrintout>>}
|
||||
*/
|
||||
static async getAll(protocolId: number): Promise<Array<protocolPrintout>> {
|
||||
return await dataSource
|
||||
.getRepository(protocolPrintout)
|
||||
.createQueryBuilder("protocolPrintout")
|
||||
.where("protocolPrintout.protocolId = :protocolId", { protocolId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolPrintouts not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get protocolPrintout by id
|
||||
* @returns {Promise<protocolPrintout>}
|
||||
*/
|
||||
static async getById(id: number, protocolId: number): Promise<protocolPrintout> {
|
||||
return await dataSource
|
||||
.getRepository(protocolPrintout)
|
||||
.createQueryBuilder("protocolPrintout")
|
||||
.where("protocolPrintout.protocolId = :protocolId", { protocolId })
|
||||
.andWhere("protocolPrintout.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolPrintout not found by id", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get count of printouts by id
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
static async getCount(protocolId: number): Promise<number> {
|
||||
return await dataSource
|
||||
.getRepository(protocolPrintout)
|
||||
.createQueryBuilder("protocolPrintout")
|
||||
.where("protocolPrintout.protocolId = :protocolId", { protocolId })
|
||||
.getCount()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolPrintout not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
43
src/service/club/protocol/protocolService.ts
Normal file
43
src/service/club/protocol/protocolService.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { protocol } from "../../../entity/club/protocol/protocol";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class ProtocolService {
|
||||
/**
|
||||
* @description get all protocols
|
||||
* @returns {Promise<[Array<protocol>, number]>}
|
||||
*/
|
||||
static async getAll(offset: number = 0, count: number = 25): Promise<[Array<protocol>, number]> {
|
||||
return await dataSource
|
||||
.getRepository(protocol)
|
||||
.createQueryBuilder("protocol")
|
||||
.offset(offset)
|
||||
.limit(count)
|
||||
.orderBy("date", "DESC")
|
||||
.getManyAndCount()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocols not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get protocol by id
|
||||
* @returns {Promise<protocol>}
|
||||
*/
|
||||
static async getById(id: number): Promise<protocol> {
|
||||
return await dataSource
|
||||
.getRepository(protocol)
|
||||
.createQueryBuilder("protocol")
|
||||
.where("protocol.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocol not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/club/protocol/protocolVotingService.ts
Normal file
41
src/service/club/protocol/protocolVotingService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { protocolVoting } from "../../../entity/club/protocol/protocolVoting";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class ProtocolVotingService {
|
||||
/**
|
||||
* @description get all protocolVotingss
|
||||
* @returns {Promise<Array<protocolVoting>>}
|
||||
*/
|
||||
static async getAll(protocolId: number): Promise<Array<protocolVoting>> {
|
||||
return await dataSource
|
||||
.getRepository(protocolVoting)
|
||||
.createQueryBuilder("protocolVotings")
|
||||
.where("protocolVotings.protocolId = :protocolId", { protocolId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolVotings not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get protocolVoting by id
|
||||
* @returns {Promise<protocolVoting>}
|
||||
*/
|
||||
static async getById(id: number): Promise<protocolVoting> {
|
||||
return await dataSource
|
||||
.getRepository(protocolVoting)
|
||||
.createQueryBuilder("protocolVotings")
|
||||
.where("protocolVotings.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolVoting not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue