diff --git a/.dockerignore b/.dockerignore index 4b56232..9ede668 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,5 +2,5 @@ node_modules/ dist/ .git/ -export/ +files/ .env \ No newline at end of file diff --git a/.gitignore b/.gitignore index 89904f3..7efd6b5 100644 --- a/.gitignore +++ b/.gitignore @@ -130,6 +130,6 @@ dist .yarn/install-state.gz .pnp.* -export +files .idea \ No newline at end of file diff --git a/README.md b/README.md index 670a481..e146e48 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ services: - CLUB_NAME= - CLUB_WEBSITE= volumes: - - :/app/export + - :/app/files networks: - ff_internal depends_on: diff --git a/src/command/calendarCommand.ts b/src/command/club/calendar/calendarCommand.ts similarity index 100% rename from src/command/calendarCommand.ts rename to src/command/club/calendar/calendarCommand.ts diff --git a/src/command/calendarCommandHandler.ts b/src/command/club/calendar/calendarCommandHandler.ts similarity index 87% rename from src/command/calendarCommandHandler.ts rename to src/command/club/calendar/calendarCommandHandler.ts index 9592347..5cd89b6 100644 --- a/src/command/calendarCommandHandler.ts +++ b/src/command/club/calendar/calendarCommandHandler.ts @@ -1,13 +1,13 @@ -import { dataSource } from "../data-source"; -import { calendar } from "../entity/calendar"; -import { calendarType } from "../entity/calendarType"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { calendar } from "../../../entity/club/calendar"; +import { calendarType } from "../../../entity/settings/calendarType"; +import InternalException from "../../../exceptions/internalException"; import { CreateCalendarCommand, DeleteCalendarCommand, UpdateCalendarCommand } from "./calendarCommand"; export default abstract class CalendarCommandHandler { /** * @description create calendar - * @param CreateCalendarCommand + * @param {CreateCalendarCommand} createCalendar * @returns {Promise} */ static async create(createCalendar: CreateCalendarCommand): Promise { @@ -39,7 +39,7 @@ export default abstract class CalendarCommandHandler { /** * @description update calendar - * @param UpdateCalendarCommand + * @param {UpdateCalendarCommand} updateCalendar * @returns {Promise} */ static async update(updateCalendar: UpdateCalendarCommand): Promise { @@ -78,7 +78,7 @@ export default abstract class CalendarCommandHandler { /** * @description delete calendar - * @param DeleteCalendarCommand + * @param {DeleteCalendarCommand} deleteCalendar * @returns {Promise} */ static async delete(deleteCalendar: DeleteCalendarCommand): Promise { diff --git a/src/command/communicationCommand.ts b/src/command/club/member/communicationCommand.ts similarity index 100% rename from src/command/communicationCommand.ts rename to src/command/club/member/communicationCommand.ts diff --git a/src/command/communicationCommandHandler.ts b/src/command/club/member/communicationCommandHandler.ts similarity index 87% rename from src/command/communicationCommandHandler.ts rename to src/command/club/member/communicationCommandHandler.ts index 9d18cc9..ad6341c 100644 --- a/src/command/communicationCommandHandler.ts +++ b/src/command/club/member/communicationCommandHandler.ts @@ -1,8 +1,6 @@ -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"; +import { dataSource } from "../../../data-source"; +import { communication } from "../../../entity/club/member/communication"; +import InternalException from "../../../exceptions/internalException"; import { CreateCommunicationCommand, DeleteCommunicationCommand, @@ -12,7 +10,7 @@ import { export default abstract class CommunicationCommandHandler { /** * @description create communication - * @param CreateCommunicationCommand + * @param {CreateCommunicationCommand} createCommunication * @returns {Promise} */ static async create(createCommunication: CreateCommunicationCommand): Promise { @@ -44,7 +42,7 @@ export default abstract class CommunicationCommandHandler { /** * @description update communication - * @param UpdateCommunicationCommand + * @param {UpdateCommunicationCommand} updateCommunication * @returns {Promise} */ static async update(updateCommunication: UpdateCommunicationCommand): Promise { @@ -73,7 +71,7 @@ export default abstract class CommunicationCommandHandler { /** * @description delete communication - * @param DeleteCommunicationCommand + * @param {DeleteCommunicationCommand} deleteCommunication * @returns {Promise} */ static async delete(deleteCommunication: DeleteCommunicationCommand): Promise { diff --git a/src/command/memberAwardCommand.ts b/src/command/club/member/memberAwardCommand.ts similarity index 100% rename from src/command/memberAwardCommand.ts rename to src/command/club/member/memberAwardCommand.ts diff --git a/src/command/memberAwardCommandHandler.ts b/src/command/club/member/memberAwardCommandHandler.ts similarity index 76% rename from src/command/memberAwardCommandHandler.ts rename to src/command/club/member/memberAwardCommandHandler.ts index 775f55d..0a02e01 100644 --- a/src/command/memberAwardCommandHandler.ts +++ b/src/command/club/member/memberAwardCommandHandler.ts @@ -1,14 +1,12 @@ -import { dataSource } from "../data-source"; -import { award } from "../entity/award"; -import { member } from "../entity/member"; -import { memberAwards } from "../entity/memberAwards"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { memberAwards } from "../../../entity/club/member/memberAwards"; +import InternalException from "../../../exceptions/internalException"; import { CreateMemberAwardCommand, DeleteMemberAwardCommand, UpdateMemberAwardCommand } from "./memberAwardCommand"; export default abstract class MemberAwardCommandHandler { /** * @description create memberAward - * @param CreateMemberAwardCommand + * @param {CreateMemberAwardCommand} createMemberAward * @returns {Promise} */ static async create(createMemberAward: CreateMemberAwardCommand): Promise { @@ -34,7 +32,7 @@ export default abstract class MemberAwardCommandHandler { /** * @description update memberAward - * @param UpdateMemberAwardCommand + * @param {UpdateMemberAwardCommand} updateMemberAward * @returns {Promise} */ static async update(updateMemberAward: UpdateMemberAwardCommand): Promise { @@ -58,16 +56,16 @@ export default abstract class MemberAwardCommandHandler { /** * @description delete memberAward - * @param DeleteMemberAwardCommand + * @param {DeleteMemberAwardCommand} deleteMemberAward * @returns {Promise} */ - static async delete(deletMemberAward: DeleteMemberAwardCommand): Promise { + static async delete(deleteMemberAward: DeleteMemberAwardCommand): Promise { return await dataSource .createQueryBuilder() .delete() .from(memberAwards) - .where("id = :id", { id: deletMemberAward.id }) - .andWhere("memberId = :memberId", { memberId: deletMemberAward.memberId }) + .where("id = :id", { id: deleteMemberAward.id }) + .andWhere("memberId = :memberId", { memberId: deleteMemberAward.memberId }) .execute() .then(() => {}) .catch((err) => { diff --git a/src/command/memberCommand.ts b/src/command/club/member/memberCommand.ts similarity index 90% rename from src/command/memberCommand.ts rename to src/command/club/member/memberCommand.ts index a40de21..a05e284 100644 --- a/src/command/memberCommand.ts +++ b/src/command/club/member/memberCommand.ts @@ -1,4 +1,4 @@ -import { Salutation } from "../enums/salutation"; +import { Salutation } from "../../../enums/salutation"; export interface CreateMemberCommand { salutation: Salutation; diff --git a/src/command/memberCommandHandler.ts b/src/command/club/member/memberCommandHandler.ts similarity index 87% rename from src/command/memberCommandHandler.ts rename to src/command/club/member/memberCommandHandler.ts index 767a01f..8d8e65b 100644 --- a/src/command/memberCommandHandler.ts +++ b/src/command/club/member/memberCommandHandler.ts @@ -1,8 +1,7 @@ -import { dataSource } from "../data-source"; -import { communication } from "../entity/communication"; -import { member } from "../entity/member"; -import InternalException from "../exceptions/internalException"; -import CommunicationService from "../service/communicationService"; +import { dataSource } from "../../../data-source"; +import { communication } from "../../../entity/club/member/communication"; +import { member } from "../../../entity/club/member/member"; +import InternalException from "../../../exceptions/internalException"; import { CreateMemberCommand, DeleteMemberCommand, @@ -13,7 +12,7 @@ import { export default abstract class MemberCommandHandler { /** * @description create member - * @param CreateMemberCommand + * @param {CreateMemberCommand} createMember * @returns {Promise} */ static async create(createMember: CreateMemberCommand): Promise { @@ -40,7 +39,7 @@ export default abstract class MemberCommandHandler { /** * @description update member - * @param UpdateMemberCommand + * @param {UpdateMemberCommand} updateMember * @returns {Promise} */ static async update(updateMember: UpdateMemberCommand): Promise { @@ -66,7 +65,7 @@ export default abstract class MemberCommandHandler { /** * @description update member newsletter - * @param UpdateMemberCommand + * @param {UpdateMemberCommand} updateMember * @returns {Promise} */ static async updateNewsletter(updateMember: UpdateMemberNewsletterCommand): Promise { @@ -91,7 +90,7 @@ export default abstract class MemberCommandHandler { /** * @description update member newsletter to unset - * @param memberId string + * @param {number} memberId * @returns {Promise} */ static async unsetNewsletter(memberId: number): Promise { @@ -111,7 +110,7 @@ export default abstract class MemberCommandHandler { /** * @description delete member - * @param DeleteMemberCommand + * @param {DeleteMemberCommand} deleteMember * @returns {Promise} */ static async delete(deleteMember: DeleteMemberCommand): Promise { diff --git a/src/command/memberExecutivePositionCommand.ts b/src/command/club/member/memberExecutivePositionCommand.ts similarity index 100% rename from src/command/memberExecutivePositionCommand.ts rename to src/command/club/member/memberExecutivePositionCommand.ts diff --git a/src/command/memberExecutivePositionCommandHandler.ts b/src/command/club/member/memberExecutivePositionCommandHandler.ts similarity index 76% rename from src/command/memberExecutivePositionCommandHandler.ts rename to src/command/club/member/memberExecutivePositionCommandHandler.ts index 3d36a14..f683541 100644 --- a/src/command/memberExecutivePositionCommandHandler.ts +++ b/src/command/club/member/memberExecutivePositionCommandHandler.ts @@ -1,8 +1,6 @@ -import { dataSource } from "../data-source"; -import { executivePosition } from "../entity/executivePosition"; -import { member } from "../entity/member"; -import { memberExecutivePositions } from "../entity/memberExecutivePositions"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { memberExecutivePositions } from "../../../entity/club/member/memberExecutivePositions"; +import InternalException from "../../../exceptions/internalException"; import { CreateMemberExecutivePositionCommand, DeleteMemberExecutivePositionCommand, @@ -12,7 +10,7 @@ import { export default abstract class MemberExecutivePositionCommandHandler { /** * @description create memberExecutivePosition - * @param CreateMemberExecutivePositionCommand + * @param {CreateMemberExecutivePositionCommand} createMemberExecutivePosition * @returns {Promise} */ static async create(createMemberExecutivePosition: CreateMemberExecutivePositionCommand): Promise { @@ -38,7 +36,7 @@ export default abstract class MemberExecutivePositionCommandHandler { /** * @description update memberExecutivePosition - * @param UpdateMemberExecutivePositionCommand + * @param {UpdateMemberExecutivePositionCommand} updateMemberExecutivePosition * @returns {Promise} */ static async update(updateMemberExecutivePosition: UpdateMemberExecutivePositionCommand): Promise { @@ -62,16 +60,16 @@ export default abstract class MemberExecutivePositionCommandHandler { /** * @description delete memberExecutivePosition - * @param DeleteMemberExecutivePositionCommand + * @param {DeleteMemberExecutivePositionCommand} deleteMemberExecutivePosition * @returns {Promise} */ - static async delete(deletMemberExecutivePosition: DeleteMemberExecutivePositionCommand): Promise { + static async delete(deleteMemberExecutivePosition: DeleteMemberExecutivePositionCommand): Promise { return await dataSource .createQueryBuilder() .delete() .from(memberExecutivePositions) - .where("id = :id", { id: deletMemberExecutivePosition.id }) - .andWhere("memberId = :memberId", { memberId: deletMemberExecutivePosition.memberId }) + .where("id = :id", { id: deleteMemberExecutivePosition.id }) + .andWhere("memberId = :memberId", { memberId: deleteMemberExecutivePosition.memberId }) .execute() .then(() => {}) .catch((err) => { diff --git a/src/command/memberQualificationCommand.ts b/src/command/club/member/memberQualificationCommand.ts similarity index 100% rename from src/command/memberQualificationCommand.ts rename to src/command/club/member/memberQualificationCommand.ts diff --git a/src/command/memberQualificationCommandHandler.ts b/src/command/club/member/memberQualificationCommandHandler.ts similarity index 76% rename from src/command/memberQualificationCommandHandler.ts rename to src/command/club/member/memberQualificationCommandHandler.ts index 7faad96..351cfb6 100644 --- a/src/command/memberQualificationCommandHandler.ts +++ b/src/command/club/member/memberQualificationCommandHandler.ts @@ -1,18 +1,16 @@ -import { dataSource } from "../data-source"; -import { qualification } from "../entity/qualification"; -import { memberQualifications } from "../entity/memberQualifications"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { memberQualifications } from "../../../entity/club/member/memberQualifications"; +import InternalException from "../../../exceptions/internalException"; import { CreateMemberQualificationCommand, DeleteMemberQualificationCommand, UpdateMemberQualificationCommand, } from "./memberQualificationCommand"; -import { member } from "../entity/member"; export default abstract class MemberQualificationCommandHandler { /** * @description create memberQualification - * @param CreateMemberQualificationCommand + * @param {CreateMemberQualificationCommand} createMemberQualification * @returns {Promise} */ static async create(createMemberQualification: CreateMemberQualificationCommand): Promise { @@ -37,7 +35,7 @@ export default abstract class MemberQualificationCommandHandler { /** * @description update memberQualification - * @param UpdateMemberQualificationCommand + * @param {UpdateMemberQualificationCommand} updateMemberQualification * @returns {Promise} */ static async update(updateMemberQualification: UpdateMemberQualificationCommand): Promise { @@ -62,16 +60,16 @@ export default abstract class MemberQualificationCommandHandler { /** * @description delete memberQualification - * @param DeleteMemberQualificationCommand + * @param {DeleteMemberQualificationCommand} deleteMemberQualification * @returns {Promise} */ - static async delete(deletMemberQualification: DeleteMemberQualificationCommand): Promise { + static async delete(deleteMemberQualification: DeleteMemberQualificationCommand): Promise { return await dataSource .createQueryBuilder() .delete() .from(memberQualifications) - .where("id = :id", { id: deletMemberQualification.id }) - .andWhere("memberId = :memberId", { memberId: deletMemberQualification.memberId }) + .where("id = :id", { id: deleteMemberQualification.id }) + .andWhere("memberId = :memberId", { memberId: deleteMemberQualification.memberId }) .execute() .then(() => {}) .catch((err) => { diff --git a/src/command/membershipCommand.ts b/src/command/club/member/membershipCommand.ts similarity index 100% rename from src/command/membershipCommand.ts rename to src/command/club/member/membershipCommand.ts diff --git a/src/command/membershipCommandHandler.ts b/src/command/club/member/membershipCommandHandler.ts similarity index 90% rename from src/command/membershipCommandHandler.ts rename to src/command/club/member/membershipCommandHandler.ts index b52a1dd..602d6d7 100644 --- a/src/command/membershipCommandHandler.ts +++ b/src/command/club/member/membershipCommandHandler.ts @@ -1,8 +1,6 @@ -import { dataSource } from "../data-source"; -import { member } from "../entity/member"; -import { membership } from "../entity/membership"; -import { membershipStatus } from "../entity/membershipStatus"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { membership } from "../../../entity/club/member/membership"; +import InternalException from "../../../exceptions/internalException"; import { CreateMembershipCommand, DeleteMembershipCommand, UpdateMembershipCommand } from "./membershipCommand"; export default abstract class MembershipCommandHandler { @@ -33,7 +31,7 @@ export default abstract class MembershipCommandHandler { .createQueryBuilder() .update(membership) .set({ - end: createMembership.start, + end: new Date(createMembership.start).setDate(new Date(createMembership.start).getDate() - 1), terminationReason: "beendet durch neuen Eintrag.", }) .where("end IS NULL") diff --git a/src/command/newsletterCommand.ts b/src/command/club/newsletter/newsletterCommand.ts similarity index 100% rename from src/command/newsletterCommand.ts rename to src/command/club/newsletter/newsletterCommand.ts diff --git a/src/command/newsletterCommandHandler.ts b/src/command/club/newsletter/newsletterCommandHandler.ts similarity index 84% rename from src/command/newsletterCommandHandler.ts rename to src/command/club/newsletter/newsletterCommandHandler.ts index 6667a74..38c156b 100644 --- a/src/command/newsletterCommandHandler.ts +++ b/src/command/club/newsletter/newsletterCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { newsletter } from "../entity/newsletter"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { newsletter } from "../../../entity/club/newsletter/newsletter"; +import InternalException from "../../../exceptions/internalException"; import { CreateNewsletterCommand, SendNewsletterCommand, SynchronizeNewsletterCommand } from "./newsletterCommand"; export default abstract class NewsletterCommandHandler { /** * @description create newsletter - * @param CreateNewsletterCommand + * @param {CreateNewsletterCommand} createNewsletter * @returns {Promise} */ static async create(createNewsletter: CreateNewsletterCommand): Promise { @@ -28,7 +28,7 @@ export default abstract class NewsletterCommandHandler { /** * @description sync newsletter - * @param SynchronizeNewsletterCommand + * @param {SynchronizeNewsletterCommand} syncNewsletter * @returns {Promise} */ static async sync(syncNewsletter: SynchronizeNewsletterCommand): Promise { @@ -53,7 +53,7 @@ export default abstract class NewsletterCommandHandler { /** * @description send newsletter - * @param SendNewsletterCommand + * @param {SendNewsletterCommand} syncNewsletter * @returns {Promise} */ static async send(syncNewsletter: SendNewsletterCommand): Promise { diff --git a/src/command/newsletterDatesCommand.ts b/src/command/club/newsletter/newsletterDatesCommand.ts similarity index 100% rename from src/command/newsletterDatesCommand.ts rename to src/command/club/newsletter/newsletterDatesCommand.ts diff --git a/src/command/newsletterDatesCommandHandler.ts b/src/command/club/newsletter/newsletterDatesCommandHandler.ts similarity index 91% rename from src/command/newsletterDatesCommandHandler.ts rename to src/command/club/newsletter/newsletterDatesCommandHandler.ts index 99ee1ad..efaea75 100644 --- a/src/command/newsletterDatesCommandHandler.ts +++ b/src/command/club/newsletter/newsletterDatesCommandHandler.ts @@ -1,9 +1,9 @@ import { DeleteResult, EntityManager, InsertResult, UpdateResult } from "typeorm"; -import { dataSource } from "../data-source"; -import InternalException from "../exceptions/internalException"; -import NewsletterDatesService from "../service/newsletterDatesService"; +import { dataSource } from "../../../data-source"; +import InternalException from "../../../exceptions/internalException"; +import NewsletterDatesService from "../../../service/club/newsletter/newsletterDatesService"; import { NewsletterDateCommand, SynchronizeNewsletterDatesCommand } from "./newsletterDatesCommand"; -import { newsletterDates } from "../entity/newsletterDates"; +import { newsletterDates } from "../../../entity/club/newsletter/newsletterDates"; export default abstract class NewsletterDatesCommandHandler { /** diff --git a/src/command/newsletterRecipientsCommand.ts b/src/command/club/newsletter/newsletterRecipientsCommand.ts similarity index 100% rename from src/command/newsletterRecipientsCommand.ts rename to src/command/club/newsletter/newsletterRecipientsCommand.ts diff --git a/src/command/newsletterRecipientsCommandHandler.ts b/src/command/club/newsletter/newsletterRecipientsCommandHandler.ts similarity index 87% rename from src/command/newsletterRecipientsCommandHandler.ts rename to src/command/club/newsletter/newsletterRecipientsCommandHandler.ts index b321c71..262febc 100644 --- a/src/command/newsletterRecipientsCommandHandler.ts +++ b/src/command/club/newsletter/newsletterRecipientsCommandHandler.ts @@ -1,9 +1,9 @@ import { DeleteResult, EntityManager, InsertResult, UpdateResult } from "typeorm"; -import { dataSource } from "../data-source"; -import InternalException from "../exceptions/internalException"; -import NewsletterRecipientsService from "../service/newsletterRecipientsService"; +import { dataSource } from "../../../data-source"; +import InternalException from "../../../exceptions/internalException"; +import NewsletterRecipientsService from "../../../service/club/newsletter/newsletterRecipientsService"; import { SynchronizeNewsletterRecipientsCommand } from "./newsletterRecipientsCommand"; -import { newsletterRecipients } from "../entity/newsletterRecipients"; +import { newsletterRecipients } from "../../../entity/club/newsletter/newsletterRecipients"; export default abstract class NewsletterRecipientsCommandHandler { /** diff --git a/src/command/protocolAgendaCommand.ts b/src/command/club/protocol/protocolAgendaCommand.ts similarity index 100% rename from src/command/protocolAgendaCommand.ts rename to src/command/club/protocol/protocolAgendaCommand.ts diff --git a/src/command/protocolAgendaCommandHandler.ts b/src/command/club/protocol/protocolAgendaCommandHandler.ts similarity index 79% rename from src/command/protocolAgendaCommandHandler.ts rename to src/command/club/protocol/protocolAgendaCommandHandler.ts index 91c7dea..0c74179 100644 --- a/src/command/protocolAgendaCommandHandler.ts +++ b/src/command/club/protocol/protocolAgendaCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { protocolAgenda } from "../entity/protocolAgenda"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { protocolAgenda } from "../../../entity/club/protocol/protocolAgenda"; +import InternalException from "../../../exceptions/internalException"; import { SynchronizeProtocolAgendaCommand } from "./protocolAgendaCommand"; export default abstract class ProtocolAgendaCommandHandler { /** * @description create protocolAgenda - * @param {number} + * @param {number} protocolId * @returns {Promise} */ static async create(protocolId: number): Promise { @@ -30,7 +30,7 @@ export default abstract class ProtocolAgendaCommandHandler { /** * @description sync protocolAgenda - * @param {Array} + * @param {Array} syncProtocolAgenda * @returns {Promise} */ static async sync(syncProtocolAgenda: Array): Promise { diff --git a/src/command/protocolCommand.ts b/src/command/club/protocol/protocolCommand.ts similarity index 100% rename from src/command/protocolCommand.ts rename to src/command/club/protocol/protocolCommand.ts diff --git a/src/command/protocolCommandHandler.ts b/src/command/club/protocol/protocolCommandHandler.ts similarity index 81% rename from src/command/protocolCommandHandler.ts rename to src/command/club/protocol/protocolCommandHandler.ts index f2f293e..95e5017 100644 --- a/src/command/protocolCommandHandler.ts +++ b/src/command/club/protocol/protocolCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { protocol } from "../entity/protocol"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { protocol } from "../../../entity/club/protocol/protocol"; +import InternalException from "../../../exceptions/internalException"; import { CreateProtocolCommand, SynchronizeProtocolCommand } from "./protocolCommand"; export default abstract class ProtocolCommandHandler { /** * @description create protocol - * @param CreateProtocolCommand + * @param {CreateProtocolCommand} createProtocol * @returns {Promise} */ static async create(createProtocol: CreateProtocolCommand): Promise { @@ -29,7 +29,7 @@ export default abstract class ProtocolCommandHandler { /** * @description sync protocol - * @param SynchronizeProtocolCommand + * @param {SynchronizeProtocolCommand} syncProtocol * @returns {Promise} */ static async sync(syncProtocol: SynchronizeProtocolCommand): Promise { diff --git a/src/command/protocolDecisionCommand.ts b/src/command/club/protocol/protocolDecisionCommand.ts similarity index 100% rename from src/command/protocolDecisionCommand.ts rename to src/command/club/protocol/protocolDecisionCommand.ts diff --git a/src/command/protocolDecisionCommandHandler.ts b/src/command/club/protocol/protocolDecisionCommandHandler.ts similarity index 79% rename from src/command/protocolDecisionCommandHandler.ts rename to src/command/club/protocol/protocolDecisionCommandHandler.ts index 750a40e..19aba38 100644 --- a/src/command/protocolDecisionCommandHandler.ts +++ b/src/command/club/protocol/protocolDecisionCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { protocolDecision } from "../entity/protocolDecision"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { protocolDecision } from "../../../entity/club/protocol/protocolDecision"; +import InternalException from "../../../exceptions/internalException"; import { SynchronizeProtocolDecisionCommand } from "./protocolDecisionCommand"; export default abstract class ProtocolDecisionCommandHandler { /** * @description create protocolDecision - * @param {number} + * @param {number} protocolId * @returns {Promise} */ static async create(protocolId: number): Promise { @@ -29,7 +29,7 @@ export default abstract class ProtocolDecisionCommandHandler { } /** * @description sync protocolDecision - * @param {Array} + * @param {Array} syncProtocolDecisions * @returns {Promise} */ static async sync(syncProtocolDecisions: Array): Promise { diff --git a/src/command/club/protocol/protocolPresenceCommand.ts b/src/command/club/protocol/protocolPresenceCommand.ts new file mode 100644 index 0000000..76c004a --- /dev/null +++ b/src/command/club/protocol/protocolPresenceCommand.ts @@ -0,0 +1,9 @@ +export interface SynchronizeProtocolPresenceCommand { + members: Array; + protocolId: number; +} + +export interface ProtocolPresenceCommand { + memberId: number; + absent: boolean; +} diff --git a/src/command/club/protocol/protocolPresenceCommandHandler.ts b/src/command/club/protocol/protocolPresenceCommandHandler.ts new file mode 100644 index 0000000..abdb82b --- /dev/null +++ b/src/command/club/protocol/protocolPresenceCommandHandler.ts @@ -0,0 +1,96 @@ +import { DeleteResult, EntityManager, InsertResult, UpdateResult } from "typeorm"; +import { dataSource } from "../../../data-source"; +import { protocolPresence } from "../../../entity/club/protocol/protocolPresence"; +import InternalException from "../../../exceptions/internalException"; +import ProtocolPresenceService from "../../../service/club/protocol/protocolPrecenseService"; +import { ProtocolPresenceCommand, SynchronizeProtocolPresenceCommand } from "./protocolPresenceCommand"; + +export default abstract class ProtocolPresenceCommandHandler { + /** + * @description sync protocolPresence + * @param {SynchronizeProtocolPresenceCommand} syncProtocolPresences + * @returns {Promise} + */ + static async sync(syncProtocolPresences: SynchronizeProtocolPresenceCommand): Promise { + let currentPresence = await ProtocolPresenceService.getAll(syncProtocolPresences.protocolId); + + return await dataSource.manager + .transaction(async (manager) => { + let newMembers = syncProtocolPresences.members.filter( + (r) => !currentPresence.some((cp) => cp.memberId == r.memberId) + ); + let removeMembers = currentPresence.filter( + (r) => !syncProtocolPresences.members.some((cp) => cp.memberId == r.memberId) + ); + let keptMembers = syncProtocolPresences.members.filter( + (m) => + currentPresence.some((cd) => cd.memberId == m.memberId) && + !removeMembers.some((cd) => cd.memberId == m.memberId) + ); + + if (newMembers.length != 0) { + await this.syncPresenceAdd(manager, syncProtocolPresences.protocolId, newMembers); + } + + if (removeMembers.length != 0) { + await this.syncPresenceRemove(manager, syncProtocolPresences.protocolId, removeMembers); + } + + for (const member of keptMembers) { + await this.syncPresenceUpdate(manager, syncProtocolPresences.protocolId, member); + } + }) + .then(() => {}) + .catch((err) => { + throw new InternalException("Failed saving protocol presence", err); + }); + } + + private static async syncPresenceAdd( + manager: EntityManager, + protocolId: number, + memberIds: Array + ): Promise { + return await manager + .createQueryBuilder() + .insert() + .into(protocolPresence) + .values( + memberIds.map((m) => ({ + ...m, + protocolId, + })) + ) + .execute(); + } + + private static async syncPresenceUpdate( + manager: EntityManager, + protocolId: number, + member: ProtocolPresenceCommand + ): Promise { + return await manager + .createQueryBuilder() + .update(protocolPresence) + .set({ + absent: member.absent, + }) + .where("memberId = :memberId", { memberId: member.memberId }) + .andWhere("protocolId = :protocolId", { protocolId }) + .execute(); + } + + private static async syncPresenceRemove( + manager: EntityManager, + protocolId: number, + members: Array + ): Promise { + return await manager + .createQueryBuilder() + .delete() + .from(protocolPresence) + .where("memberId IN (:...ids)", { ids: members.map((m) => m.memberId) }) + .andWhere("protocolId = :protocolId", { protocolId }) + .execute(); + } +} diff --git a/src/command/protocolPrintoutCommand.ts b/src/command/club/protocol/protocolPrintoutCommand.ts similarity index 100% rename from src/command/protocolPrintoutCommand.ts rename to src/command/club/protocol/protocolPrintoutCommand.ts diff --git a/src/command/protocolPrintoutCommandHandler.ts b/src/command/club/protocol/protocolPrintoutCommandHandler.ts similarity index 75% rename from src/command/protocolPrintoutCommandHandler.ts rename to src/command/club/protocol/protocolPrintoutCommandHandler.ts index c1cdcbe..9ceabea 100644 --- a/src/command/protocolPrintoutCommandHandler.ts +++ b/src/command/club/protocol/protocolPrintoutCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { protocolPrintout } from "../entity/protocolPrintout"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { protocolPrintout } from "../../../entity/club/protocol/protocolPrintout"; +import InternalException from "../../../exceptions/internalException"; import { CreateProtocolPrintoutCommand } from "./protocolPrintoutCommand"; export default abstract class ProtocolPrintoutCommandHandler { /** * @description create protocolPrintout - * @param {number} + * @param {CreateProtocolPrintoutCommand} printout * @returns {Promise} */ static async create(printout: CreateProtocolPrintoutCommand): Promise { diff --git a/src/command/protocolVotingCommand.ts b/src/command/club/protocol/protocolVotingCommand.ts similarity index 100% rename from src/command/protocolVotingCommand.ts rename to src/command/club/protocol/protocolVotingCommand.ts diff --git a/src/command/protocolVotingCommandHandler.ts b/src/command/club/protocol/protocolVotingCommandHandler.ts similarity index 79% rename from src/command/protocolVotingCommandHandler.ts rename to src/command/club/protocol/protocolVotingCommandHandler.ts index bbc9660..6b8834d 100644 --- a/src/command/protocolVotingCommandHandler.ts +++ b/src/command/club/protocol/protocolVotingCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { protocolVoting } from "../entity/protocolVoting"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { protocolVoting } from "../../../entity/club/protocol/protocolVoting"; +import InternalException from "../../../exceptions/internalException"; import { SynchronizeProtocolVotingCommand } from "./protocolVotingCommand"; export default abstract class ProtocolVotingCommandHandler { /** * @description create protocolVoting - * @param {number} + * @param {number} protocolId * @returns {Promise} */ static async create(protocolId: number): Promise { @@ -29,7 +29,7 @@ export default abstract class ProtocolVotingCommandHandler { } /** * @description sync protocolVoting - * @param {Array} + * @param {Array} syncProtocolVotings * @returns {Promise} */ static async sync(syncProtocolVotings: Array): Promise { diff --git a/src/command/protocolPresenceCommand.ts b/src/command/protocolPresenceCommand.ts deleted file mode 100644 index b39878b..0000000 --- a/src/command/protocolPresenceCommand.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface SynchronizeProtocolPresenceCommand { - memberIds: Array; - protocolId: number; -} diff --git a/src/command/protocolPresenceCommandHandler.ts b/src/command/protocolPresenceCommandHandler.ts deleted file mode 100644 index b773cc6..0000000 --- a/src/command/protocolPresenceCommandHandler.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { DeleteResult, EntityManager, InsertResult } from "typeorm"; -import { dataSource } from "../data-source"; -import { protocolPresence } from "../entity/protocolPresence"; -import InternalException from "../exceptions/internalException"; -import ProtocolPresenceService from "../service/protocolPrecenseService"; -import { SynchronizeProtocolPresenceCommand } from "./protocolPresenceCommand"; - -export default abstract class ProtocolPresenceCommandHandler { - /** - * @description sync protocolPresence - * @param {SynchronizeProtocolPresenceCommand} - * @returns {Promise} - */ - static async sync(syncProtocolPresences: SynchronizeProtocolPresenceCommand): Promise { - let currentPresence = (await ProtocolPresenceService.getAll(syncProtocolPresences.protocolId)).map( - (r) => r.memberId - ); - - return await dataSource.manager - .transaction(async (manager) => { - let newMembers = syncProtocolPresences.memberIds.filter((r) => !currentPresence.includes(r)); - let removeMembers = currentPresence.filter((r) => !syncProtocolPresences.memberIds.includes(r)); - - if (newMembers.length != 0) { - await this.syncPresenceAdd(manager, syncProtocolPresences.protocolId, newMembers); - } - - if (removeMembers.length != 0) { - await this.syncPresenceRemove(manager, syncProtocolPresences.protocolId, removeMembers); - } - }) - .then(() => {}) - .catch((err) => { - throw new InternalException("Failed saving protocol presence", err); - }); - } - - private static async syncPresenceAdd( - manager: EntityManager, - protocolId: number, - memberIds: Array - ): Promise { - return await manager - .createQueryBuilder() - .insert() - .into(protocolPresence) - .values( - memberIds.map((m) => ({ - protocolId, - memberId: m, - })) - ) - .execute(); - } - - private static async syncPresenceRemove( - manager: EntityManager, - protocolId: number, - memberIds: Array - ): Promise { - return await manager - .createQueryBuilder() - .delete() - .from(protocolPresence) - .where("memberId IN (:...ids)", { ids: memberIds }) - .andWhere("protocolId = :protocolId", { protocolId }) - .execute(); - } -} diff --git a/src/command/refreshCommandHandler.ts b/src/command/refreshCommandHandler.ts index ae6dc0b..86841ad 100644 --- a/src/command/refreshCommandHandler.ts +++ b/src/command/refreshCommandHandler.ts @@ -4,7 +4,7 @@ import { REFRESH_EXPIRATION } from "../env.defaults"; import InternalException from "../exceptions/internalException"; import { JWTHelper } from "../helpers/jwtHelper"; import { StringHelper } from "../helpers/stringHelper"; -import UserService from "../service/userService"; +import UserService from "../service/user/userService"; import { JWTRefresh } from "../type/jwtTypes"; import { CreateRefreshCommand, DeleteRefreshCommand } from "./refreshCommand"; import ms from "ms"; @@ -12,7 +12,7 @@ import ms from "ms"; export default abstract class RefreshCommandHandler { /** * @description create and save refreshToken to user - * @param CreateRefreshCommand + * @param {CreateRefreshCommand} createRefresh * @returns {Promise} */ static async create(createRefresh: CreateRefreshCommand): Promise { @@ -42,7 +42,7 @@ export default abstract class RefreshCommandHandler { /** * @description delete refresh by user and token - * @param DeleteRefreshCommand + * @param {DeleteRefreshCommand} deleteRefresh * @returns {Promise} */ static async deleteByToken(deleteRefresh: DeleteRefreshCommand): Promise { diff --git a/src/command/resetCommandHandler.ts b/src/command/resetCommandHandler.ts index 6ef1d00..9c75aba 100644 --- a/src/command/resetCommandHandler.ts +++ b/src/command/resetCommandHandler.ts @@ -7,7 +7,7 @@ import { CreateResetCommand, DeleteResetCommand } from "./resetCommand"; export default abstract class ResetCommandHandler { /** * @description create user - * @param CreateResetCommand + * @param {CreateResetCommand} createReset * @returns {Promise} */ static async create(createReset: CreateResetCommand): Promise { @@ -35,7 +35,7 @@ export default abstract class ResetCommandHandler { /** * @description delete reset by mail and token - * @param DeleteRefreshCommand + * @param {DeleteRefreshCommand} deleteReset * @returns {Promise} */ static async deleteByTokenAndMail(deleteReset: DeleteResetCommand): Promise { diff --git a/src/command/awardCommand.ts b/src/command/settings/award/awardCommand.ts similarity index 100% rename from src/command/awardCommand.ts rename to src/command/settings/award/awardCommand.ts diff --git a/src/command/awardCommandHandler.ts b/src/command/settings/award/awardCommandHandler.ts similarity index 76% rename from src/command/awardCommandHandler.ts rename to src/command/settings/award/awardCommandHandler.ts index b862e7b..af0000f 100644 --- a/src/command/awardCommandHandler.ts +++ b/src/command/settings/award/awardCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { award } from "../entity/award"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { award } from "../../../entity/settings/award"; +import InternalException from "../../../exceptions/internalException"; import { CreateAwardCommand, DeleteAwardCommand, UpdateAwardCommand } from "./awardCommand"; export default abstract class AwardCommandHandler { /** * @description create award - * @param CreateAwardCommand + * @param {CreateAwardCommand} createAward * @returns {Promise} */ static async create(createAward: CreateAwardCommand): Promise { @@ -28,7 +28,7 @@ export default abstract class AwardCommandHandler { /** * @description update award - * @param UpdateAwardCommand + * @param {UpdateAwardCommand} updateAward * @returns {Promise} */ static async update(updateAward: UpdateAwardCommand): Promise { @@ -48,15 +48,15 @@ export default abstract class AwardCommandHandler { /** * @description delete award - * @param DeleteAwardCommand + * @param {DeleteAwardCommand} deleteAward * @returns {Promise} */ - static async delete(deletAward: DeleteAwardCommand): Promise { + static async delete(deleteAward: DeleteAwardCommand): Promise { return await dataSource .createQueryBuilder() .delete() .from(award) - .where("id = :id", { id: deletAward.id }) + .where("id = :id", { id: deleteAward.id }) .execute() .then(() => {}) .catch((err) => { diff --git a/src/command/calendarTypeCommand.ts b/src/command/settings/calendarType/calendarTypeCommand.ts similarity index 100% rename from src/command/calendarTypeCommand.ts rename to src/command/settings/calendarType/calendarTypeCommand.ts diff --git a/src/command/calendarTypeCommandHandler.ts b/src/command/settings/calendarType/calendarTypeCommandHandler.ts similarity index 84% rename from src/command/calendarTypeCommandHandler.ts rename to src/command/settings/calendarType/calendarTypeCommandHandler.ts index 223288c..bc20d6a 100644 --- a/src/command/calendarTypeCommandHandler.ts +++ b/src/command/settings/calendarType/calendarTypeCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { calendarType } from "../entity/calendarType"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { calendarType } from "../../../entity/settings/calendarType"; +import InternalException from "../../../exceptions/internalException"; import { CreateCalendarTypeCommand, DeleteCalendarTypeCommand, UpdateCalendarTypeCommand } from "./calendarTypeCommand"; export default abstract class CalendarTypeCommandHandler { /** * @description create calendarType - * @param CreateCalendarTypeCommand + * @param {CreateCalendarTypeCommand} createCalendarType * @returns {Promise} */ static async create(createCalendarType: CreateCalendarTypeCommand): Promise { @@ -31,7 +31,7 @@ export default abstract class CalendarTypeCommandHandler { /** * @description update calendarType - * @param UpdateCalendarTypeCommand + * @param {UpdateCalendarTypeCommand} updateCalendarType * @returns {Promise} */ static async update(updateCalendarType: UpdateCalendarTypeCommand): Promise { @@ -54,7 +54,7 @@ export default abstract class CalendarTypeCommandHandler { /** * @description delete calendarType - * @param DeleteCalendarTypeCommand + * @param {DeleteCalendarTypeCommand} deleteCalendarType * @returns {Promise} */ static async delete(deleteCalendarType: DeleteCalendarTypeCommand): Promise { diff --git a/src/command/communicationTypeCommand.ts b/src/command/settings/communicationType/communicationTypeCommand.ts similarity index 82% rename from src/command/communicationTypeCommand.ts rename to src/command/settings/communicationType/communicationTypeCommand.ts index fdc686e..8451cc9 100644 --- a/src/command/communicationTypeCommand.ts +++ b/src/command/settings/communicationType/communicationTypeCommand.ts @@ -1,4 +1,4 @@ -import { CommunicationFieldType } from "../type/fieldTypes"; +import { CommunicationFieldType } from "../../../type/fieldTypes"; export interface CreateCommunicationTypeCommand { type: string; diff --git a/src/command/communicationTypeCommandHandler.ts b/src/command/settings/communicationType/communicationTypeCommandHandler.ts similarity index 76% rename from src/command/communicationTypeCommandHandler.ts rename to src/command/settings/communicationType/communicationTypeCommandHandler.ts index 2b4a1be..04c7f10 100644 --- a/src/command/communicationTypeCommandHandler.ts +++ b/src/command/settings/communicationType/communicationTypeCommandHandler.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { communicationType } from "../entity/communicationType"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { communicationType } from "../../../entity/settings/communicationType"; +import InternalException from "../../../exceptions/internalException"; import { CreateCommunicationTypeCommand, DeleteCommunicationTypeCommand, @@ -10,7 +10,7 @@ import { export default abstract class CommunicationTypeCommandHandler { /** * @description create communicationType - * @param CreateCommunicationTypeCommand + * @param {CreateCommunicationTypeCommand} createCommunicationType * @returns {Promise} */ static async create(createCommunicationType: CreateCommunicationTypeCommand): Promise { @@ -33,7 +33,7 @@ export default abstract class CommunicationTypeCommandHandler { /** * @description update communicationType - * @param UpdateCommunicationTypeCommand + * @param {UpdateCommunicationTypeCommand} updateCommunicationType * @returns {Promise} */ static async update(updateCommunicationType: UpdateCommunicationTypeCommand): Promise { @@ -54,15 +54,15 @@ export default abstract class CommunicationTypeCommandHandler { /** * @description delete communicationType - * @param DeleteCommunicationTypeCommand + * @param {DeleteCommunicationTypeCommand} deleteCommunicationType * @returns {Promise} */ - static async delete(deletCommunicationType: DeleteCommunicationTypeCommand): Promise { + static async delete(deleteCommunicationType: DeleteCommunicationTypeCommand): Promise { return await dataSource .createQueryBuilder() .delete() .from(communicationType) - .where("id = :id", { id: deletCommunicationType.id }) + .where("id = :id", { id: deleteCommunicationType.id }) .execute() .then(() => {}) .catch((err) => { diff --git a/src/command/executivePositionCommand.ts b/src/command/settings/executivePosition/executivePositionCommand.ts similarity index 100% rename from src/command/executivePositionCommand.ts rename to src/command/settings/executivePosition/executivePositionCommand.ts diff --git a/src/command/executivePositionCommandHandler.ts b/src/command/settings/executivePosition/executivePositionCommandHandler.ts similarity index 74% rename from src/command/executivePositionCommandHandler.ts rename to src/command/settings/executivePosition/executivePositionCommandHandler.ts index e607dd7..d1be38d 100644 --- a/src/command/executivePositionCommandHandler.ts +++ b/src/command/settings/executivePosition/executivePositionCommandHandler.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { executivePosition } from "../entity/executivePosition"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { executivePosition } from "../../../entity/settings/executivePosition"; +import InternalException from "../../../exceptions/internalException"; import { CreateExecutivePositionCommand, DeleteExecutivePositionCommand, @@ -10,7 +10,7 @@ import { export default abstract class ExecutivePositionCommandHandler { /** * @description create executivePosition - * @param CreateExecutivePositionCommand + * @param {CreateExecutivePositionCommand} createExecutivePosition * @returns {Promise} */ static async create(createExecutivePosition: CreateExecutivePositionCommand): Promise { @@ -32,7 +32,7 @@ export default abstract class ExecutivePositionCommandHandler { /** * @description update executivePosition - * @param UpdateExecutivePositionCommand + * @param {UpdateExecutivePositionCommand} updateExecutivePosition * @returns {Promise} */ static async update(updateExecutivePosition: UpdateExecutivePositionCommand): Promise { @@ -52,15 +52,15 @@ export default abstract class ExecutivePositionCommandHandler { /** * @description delete executivePosition - * @param DeleteExecutivePositionCommand + * @param {DeleteExecutivePositionCommand} deleteExecutivePosition * @returns {Promise} */ - static async delete(deletExecutivePosition: DeleteExecutivePositionCommand): Promise { + static async delete(deleteExecutivePosition: DeleteExecutivePositionCommand): Promise { return await dataSource .createQueryBuilder() .delete() .from(executivePosition) - .where("id = :id", { id: deletExecutivePosition.id }) + .where("id = :id", { id: deleteExecutivePosition.id }) .execute() .then(() => {}) .catch((err) => { diff --git a/src/command/membershipStatusCommand.ts b/src/command/settings/membershipStatus/membershipStatusCommand.ts similarity index 100% rename from src/command/membershipStatusCommand.ts rename to src/command/settings/membershipStatus/membershipStatusCommand.ts diff --git a/src/command/membershipStatusCommandHandler.ts b/src/command/settings/membershipStatus/membershipStatusCommandHandler.ts similarity index 75% rename from src/command/membershipStatusCommandHandler.ts rename to src/command/settings/membershipStatus/membershipStatusCommandHandler.ts index b72641e..bc9f30f 100644 --- a/src/command/membershipStatusCommandHandler.ts +++ b/src/command/settings/membershipStatus/membershipStatusCommandHandler.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { membershipStatus } from "../entity/membershipStatus"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { membershipStatus } from "../../../entity/settings/membershipStatus"; +import InternalException from "../../../exceptions/internalException"; import { CreateMembershipStatusCommand, DeleteMembershipStatusCommand, @@ -10,7 +10,7 @@ import { export default abstract class MembershipStatusCommandHandler { /** * @description create membershipStatus - * @param CreateMembershipStatusCommand + * @param {CreateMembershipStatusCommand} createMembershipStatus * @returns {Promise} */ static async create(createMembershipStatus: CreateMembershipStatusCommand): Promise { @@ -32,7 +32,7 @@ export default abstract class MembershipStatusCommandHandler { /** * @description update membershipStatus - * @param UpdateMembershipStatusCommand + * @param {UpdateMembershipStatusCommand} updateMembershipStatus * @returns {Promise} */ static async update(updateMembershipStatus: UpdateMembershipStatusCommand): Promise { @@ -52,15 +52,15 @@ export default abstract class MembershipStatusCommandHandler { /** * @description delete membershipStatus - * @param DeleteMembershipStatusCommand + * @param {DeleteMembershipStatusCommand} deleteMembershipStatus * @returns {Promise} */ - static async delete(deletMembershipStatus: DeleteMembershipStatusCommand): Promise { + static async delete(deleteMembershipStatus: DeleteMembershipStatusCommand): Promise { return await dataSource .createQueryBuilder() .delete() .from(membershipStatus) - .where("id = :id", { id: deletMembershipStatus.id }) + .where("id = :id", { id: deleteMembershipStatus.id }) .execute() .then(() => {}) .catch((err) => { diff --git a/src/command/newsletterConfigCommand.ts b/src/command/settings/newsletterConfig/newsletterConfigCommand.ts similarity index 69% rename from src/command/newsletterConfigCommand.ts rename to src/command/settings/newsletterConfig/newsletterConfigCommand.ts index 011bc11..f07de54 100644 --- a/src/command/newsletterConfigCommand.ts +++ b/src/command/settings/newsletterConfig/newsletterConfigCommand.ts @@ -1,4 +1,4 @@ -import { NewsletterConfigType } from "../enums/newsletterConfigType"; +import { NewsletterConfigType } from "../../../enums/newsletterConfigType"; export interface SetNewsletterConfigCommand { comTypeId: number; diff --git a/src/command/newsletterConfigCommandHandler.ts b/src/command/settings/newsletterConfig/newsletterConfigCommandHandler.ts similarity index 80% rename from src/command/newsletterConfigCommandHandler.ts rename to src/command/settings/newsletterConfig/newsletterConfigCommandHandler.ts index 6f6b948..56b41bd 100644 --- a/src/command/newsletterConfigCommandHandler.ts +++ b/src/command/settings/newsletterConfig/newsletterConfigCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { newsletterConfig } from "../entity/newsletterConfig"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { newsletterConfig } from "../../../entity/settings/newsletterConfig"; +import InternalException from "../../../exceptions/internalException"; import { DeleteNewsletterConfigCommand, SetNewsletterConfigCommand } from "./newsletterConfigCommand"; export default abstract class NewsletterConfigCommandHandler { /** * @description set newsletterConfig - * @param SetNewsletterConfigCommand + * @param {SetNewsletterConfigCommand} setNewsletterConfig * @returns {Promise} */ static async set(setNewsletterConfig: SetNewsletterConfigCommand): Promise { @@ -29,7 +29,7 @@ export default abstract class NewsletterConfigCommandHandler { } /** * @description delete newsletterConfig - * @param number + * @param {DeleteNewsletterConfigCommand} deleteNewsletterConfig * @returns {Promise} */ static async delete(deleteNewsletterConfig: DeleteNewsletterConfigCommand): Promise { diff --git a/src/command/qualificationCommand.ts b/src/command/settings/qualification/qualificationCommand.ts similarity index 100% rename from src/command/qualificationCommand.ts rename to src/command/settings/qualification/qualificationCommand.ts diff --git a/src/command/qualificationCommandHandler.ts b/src/command/settings/qualification/qualificationCommandHandler.ts similarity index 76% rename from src/command/qualificationCommandHandler.ts rename to src/command/settings/qualification/qualificationCommandHandler.ts index 67da2f9..0abd401 100644 --- a/src/command/qualificationCommandHandler.ts +++ b/src/command/settings/qualification/qualificationCommandHandler.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { qualification } from "../entity/qualification"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { qualification } from "../../../entity/settings/qualification"; +import InternalException from "../../../exceptions/internalException"; import { CreateQualificationCommand, DeleteQualificationCommand, @@ -10,7 +10,7 @@ import { export default abstract class QualificationCommandHandler { /** * @description create qualification - * @param CreateQualificationCommand + * @param {CreateQualificationCommand} createQualification * @returns {Promise} */ static async create(createQualification: CreateQualificationCommand): Promise { @@ -33,7 +33,7 @@ export default abstract class QualificationCommandHandler { /** * @description update qualification - * @param UpdateQualificationCommand + * @param {UpdateQualificationCommand} updateQualification * @returns {Promise} */ static async update(updateQualification: UpdateQualificationCommand): Promise { @@ -54,15 +54,15 @@ export default abstract class QualificationCommandHandler { /** * @description delete qualification - * @param DeleteQualificationCommand + * @param {DeleteQualificationCommand} deleteQualification * @returns {Promise} */ - static async delete(deletQualification: DeleteQualificationCommand): Promise { + static async delete(deleteQualification: DeleteQualificationCommand): Promise { return await dataSource .createQueryBuilder() .delete() .from(qualification) - .where("id = :id", { id: deletQualification.id }) + .where("id = :id", { id: deleteQualification.id }) .execute() .then(() => {}) .catch((err) => { diff --git a/src/command/queryStoreCommand.ts b/src/command/settings/queryStore/queryStoreCommand.ts similarity index 79% rename from src/command/queryStoreCommand.ts rename to src/command/settings/queryStore/queryStoreCommand.ts index 7043159..fee7ffc 100644 --- a/src/command/queryStoreCommand.ts +++ b/src/command/settings/queryStore/queryStoreCommand.ts @@ -1,4 +1,4 @@ -import { DynamicQueryStructure } from "../type/dynamicQueries"; +import { DynamicQueryStructure } from "../../../type/dynamicQueries"; export interface CreateQueryStoreCommand { title: string; diff --git a/src/command/queryStoreCommandHandler.ts b/src/command/settings/queryStore/queryStoreCommandHandler.ts similarity index 78% rename from src/command/queryStoreCommandHandler.ts rename to src/command/settings/queryStore/queryStoreCommandHandler.ts index 7eeb80c..3776b5e 100644 --- a/src/command/queryStoreCommandHandler.ts +++ b/src/command/settings/queryStore/queryStoreCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { query } from "../entity/query"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { query } from "../../../entity/settings/query"; +import InternalException from "../../../exceptions/internalException"; import { CreateQueryStoreCommand, DeleteQueryStoreCommand, UpdateQueryStoreCommand } from "./queryStoreCommand"; export default abstract class QueryStoreCommandHandler { /** * @description create queryStore - * @param CreateQueryStoreCommand + * @param {CreateQueryStoreCommand} createQueryStore * @returns {Promise} */ static async create(createQueryStore: CreateQueryStoreCommand): Promise { @@ -30,7 +30,7 @@ export default abstract class QueryStoreCommandHandler { /** * @description update queryStore - * @param UpdateQueryStoreCommand + * @param {UpdateQueryStoreCommand} updateQueryStore * @returns {Promise} */ static async update(updateQueryStore: UpdateQueryStoreCommand): Promise { @@ -51,15 +51,15 @@ export default abstract class QueryStoreCommandHandler { /** * @description delete queryStore - * @param DeleteQueryStoreCommand + * @param {DeleteQueryStoreCommand} deleteQueryStore * @returns {Promise} */ - static async delete(deletQueryStore: DeleteQueryStoreCommand): Promise { + static async delete(deleteQueryStore: DeleteQueryStoreCommand): Promise { return await dataSource .createQueryBuilder() .delete() .from(query) - .where("id = :id", { id: deletQueryStore.id }) + .where("id = :id", { id: deleteQueryStore.id }) .execute() .then(() => {}) .catch((err) => { diff --git a/src/command/templateCommand.ts b/src/command/settings/template/templateCommand.ts similarity index 100% rename from src/command/templateCommand.ts rename to src/command/settings/template/templateCommand.ts diff --git a/src/command/templateCommandHandler.ts b/src/command/settings/template/templateCommandHandler.ts similarity index 78% rename from src/command/templateCommandHandler.ts rename to src/command/settings/template/templateCommandHandler.ts index 1f9b4ce..54ea6f7 100644 --- a/src/command/templateCommandHandler.ts +++ b/src/command/settings/template/templateCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { template } from "../entity/template"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { template } from "../../../entity/settings/template"; +import InternalException from "../../../exceptions/internalException"; import { CreateTemplateCommand, DeleteTemplateCommand, UpdateTemplateCommand } from "./templateCommand"; export default abstract class TemplateCommandHandler { /** * @description create template - * @param CreateTemplateCommand + * @param {CreateTemplateCommand} createTemplate * @returns {Promise} */ static async create(createTemplate: CreateTemplateCommand): Promise { @@ -29,7 +29,7 @@ export default abstract class TemplateCommandHandler { /** * @description update template - * @param UpdateTemplateCommand + * @param {UpdateTemplateCommand} updateTemplate * @returns {Promise} */ static async update(updateTemplate: UpdateTemplateCommand): Promise { @@ -52,15 +52,15 @@ export default abstract class TemplateCommandHandler { /** * @description delete template - * @param DeleteTemplateCommand + * @param {DeleteTemplateCommand} deleteTemplate * @returns {Promise} */ - static async delete(deletTemplate: DeleteTemplateCommand): Promise { + static async delete(deleteTemplate: DeleteTemplateCommand): Promise { return await dataSource .createQueryBuilder() .delete() .from(template) - .where("id = :id", { id: deletTemplate.id }) + .where("id = :id", { id: deleteTemplate.id }) .execute() .then(() => {}) .catch((err) => { diff --git a/src/command/templateUsageCommand.ts b/src/command/settings/templateUsage/templateUsageCommand.ts similarity index 100% rename from src/command/templateUsageCommand.ts rename to src/command/settings/templateUsage/templateUsageCommand.ts diff --git a/src/command/templateUsageCommandHandler.ts b/src/command/settings/templateUsage/templateUsageCommandHandler.ts similarity index 77% rename from src/command/templateUsageCommandHandler.ts rename to src/command/settings/templateUsage/templateUsageCommandHandler.ts index c9eecce..06c46c9 100644 --- a/src/command/templateUsageCommandHandler.ts +++ b/src/command/settings/templateUsage/templateUsageCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { templateUsage } from "../entity/templateUsage"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { templateUsage } from "../../../entity/settings/templateUsage"; +import InternalException from "../../../exceptions/internalException"; import { UpdateTemplateUsageCommand } from "./templateUsageCommand"; export default abstract class TemplateUsageCommandHandler { /** * @description update templateUsage - * @param UpdateTemplateUsageCommand + * @param {UpdateTemplateUsageCommand} updateTemplateUsage * @returns {Promise} */ static async update(updateTemplateUsage: UpdateTemplateUsageCommand): Promise { diff --git a/src/command/roleCommand.ts b/src/command/user/role/roleCommand.ts similarity index 100% rename from src/command/roleCommand.ts rename to src/command/user/role/roleCommand.ts diff --git a/src/command/roleCommandHandler.ts b/src/command/user/role/roleCommandHandler.ts similarity index 83% rename from src/command/roleCommandHandler.ts rename to src/command/user/role/roleCommandHandler.ts index e967fb3..739d8b9 100644 --- a/src/command/roleCommandHandler.ts +++ b/src/command/user/role/roleCommandHandler.ts @@ -1,12 +1,12 @@ -import { dataSource } from "../data-source"; -import { role } from "../entity/role"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { role } from "../../../entity/user/role"; +import InternalException from "../../../exceptions/internalException"; import { CreateRoleCommand, DeleteRoleCommand, UpdateRoleCommand } from "./roleCommand"; export default abstract class RoleCommandHandler { /** * @description create role - * @param CreateRoleCommand + * @param {CreateRoleCommand} createRole * @returns {Promise} */ static async create(createRole: CreateRoleCommand): Promise { @@ -28,7 +28,7 @@ export default abstract class RoleCommandHandler { /** * @description update role - * @param UpdateRoleCommand + * @param {UpdateRoleCommand} updateRole * @returns {Promise} */ static async update(updateRole: UpdateRoleCommand): Promise { @@ -48,7 +48,7 @@ export default abstract class RoleCommandHandler { /** * @description delete role - * @param DeleteRoleCommand + * @param {DeleteRoleCommand} deleteRole * @returns {Promise} */ static async delete(deleteRole: DeleteRoleCommand): Promise { diff --git a/src/command/rolePermissionCommand.ts b/src/command/user/role/rolePermissionCommand.ts similarity index 82% rename from src/command/rolePermissionCommand.ts rename to src/command/user/role/rolePermissionCommand.ts index dae6ea2..3d4021c 100644 --- a/src/command/rolePermissionCommand.ts +++ b/src/command/user/role/rolePermissionCommand.ts @@ -1,4 +1,4 @@ -import { PermissionString } from "../type/permissionTypes"; +import { PermissionString } from "../../../type/permissionTypes"; export interface CreateRolePermissionCommand { permission: PermissionString; diff --git a/src/command/rolePermissionCommandHandler.ts b/src/command/user/role/rolePermissionCommandHandler.ts similarity index 83% rename from src/command/rolePermissionCommandHandler.ts rename to src/command/user/role/rolePermissionCommandHandler.ts index e1d5e2c..a9a0b1f 100644 --- a/src/command/rolePermissionCommandHandler.ts +++ b/src/command/user/role/rolePermissionCommandHandler.ts @@ -1,22 +1,21 @@ import { DeleteResult, EntityManager, InsertResult } from "typeorm"; -import { dataSource } from "../data-source"; -import { rolePermission } from "../entity/role_permission"; -import InternalException from "../exceptions/internalException"; -import RoleService from "../service/roleService"; +import { dataSource } from "../../../data-source"; +import { rolePermission } from "../../../entity/user/role_permission"; +import InternalException from "../../../exceptions/internalException"; +import RoleService from "../../../service/user/roleService"; import { CreateRolePermissionCommand, DeleteRolePermissionCommand, UpdateRolePermissionsCommand, } from "./rolePermissionCommand"; -import PermissionHelper from "../helpers/permissionHelper"; -import RolePermissionService from "../service/rolePermissionService"; -import { role } from "../entity/role"; -import { PermissionString } from "../type/permissionTypes"; +import PermissionHelper from "../../../helpers/permissionHelper"; +import RolePermissionService from "../../../service/user/rolePermissionService"; +import { PermissionString } from "../../../type/permissionTypes"; export default abstract class RolePermissionCommandHandler { /** * @description update role permissions - * @param UpdateRolePermissionsCommand + * @param {UpdateRolePermissionsCommand} updateRolePermissions * @returns {Promise} */ static async updatePermissions(updateRolePermissions: UpdateRolePermissionsCommand): Promise { @@ -75,7 +74,7 @@ export default abstract class RolePermissionCommandHandler { /** * @description grant permission to user - * @param CreateRolePermissionCommand + * @param {CreateRolePermissionCommand} createPermission * @returns {Promise} */ static async create(createPermission: CreateRolePermissionCommand): Promise { @@ -98,7 +97,7 @@ export default abstract class RolePermissionCommandHandler { /** * @description remove permission from role - * @param DeleteRolePermissionCommand + * @param {DeleteRolePermissionCommand} deletePermission * @returns {Promise} */ static async delete(deletePermission: DeleteRolePermissionCommand): Promise { @@ -109,7 +108,7 @@ export default abstract class RolePermissionCommandHandler { .where("roleId = :id", { id: deletePermission.roleId }) .andWhere("permission = :permission", { permission: deletePermission.permission }) .execute() - .then((res) => {}) + .then(() => {}) .catch((err) => { throw new InternalException("failed role permission removal", err); }); diff --git a/src/command/inviteCommand.ts b/src/command/user/user/inviteCommand.ts similarity index 100% rename from src/command/inviteCommand.ts rename to src/command/user/user/inviteCommand.ts diff --git a/src/command/inviteCommandHandler.ts b/src/command/user/user/inviteCommandHandler.ts similarity index 89% rename from src/command/inviteCommandHandler.ts rename to src/command/user/user/inviteCommandHandler.ts index 468247b..61c6149 100644 --- a/src/command/inviteCommandHandler.ts +++ b/src/command/user/user/inviteCommandHandler.ts @@ -1,7 +1,7 @@ -import { dataSource } from "../data-source"; -import { invite } from "../entity/invite"; -import InternalException from "../exceptions/internalException"; -import { StringHelper } from "../helpers/stringHelper"; +import { dataSource } from "../../../data-source"; +import { invite } from "../../../entity/user/invite"; +import InternalException from "../../../exceptions/internalException"; +import { StringHelper } from "../../../helpers/stringHelper"; import { CreateInviteCommand, DeleteInviteCommand } from "./inviteCommand"; export default abstract class InviteCommandHandler { diff --git a/src/command/userCommand.ts b/src/command/user/user/userCommand.ts similarity index 100% rename from src/command/userCommand.ts rename to src/command/user/user/userCommand.ts diff --git a/src/command/userCommandHandler.ts b/src/command/user/user/userCommandHandler.ts similarity index 89% rename from src/command/userCommandHandler.ts rename to src/command/user/user/userCommandHandler.ts index 6d1c616..affab87 100644 --- a/src/command/userCommandHandler.ts +++ b/src/command/user/user/userCommandHandler.ts @@ -1,7 +1,7 @@ import { EntityManager } from "typeorm"; -import { dataSource } from "../data-source"; -import { user } from "../entity/user"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { user } from "../../../entity/user/user"; +import InternalException from "../../../exceptions/internalException"; import { CreateUserCommand, DeleteUserCommand, @@ -10,12 +10,12 @@ import { UpdateUserRolesCommand, UpdateUserSecretCommand, } from "./userCommand"; -import UserService from "../service/userService"; +import UserService from "../../../service/user/userService"; export default abstract class UserCommandHandler { /** * @description create user - * @param CreateUserCommand + * @param {CreateUserCommand} createUser * @returns {Promise} */ static async create(createUser: CreateUserCommand): Promise { @@ -42,7 +42,7 @@ export default abstract class UserCommandHandler { /** * @description update user - * @param UpdateUserCommand + * @param {UpdateUserCommand} updateUser * @returns {Promise} */ static async update(updateUser: UpdateUserCommand): Promise { @@ -65,7 +65,7 @@ export default abstract class UserCommandHandler { /** * @description update user - * @param UpdateUserSecretCommand + * @param {UpdateUserSecretCommand} updateUser * @returns {Promise} */ static async updateSecret(updateUser: UpdateUserSecretCommand): Promise { @@ -85,7 +85,7 @@ export default abstract class UserCommandHandler { /** * @description update user roles - * @param UpdateUserRolesCommand + * @param {UpdateUserRolesCommand} updateUserRoles * @returns {Promise} */ static async updateRoles(updateUserRoles: UpdateUserRolesCommand): Promise { @@ -119,13 +119,13 @@ export default abstract class UserCommandHandler { /** * @description transfer ownership - * @param TransferUserOwnerCommand + * @param {TransferUserOwnerCommand} transferOwnership * @returns {Promise} */ static async transferOwnership(transferOwnership: TransferUserOwnerCommand): Promise { return await dataSource.manager .transaction(async (manager) => { - manager + await manager .createQueryBuilder() .update(user) .set({ @@ -134,7 +134,7 @@ export default abstract class UserCommandHandler { .where("id = :id", { id: transferOwnership.fromId }) .execute(); - manager + await manager .createQueryBuilder() .update(user) .set({ diff --git a/src/command/userPermissionCommand.ts b/src/command/user/user/userPermissionCommand.ts similarity index 82% rename from src/command/userPermissionCommand.ts rename to src/command/user/user/userPermissionCommand.ts index 44da15b..47f7594 100644 --- a/src/command/userPermissionCommand.ts +++ b/src/command/user/user/userPermissionCommand.ts @@ -1,4 +1,4 @@ -import { PermissionString } from "../type/permissionTypes"; +import { PermissionString } from "../../../type/permissionTypes"; export interface CreateUserPermissionCommand { permission: PermissionString; diff --git a/src/command/userPermissionCommandHandler.ts b/src/command/user/user/userPermissionCommandHandler.ts similarity index 84% rename from src/command/userPermissionCommandHandler.ts rename to src/command/user/user/userPermissionCommandHandler.ts index 8006ce2..75c1142 100644 --- a/src/command/userPermissionCommandHandler.ts +++ b/src/command/user/user/userPermissionCommandHandler.ts @@ -1,21 +1,21 @@ import { DeleteResult, EntityManager, InsertResult } from "typeorm"; -import { dataSource } from "../data-source"; -import { user } from "../entity/user"; -import { userPermission } from "../entity/user_permission"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { user } from "../../../entity/user/user"; +import { userPermission } from "../../../entity/user/user_permission"; +import InternalException from "../../../exceptions/internalException"; import { CreateUserPermissionCommand, DeleteUserPermissionCommand, UpdateUserPermissionsCommand, } from "./userPermissionCommand"; -import UserPermissionService from "../service/userPermissionService"; -import PermissionHelper from "../helpers/permissionHelper"; -import { PermissionString } from "../type/permissionTypes"; +import UserPermissionService from "../../../service/user/userPermissionService"; +import PermissionHelper from "../../../helpers/permissionHelper"; +import { PermissionString } from "../../../type/permissionTypes"; export default abstract class UserPermissionCommandHandler { /** * @description update user permissions - * @param UpdateUserPermissionsCommand + * @param {UpdateUserPermissionsCommand} updateUserPermissions * @returns {Promise} */ static async updatePermissions(updateUserPermissions: UpdateUserPermissionsCommand): Promise { @@ -75,7 +75,7 @@ export default abstract class UserPermissionCommandHandler { /** * @description grant permission to user - * @param CreateUserPermissionCommand + * @param {CreateUserPermissionCommand} createPermission * @returns {Promise} */ static async create(createPermission: CreateUserPermissionCommand): Promise { @@ -98,7 +98,7 @@ export default abstract class UserPermissionCommandHandler { /** * @description remove permission to user - * @param DeleteUserPermissionCommand + * @param {DeleteUserPermissionCommand} deletePermission * @returns {Promise} */ static async delete(deletePermission: DeleteUserPermissionCommand): Promise { diff --git a/src/controller/admin/calendarController.ts b/src/controller/admin/club/calendarController.ts similarity index 89% rename from src/controller/admin/calendarController.ts rename to src/controller/admin/club/calendarController.ts index f6a3bcd..fcb5ddb 100644 --- a/src/controller/admin/calendarController.ts +++ b/src/controller/admin/club/calendarController.ts @@ -1,16 +1,16 @@ import { Request, Response } from "express"; -import CalendarService from "../../service/calendarService"; -import CalendarFactory from "../../factory/admin/calendar"; -import CalendarTypeService from "../../service/calendarTypeService"; -import CalendarTypeFactory from "../../factory/admin/calendarType"; -import { CreateCalendarCommand, DeleteCalendarCommand, UpdateCalendarCommand } from "../../command/calendarCommand"; -import CalendarCommandHandler from "../../command/calendarCommandHandler"; +import CalendarService from "../../../service/club/calendarService"; +import CalendarFactory from "../../../factory/admin/club/calendar"; +import CalendarTypeService from "../../../service/settings/calendarTypeService"; +import CalendarTypeFactory from "../../../factory/admin/settings/calendarType"; +import { CreateCalendarCommand, DeleteCalendarCommand, UpdateCalendarCommand } from "../../../command/club/calendar/calendarCommand"; +import CalendarCommandHandler from "../../../command/club/calendar/calendarCommandHandler"; import { CreateCalendarTypeCommand, DeleteCalendarTypeCommand, UpdateCalendarTypeCommand, -} from "../../command/calendarTypeCommand"; -import CalendarTypeCommandHandler from "../../command/calendarTypeCommandHandler"; +} from "../../../command/settings/calendarType/calendarTypeCommand"; +import CalendarTypeCommandHandler from "../../../command/settings/calendarType/calendarTypeCommandHandler"; /** * @description get all calendar items diff --git a/src/controller/admin/memberController.ts b/src/controller/admin/club/memberController.ts similarity index 87% rename from src/controller/admin/memberController.ts rename to src/controller/admin/club/memberController.ts index 9aa6446..dacbbae 100644 --- a/src/controller/admin/memberController.ts +++ b/src/controller/admin/club/memberController.ts @@ -1,53 +1,55 @@ import { Request, Response } from "express"; -import MemberService from "../../service/memberService"; -import MemberFactory from "../../factory/admin/member"; -import MembershipService from "../../service/membershipService"; -import MembershipFactory from "../../factory/admin/membership"; -import MemberAwardService from "../../service/memberAwardService"; -import MemberAwardFactory from "../../factory/admin/memberAward"; -import MemberQualificationService from "../../service/memberQualificationService"; -import MemberQualificationFactory from "../../factory/admin/memberQualification"; -import MemberExecutivePositionService from "../../service/memberExecutivePositionService"; -import MemberExecutivePositionFactory from "../../factory/admin/memberExecutivePosition"; -import CommunicationService from "../../service/communicationService"; -import CommunicationFactory from "../../factory/admin/communication"; +import MemberService from "../../../service/club/member/memberService"; +import MemberFactory from "../../../factory/admin/club/member/member"; +import MembershipService from "../../../service/club/member/membershipService"; +import MembershipFactory from "../../../factory/admin/club/member/membership"; +import MemberAwardService from "../../../service/club/member/memberAwardService"; +import MemberAwardFactory from "../../../factory/admin/club/member/memberAward"; +import MemberQualificationService from "../../../service/club/member/memberQualificationService"; +import MemberQualificationFactory from "../../../factory/admin/club/member/memberQualification"; +import MemberExecutivePositionService from "../../../service/club/member/memberExecutivePositionService"; +import MemberExecutivePositionFactory from "../../../factory/admin/club/member/memberExecutivePosition"; +import CommunicationService from "../../../service/club/member/communicationService"; +import CommunicationFactory from "../../../factory/admin/club/member/communication"; import { CreateMemberCommand, DeleteMemberCommand, UpdateMemberCommand, UpdateMemberNewsletterCommand, -} from "../../command/memberCommand"; -import MemberCommandHandler from "../../command/memberCommandHandler"; +} from "../../../command/club/member/memberCommand"; +import MemberCommandHandler from "../../../command/club/member/memberCommandHandler"; import { CreateMembershipCommand, DeleteMembershipCommand, UpdateMembershipCommand, -} from "../../command/membershipCommand"; -import MembershipCommandHandler from "../../command/membershipCommandHandler"; +} from "../../../command/club/member/membershipCommand"; +import MembershipCommandHandler from "../../../command/club/member/membershipCommandHandler"; import { CreateMemberAwardCommand, DeleteMemberAwardCommand, UpdateMemberAwardCommand, -} from "../../command/memberAwardCommand"; -import MemberAwardCommandHandler from "../../command/memberAwardCommandHandler"; +} from "../../../command/club/member/memberAwardCommand"; +import MemberAwardCommandHandler from "../../../command/club/member/memberAwardCommandHandler"; import { CreateMemberExecutivePositionCommand, DeleteMemberExecutivePositionCommand, UpdateMemberExecutivePositionCommand, -} from "../../command/memberExecutivePositionCommand"; -import MemberExecutivePositionCommandHandler from "../../command/memberExecutivePositionCommandHandler"; +} from "../../../command/club/member/memberExecutivePositionCommand"; +import MemberExecutivePositionCommandHandler from "../../../command/club/member/memberExecutivePositionCommandHandler"; import { CreateMemberQualificationCommand, DeleteMemberQualificationCommand, UpdateMemberQualificationCommand, -} from "../../command/memberQualificationCommand"; -import MemberQualificationCommandHandler from "../../command/memberQualificationCommandHandler"; +} from "../../../command/club/member/memberQualificationCommand"; +import MemberQualificationCommandHandler from "../../../command/club/member/memberQualificationCommandHandler"; import { CreateCommunicationCommand, DeleteCommunicationCommand, UpdateCommunicationCommand, -} from "../../command/communicationCommand"; -import CommunicationCommandHandler from "../../command/communicationCommandHandler"; +} from "../../../command/club/member/communicationCommand"; +import CommunicationCommandHandler from "../../../command/club/member/communicationCommandHandler"; +import {PdfExport} from "../../../helpers/pdfExport"; +import {PermissionModule} from "../../../type/permissionTypes"; /** * @description get all members @@ -218,6 +220,33 @@ export async function getCommunicationByMemberAndRecord(req: Request, res: Respo res.json(CommunicationFactory.mapToSingle(communication)); } +/** + * @description create member printout list + * @param req {Request} Express req object + * @param res {Response} Express res object + * @returns {Promise<*>} + */ +export async function createMemberPrintoutList(req: Request, res: Response): Promise { + let members = await MemberService.getByRunningMembership() + + let pdf = await PdfExport.renderFile({ + title: "Mitgliederliste", + template: "member.list", + saveToDisk: false, + data: { + member: members + }, + }); + + let pdfbuffer = Buffer.from(pdf); + + res.setHeader("Content-Type", "application/pdf"); + res.setHeader("Content-Length", pdfbuffer.byteLength); + res.setHeader("Content-Disposition", "inline; filename=preview.pdf"); + + res.send(pdfbuffer); +} + /** * @description create member * @param req {Request} Express req object diff --git a/src/controller/admin/newsletterController.ts b/src/controller/admin/club/newsletterController.ts similarity index 86% rename from src/controller/admin/newsletterController.ts rename to src/controller/admin/club/newsletterController.ts index 87e62ca..7c322e9 100644 --- a/src/controller/admin/newsletterController.ts +++ b/src/controller/admin/club/newsletterController.ts @@ -1,24 +1,24 @@ import { Request, Response } from "express"; -import NewsletterService from "../../service/newsletterService"; -import NewsletterFactory from "../../factory/admin/newsletter"; -import NewsletterDatesService from "../../service/newsletterDatesService"; -import NewsletterDatesFactory from "../../factory/admin/newsletterDates"; -import NewsletterRecipientsService from "../../service/newsletterRecipientsService"; -import NewsletterRecipientsFactory from "../../factory/admin/newsletterRecipients"; -import { FileSystemHelper } from "../../helpers/fileSystemHelper"; -import { CreateNewsletterCommand, SynchronizeNewsletterCommand } from "../../command/newsletterCommand"; -import NewsletterCommandHandler from "../../command/newsletterCommandHandler"; -import { SynchronizeNewsletterDatesCommand } from "../../command/newsletterDatesCommand"; -import NewsletterDatesCommandHandler from "../../command/newsletterDatesCommandHandler"; -import { SynchronizeNewsletterRecipientsCommand } from "../../command/newsletterRecipientsCommand"; -import NewsletterRecipientsCommandHandler from "../../command/newsletterRecipientsCommandHandler"; -import { NewsletterDatesViewModel } from "../../viewmodel/admin/newsletterDates.models"; -import { PdfExport } from "../../helpers/pdfExport"; -import UserService from "../../service/userService"; -import { TemplateHelper } from "../../helpers/templateHelper"; -import MailHelper from "../../helpers/mailHelper"; -import { NewsletterEventType, NewsletterHelper } from "../../helpers/newsletterHelper"; -import { Salutation } from "../../enums/salutation"; +import NewsletterService from "../../../service/club/newsletter/newsletterService"; +import NewsletterFactory from "../../../factory/admin/club/newsletter/newsletter"; +import NewsletterDatesService from "../../../service/club/newsletter/newsletterDatesService"; +import NewsletterDatesFactory from "../../../factory/admin/club/newsletter/newsletterDates"; +import NewsletterRecipientsService from "../../../service/club/newsletter/newsletterRecipientsService"; +import NewsletterRecipientsFactory from "../../../factory/admin/club/newsletter/newsletterRecipients"; +import { FileSystemHelper } from "../../../helpers/fileSystemHelper"; +import { CreateNewsletterCommand, SynchronizeNewsletterCommand } from "../../../command/club/newsletter/newsletterCommand"; +import NewsletterCommandHandler from "../../../command/club/newsletter/newsletterCommandHandler"; +import { SynchronizeNewsletterDatesCommand } from "../../../command/club/newsletter/newsletterDatesCommand"; +import NewsletterDatesCommandHandler from "../../../command/club/newsletter/newsletterDatesCommandHandler"; +import { SynchronizeNewsletterRecipientsCommand } from "../../../command/club/newsletter/newsletterRecipientsCommand"; +import NewsletterRecipientsCommandHandler from "../../../command/club/newsletter/newsletterRecipientsCommandHandler"; +import { NewsletterDatesViewModel } from "../../../viewmodel/admin/club/newsletter/newsletterDates.models"; +import { PdfExport } from "../../../helpers/pdfExport"; +import UserService from "../../../service/user/userService"; +import { TemplateHelper } from "../../../helpers/templateHelper"; +import MailHelper from "../../../helpers/mailHelper"; +import { NewsletterEventType, NewsletterHelper } from "../../../helpers/newsletterHelper"; +import { Salutation } from "../../../enums/salutation"; /** * @description get all newsletters diff --git a/src/controller/admin/protocolController.ts b/src/controller/admin/club/protocolController.ts similarity index 75% rename from src/controller/admin/protocolController.ts rename to src/controller/admin/club/protocolController.ts index a82608f..bba8aa0 100644 --- a/src/controller/admin/protocolController.ts +++ b/src/controller/admin/club/protocolController.ts @@ -1,33 +1,34 @@ import { Request, Response } from "express"; -import ProtocolService from "../../service/protocolService"; -import ProtocolFactory from "../../factory/admin/protocol"; -import ProtocolAgendaService from "../../service/protocolAgendaService"; -import ProtocolAgendaFactory from "../../factory/admin/protocolAgenda"; -import ProtocolDecisionService from "../../service/protocolDecisionService"; -import ProtocolDecisionFactory from "../../factory/admin/protocolDecision"; -import ProtocolPresenceService from "../../service/protocolPrecenseService"; -import ProtocolPresenceFactory from "../../factory/admin/protocolPresence"; -import ProtocolVotingService from "../../service/protocolVotingService"; -import ProtocolVotingFactory from "../../factory/admin/protocolVoting"; -import { CreateProtocolCommand, SynchronizeProtocolCommand } from "../../command/protocolCommand"; -import ProtocolCommandHandler from "../../command/protocolCommandHandler"; -import { SynchronizeProtocolAgendaCommand } from "../../command/protocolAgendaCommand"; -import ProtocolAgendaCommandHandler from "../../command/protocolAgendaCommandHandler"; -import { ProtocolAgendaViewModel } from "../../viewmodel/admin/protocolAgenda.models"; -import ProtocolDecisionCommandHandler from "../../command/protocolDecisionCommandHandler"; -import { ProtocolDecisionViewModel } from "../../viewmodel/admin/protocolDecision.models"; -import ProtocolPresenceCommandHandler from "../../command/protocolPresenceCommandHandler"; -import { SynchronizeProtocolPresenceCommand } from "../../command/protocolPresenceCommand"; -import { SynchronizeProtocolDecisionCommand } from "../../command/protocolDecisionCommand"; -import { SynchronizeProtocolVotingCommand } from "../../command/protocolVotingCommand"; -import { ProtocolVotingViewModel } from "../../viewmodel/admin/protocolVoting.models"; -import ProtocolVotingCommandHandler from "../../command/protocolVotingCommandHandler"; -import { PdfExport } from "../../helpers/pdfExport"; -import ProtocolPrintoutService from "../../service/protocolPrintoutService"; -import ProtocolPrintoutFactory from "../../factory/admin/protocolPrintout"; -import { CreateProtocolPrintoutCommand } from "../../command/protocolPrintoutCommand"; -import ProtocolPrintoutCommandHandler from "../../command/protocolPrintoutCommandHandler"; -import { FileSystemHelper } from "../../helpers/fileSystemHelper"; +import ProtocolService from "../../../service/club/protocol/protocolService"; +import ProtocolFactory from "../../../factory/admin/club/protocol/protocol"; +import ProtocolAgendaService from "../../../service/club/protocol/protocolAgendaService"; +import ProtocolAgendaFactory from "../../../factory/admin/club/protocol/protocolAgenda"; +import ProtocolDecisionService from "../../../service/club/protocol/protocolDecisionService"; +import ProtocolDecisionFactory from "../../../factory/admin/club/protocol/protocolDecision"; +import ProtocolPresenceService from "../../../service/club/protocol/protocolPrecenseService"; +import ProtocolPresenceFactory from "../../../factory/admin/club/protocol/protocolPresence"; +import ProtocolVotingService from "../../../service/club/protocol/protocolVotingService"; +import ProtocolVotingFactory from "../../../factory/admin/club/protocol/protocolVoting"; +import { CreateProtocolCommand, SynchronizeProtocolCommand } from "../../../command/club/protocol/protocolCommand"; +import ProtocolCommandHandler from "../../../command/club/protocol/protocolCommandHandler"; +import { SynchronizeProtocolAgendaCommand } from "../../../command/club/protocol/protocolAgendaCommand"; +import ProtocolAgendaCommandHandler from "../../../command/club/protocol/protocolAgendaCommandHandler"; +import { ProtocolAgendaViewModel } from "../../../viewmodel/admin/club/protocol/protocolAgenda.models"; +import ProtocolDecisionCommandHandler from "../../../command/club/protocol/protocolDecisionCommandHandler"; +import { ProtocolDecisionViewModel } from "../../../viewmodel/admin/club/protocol/protocolDecision.models"; +import ProtocolPresenceCommandHandler from "../../../command/club/protocol/protocolPresenceCommandHandler"; +import { SynchronizeProtocolPresenceCommand } from "../../../command/club/protocol/protocolPresenceCommand"; +import { SynchronizeProtocolDecisionCommand } from "../../../command/club/protocol/protocolDecisionCommand"; +import { SynchronizeProtocolVotingCommand } from "../../../command/club/protocol/protocolVotingCommand"; +import { ProtocolVotingViewModel } from "../../../viewmodel/admin/club/protocol/protocolVoting.models"; +import ProtocolVotingCommandHandler from "../../../command/club/protocol/protocolVotingCommandHandler"; +import { PdfExport } from "../../../helpers/pdfExport"; +import ProtocolPrintoutService from "../../../service/club/protocol/protocolPrintoutService"; +import ProtocolPrintoutFactory from "../../../factory/admin/club/protocol/protocolPrintout"; +import { CreateProtocolPrintoutCommand } from "../../../command/club/protocol/protocolPrintoutCommand"; +import ProtocolPrintoutCommandHandler from "../../../command/club/protocol/protocolPrintoutCommandHandler"; +import { FileSystemHelper } from "../../../helpers/fileSystemHelper"; +import { ProtocolPresenceViewModel } from "../../../viewmodel/admin/club/protocol/protocolPresence.models"; /** * @description get all protocols @@ -143,7 +144,9 @@ export async function getProtocolPrintoutByIdAndPrint(req: Request, res: Respons let printout = await ProtocolPrintoutService.getById(printoutId, protocolId); - res.sendFile(process.cwd() + `/export/${printout.filename}.pdf`, { + let filepath = FileSystemHelper.formatPath("protocol", printout.filename); + + res.sendFile(filepath, { headers: { "Content-Type": "application/pdf", }, @@ -226,7 +229,7 @@ export async function createProtocolPrintoutById(req: Request, res: Response): P let votings = await ProtocolVotingService.getAll(protocolId); let iteration = await ProtocolPrintoutService.getCount(protocolId); - let title = `Sitzungsprotokoll - ${new Date(protocol.date).toLocaleDateString("de-DE", { + let title = `${protocol.title} - ${new Date(protocol.date).toLocaleDateString("de-DE", { day: "2-digit", month: "long", year: "numeric", @@ -256,7 +259,8 @@ export async function createProtocolPrintoutById(req: Request, res: Response): P end: protocol.endtime, agenda, decisions, - presence: presence.map((p) => p.member), + presence: presence.filter((p) => !p.absent).map((p) => p.member), + absent: presence.filter((p) => p.absent).map((p) => p.member), votings, }, }); @@ -264,7 +268,7 @@ export async function createProtocolPrintoutById(req: Request, res: Response): P let printout: CreateProtocolPrintoutCommand = { title, iteration: iteration + 1, - filename: FileSystemHelper.normalizePath("protocol", filename), + filename: `${filename}.pdf`, protocolId, }; await ProtocolPrintoutCommandHandler.create(printout); @@ -379,10 +383,13 @@ export async function synchronizeProtocolVotingsById(req: Request, res: Response */ export async function synchronizeProtocolPrecenseById(req: Request, res: Response): Promise { let protocolId = parseInt(req.params.protocolId); - let presence = req.body.presence as Array; + let presence = req.body.presence as Array; let syncPresence: SynchronizeProtocolPresenceCommand = { - memberIds: presence, + members: presence.map((p) => ({ + memberId: p.memberId, + absent: p.absent, + })), protocolId, }; await ProtocolPresenceCommandHandler.sync(syncPresence); diff --git a/src/controller/admin/club/queryBuilderController.ts b/src/controller/admin/club/queryBuilderController.ts new file mode 100644 index 0000000..1fa4cb5 --- /dev/null +++ b/src/controller/admin/club/queryBuilderController.ts @@ -0,0 +1,44 @@ +import { Request, Response } from "express"; +import DynamicQueryBuilder from "../../../helpers/dynamicQueryBuilder"; +import { dataSource } from "../../../data-source"; + +/** + * @description get all table metas + * @param req {Request} Express req object + * @param res {Response} Express res object + * @returns {Promise<*>} + */ +export async function getAllTableMeta(req: Request, res: Response): Promise { + let tableMetas = DynamicQueryBuilder.getAllTableMeta(); + + res.json(tableMetas); +} + +/** + * @description get meta by tablename + * @param req {Request} Express req object + * @param res {Response} Express res object + * @returns {Promise<*>} + */ +export async function getTableMetaByTablename(req: Request, res: Response): Promise { + const tablename = req.params.tablename; + let tableMeta = DynamicQueryBuilder.getTableMeta(tablename); + + res.json(tableMeta); +} + +/** + * @description execute Query + * @param req {Request} Express req object + * @param res {Response} Express res object + * @returns {Promise<*>} + */ +export async function executeQuery(req: Request, res: Response): Promise { + let offset = parseInt((req.query.offset as string) ?? "0"); + let count = parseInt((req.query.count as string) ?? "25"); + const query = req.body.query; + + let result = await DynamicQueryBuilder.executeQuery(query, offset, count); + + res.json(result); +} diff --git a/src/controller/admin/queryBuilderController.ts b/src/controller/admin/queryBuilderController.ts deleted file mode 100644 index e6bb519..0000000 --- a/src/controller/admin/queryBuilderController.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { Request, Response } from "express"; -import DynamicQueryBuilder from "../../helpers/dynamicQueryBuilder"; -import { dataSource } from "../../data-source"; - -/** - * @description get all table metas - * @param req {Request} Express req object - * @param res {Response} Express res object - * @returns {Promise<*>} - */ -export async function getAllTableMeta(req: Request, res: Response): Promise { - let tableMetas = DynamicQueryBuilder.getAllTableMeta(); - - res.json(tableMetas); -} - -/** - * @description get meta by tablename - * @param req {Request} Express req object - * @param res {Response} Express res object - * @returns {Promise<*>} - */ -export async function getTableMetaByTablename(req: Request, res: Response): Promise { - const tablename = req.params.tablename; - let tableMeta = DynamicQueryBuilder.getTableMeta(tablename); - - res.json(tableMeta); -} - -/** - * @description execute Query - * @param req {Request} Express req object - * @param res {Response} Express res object - * @returns {Promise<*>} - */ -export async function executeQuery(req: Request, res: Response): Promise { - let offset = parseInt((req.query.offset as string) ?? "0"); - let count = parseInt((req.query.count as string) ?? "25"); - const query = req.body.query; - - if (typeof query == "string") { - const upperQuery = query.trim().toUpperCase(); - if (!upperQuery.startsWith("SELECT") || /INSERT|UPDATE|DELETE|ALTER|DROP|CREATE|TRUNCATE/.test(upperQuery)) { - return res.json({ - stats: "error", - sql: query, - code: "UNALLOWED", - msg: "Not allowed to change rows", - }); - } - - try { - let data: Array = []; - - const result = await dataSource - .transaction(async (manager) => { - data = await manager.query(query); - - throw new Error("AllwaysRollbackQuery"); - }) - .catch((error) => { - if (error.message === "AllwaysRollbackQuery") { - return { - stats: "success", - rows: data, - total: data.length, - offset: offset, - count: count, - }; - } else { - return { - stats: "error", - sql: error.sql, - code: error.code, - msg: error.sqlMessage, - }; - } - }); - res.send(result); - } catch (error) { - res.json({ - stats: "error", - sql: error.sql, - code: error.code, - msg: error.sqlMessage, - }); - } - } else { - try { - let [rows, total] = await DynamicQueryBuilder.buildQuery(query, offset, count).getManyAndCount(); - - res.json({ - stats: "success", - rows: DynamicQueryBuilder.flattenQueryResult(rows), - total: total, - offset: offset, - count: count, - }); - } catch (error) { - res.json({ - stats: "error", - sql: error.sql, - code: error.code, - msg: error.sqlMessage, - }); - } - } -} diff --git a/src/controller/admin/awardController.ts b/src/controller/admin/settings/awardController.ts similarity index 88% rename from src/controller/admin/awardController.ts rename to src/controller/admin/settings/awardController.ts index 695e3b1..a87b1c3 100644 --- a/src/controller/admin/awardController.ts +++ b/src/controller/admin/settings/awardController.ts @@ -1,8 +1,8 @@ import { Request, Response } from "express"; -import AwardService from "../../service/awardService"; -import AwardFactory from "../../factory/admin/award"; -import { CreateAwardCommand, DeleteAwardCommand, UpdateAwardCommand } from "../../command/awardCommand"; -import AwardCommandHandler from "../../command/awardCommandHandler"; +import AwardService from "../../../service/settings/awardService"; +import AwardFactory from "../../../factory/admin/settings/award"; +import { CreateAwardCommand, DeleteAwardCommand, UpdateAwardCommand } from "../../../command/settings/award/awardCommand"; +import AwardCommandHandler from "../../../command/settings/award/awardCommandHandler"; /** * @description get all awards diff --git a/src/controller/admin/communicationTypeController.ts b/src/controller/admin/settings/communicationTypeController.ts similarity index 86% rename from src/controller/admin/communicationTypeController.ts rename to src/controller/admin/settings/communicationTypeController.ts index 2d0b4e0..ad46b03 100644 --- a/src/controller/admin/communicationTypeController.ts +++ b/src/controller/admin/settings/communicationTypeController.ts @@ -1,13 +1,13 @@ import { Request, Response } from "express"; -import CommunicationTypeService from "../../service/communicationTypeService"; -import CommunicationTypeFactory from "../../factory/admin/communicationType"; -import CommunicationService from "../../service/communicationService"; +import CommunicationTypeService from "../../../service/settings/communicationTypeService"; +import CommunicationTypeFactory from "../../../factory/admin/settings/communicationType"; +import CommunicationService from "../../../service/club/member/communicationService"; import { CreateCommunicationTypeCommand, DeleteCommunicationTypeCommand, UpdateCommunicationTypeCommand, -} from "../../command/communicationTypeCommand"; -import CommunicationTypeCommandHandler from "../../command/communicationTypeCommandHandler"; +} from "../../../command/settings/communicationType/communicationTypeCommand"; +import CommunicationTypeCommandHandler from "../../../command/settings/communicationType/communicationTypeCommandHandler"; /** * @description get all communicationTypes diff --git a/src/controller/admin/executivePositionController.ts b/src/controller/admin/settings/executivePositionController.ts similarity index 86% rename from src/controller/admin/executivePositionController.ts rename to src/controller/admin/settings/executivePositionController.ts index 2c1c77d..15437ef 100644 --- a/src/controller/admin/executivePositionController.ts +++ b/src/controller/admin/settings/executivePositionController.ts @@ -1,12 +1,12 @@ import { Request, Response } from "express"; -import ExecutivePositionService from "../../service/executivePositionService"; -import ExecutivePositionFactory from "../../factory/admin/executivePosition"; +import ExecutivePositionService from "../../../service/settings/executivePositionService"; +import ExecutivePositionFactory from "../../../factory/admin/settings/executivePosition"; import { CreateExecutivePositionCommand, DeleteExecutivePositionCommand, UpdateExecutivePositionCommand, -} from "../../command/executivePositionCommand"; -import ExecutivePositionCommandHandler from "../../command/executivePositionCommandHandler"; +} from "../../../command/settings/executivePosition/executivePositionCommand"; +import ExecutivePositionCommandHandler from "../../../command/settings/executivePosition/executivePositionCommandHandler"; /** * @description get all executivePositions diff --git a/src/controller/admin/membershipStatusController.ts b/src/controller/admin/settings/membershipStatusController.ts similarity index 86% rename from src/controller/admin/membershipStatusController.ts rename to src/controller/admin/settings/membershipStatusController.ts index e840773..9c5fa23 100644 --- a/src/controller/admin/membershipStatusController.ts +++ b/src/controller/admin/settings/membershipStatusController.ts @@ -1,12 +1,12 @@ import { Request, Response } from "express"; -import MembershipStatusService from "../../service/membershipStatusService"; -import MembershipStatusFactory from "../../factory/admin/membershipStatus"; +import MembershipStatusService from "../../../service/settings/membershipStatusService"; +import MembershipStatusFactory from "../../../factory/admin/settings/membershipStatus"; import { CreateMembershipStatusCommand, DeleteMembershipStatusCommand, UpdateMembershipStatusCommand, -} from "../../command/membershipStatusCommand"; -import MembershipStatusCommandHandler from "../../command/membershipStatusCommandHandler"; +} from "../../../command/settings/membershipStatus/membershipStatusCommand"; +import MembershipStatusCommandHandler from "../../../command/settings/membershipStatus/membershipStatusCommandHandler"; /** * @description get all membershipStatus diff --git a/src/controller/admin/newsletterConfigController.ts b/src/controller/admin/settings/newsletterConfigController.ts similarity index 83% rename from src/controller/admin/newsletterConfigController.ts rename to src/controller/admin/settings/newsletterConfigController.ts index 3abe4b5..f047816 100644 --- a/src/controller/admin/newsletterConfigController.ts +++ b/src/controller/admin/settings/newsletterConfigController.ts @@ -1,8 +1,8 @@ import { Request, Response } from "express"; -import NewsletterConfigService from "../../service/newsletterConfigService"; -import NewsletterConfigFactory from "../../factory/admin/newsletterConfig"; -import NewsletterConfigCommandHandler from "../../command/newsletterConfigCommandHandler"; -import { DeleteNewsletterConfigCommand, SetNewsletterConfigCommand } from "../../command/newsletterConfigCommand"; +import NewsletterConfigService from "../../../service/settings/newsletterConfigService"; +import NewsletterConfigFactory from "../../../factory/admin/settings/newsletterConfig"; +import NewsletterConfigCommandHandler from "../../../command/settings/newsletterConfig/newsletterConfigCommandHandler"; +import { DeleteNewsletterConfigCommand, SetNewsletterConfigCommand } from "../../../command/settings/newsletterConfig/newsletterConfigCommand"; /** * @description get all newsletterConfigs diff --git a/src/controller/admin/qualificationController.ts b/src/controller/admin/settings/qualificationController.ts similarity index 88% rename from src/controller/admin/qualificationController.ts rename to src/controller/admin/settings/qualificationController.ts index c7074d5..75c9b15 100644 --- a/src/controller/admin/qualificationController.ts +++ b/src/controller/admin/settings/qualificationController.ts @@ -1,12 +1,12 @@ import { Request, Response } from "express"; -import QualificationService from "../../service/qualification"; -import QualificationFactory from "../../factory/admin/qualification"; +import QualificationService from "../../../service/settings/qualification"; +import QualificationFactory from "../../../factory/admin/settings/qualification"; import { CreateQualificationCommand, DeleteQualificationCommand, UpdateQualificationCommand, -} from "../../command/qualificationCommand"; -import QualificationCommandHandler from "../../command/qualificationCommandHandler"; +} from "../../../command/settings/qualification/qualificationCommand"; +import QualificationCommandHandler from "../../../command/settings/qualification/qualificationCommandHandler"; /** * @description get all qualifications diff --git a/src/controller/admin/queryStoreController.ts b/src/controller/admin/settings/queryStoreController.ts similarity index 87% rename from src/controller/admin/queryStoreController.ts rename to src/controller/admin/settings/queryStoreController.ts index 6c6e9c6..397b898 100644 --- a/src/controller/admin/queryStoreController.ts +++ b/src/controller/admin/settings/queryStoreController.ts @@ -1,12 +1,12 @@ import { Request, Response } from "express"; -import QueryStoreFactory from "../../factory/admin/queryStore"; -import QueryStoreService from "../../service/queryStoreService"; +import QueryStoreFactory from "../../../factory/admin/settings/queryStore"; +import QueryStoreService from "../../../service/settings/queryStoreService"; import { CreateQueryStoreCommand, DeleteQueryStoreCommand, UpdateQueryStoreCommand, -} from "../../command/queryStoreCommand"; -import QueryStoreCommandHandler from "../../command/queryStoreCommandHandler"; +} from "../../../command/settings/queryStore/queryStoreCommand"; +import QueryStoreCommandHandler from "../../../command/settings/queryStore/queryStoreCommandHandler"; /** * @description get all queryStores diff --git a/src/controller/admin/templateController.ts b/src/controller/admin/settings/templateController.ts similarity index 91% rename from src/controller/admin/templateController.ts rename to src/controller/admin/settings/templateController.ts index 9f867f9..eb9d31e 100644 --- a/src/controller/admin/templateController.ts +++ b/src/controller/admin/settings/templateController.ts @@ -1,8 +1,8 @@ import { Request, Response } from "express"; -import TemplateService from "../../service/templateService"; -import TemplateFactory from "../../factory/admin/template"; -import { CreateTemplateCommand, DeleteTemplateCommand, UpdateTemplateCommand } from "../../command/templateCommand"; -import TemplateCommandHandler from "../../command/templateCommandHandler"; +import TemplateService from "../../../service/settings/templateService"; +import TemplateFactory from "../../../factory/admin/settings/template"; +import { CreateTemplateCommand, DeleteTemplateCommand, UpdateTemplateCommand } from "../../../command/settings/template/templateCommand"; +import TemplateCommandHandler from "../../../command/settings/template/templateCommandHandler"; /** * @description get all templates diff --git a/src/controller/admin/templateUsageController.ts b/src/controller/admin/settings/templateUsageController.ts similarity index 76% rename from src/controller/admin/templateUsageController.ts rename to src/controller/admin/settings/templateUsageController.ts index 0a75af3..eb8b71f 100644 --- a/src/controller/admin/templateUsageController.ts +++ b/src/controller/admin/settings/templateUsageController.ts @@ -1,13 +1,13 @@ import { Request, Response } from "express"; -import TemplateUsageService from "../../service/templateUsageService"; -import TemplateUsageFactory from "../../factory/admin/templateUsage"; -import { UpdateTemplateUsageCommand } from "../../command/templateUsageCommand"; -import TemplateUsageCommandHandler from "../../command/templateUsageCommandHandler"; -import PermissionHelper from "../../helpers/permissionHelper"; -import ForbiddenRequestException from "../../exceptions/forbiddenRequestException"; -import { PermissionModule } from "../../type/permissionTypes"; -import { PdfExport } from "../../helpers/pdfExport"; -import { DemoDataHelper } from "../../helpers/demoDataHelper"; +import TemplateUsageService from "../../../service/settings/templateUsageService"; +import TemplateUsageFactory from "../../../factory/admin/settings/templateUsage"; +import { UpdateTemplateUsageCommand } from "../../../command/settings/templateUsage/templateUsageCommand"; +import TemplateUsageCommandHandler from "../../../command/settings/templateUsage/templateUsageCommandHandler"; +import PermissionHelper from "../../../helpers/permissionHelper"; +import ForbiddenRequestException from "../../../exceptions/forbiddenRequestException"; +import { PermissionModule } from "../../../type/permissionTypes"; +import { PdfExport } from "../../../helpers/pdfExport"; +import { DemoDataHelper } from "../../../helpers/demoDataHelper"; /** * @description get all templateUsages @@ -21,8 +21,8 @@ export async function getAllTemplateUsages(req: Request, res: Response): Promise if (!req.isOwner) { templateUsages = templateUsages.filter((tu) => { return ( - PermissionHelper.can(req.permissions, "update", "settings", tu.scope) || - PermissionHelper.can(req.permissions, "update", "club", tu.scope) + PermissionHelper.can(req.permissions, "update", "settings", tu.scope.split(".")[0] as PermissionModule) || + PermissionHelper.can(req.permissions, "update", "club", tu.scope.split(".")[0] as PermissionModule) ); }); } diff --git a/src/controller/admin/roleController.ts b/src/controller/admin/user/roleController.ts similarity index 83% rename from src/controller/admin/roleController.ts rename to src/controller/admin/user/roleController.ts index 67f6f78..f482b63 100644 --- a/src/controller/admin/roleController.ts +++ b/src/controller/admin/user/roleController.ts @@ -1,12 +1,12 @@ import { Request, Response } from "express"; -import RoleService from "../../service/roleService"; -import RoleFactory from "../../factory/admin/role"; -import RolePermissionService from "../../service/rolePermissionService"; -import PermissionHelper from "../../helpers/permissionHelper"; -import { CreateRoleCommand, DeleteRoleCommand, UpdateRoleCommand } from "../../command/roleCommand"; -import RoleCommandHandler from "../../command/roleCommandHandler"; -import { UpdateRolePermissionsCommand } from "../../command/rolePermissionCommand"; -import RolePermissionCommandHandler from "../../command/rolePermissionCommandHandler"; +import RoleService from "../../../service/user/roleService"; +import RoleFactory from "../../../factory/admin/user/role"; +import RolePermissionService from "../../../service/user/rolePermissionService"; +import PermissionHelper from "../../../helpers/permissionHelper"; +import { CreateRoleCommand, DeleteRoleCommand, UpdateRoleCommand } from "../../../command/user/role/roleCommand"; +import RoleCommandHandler from "../../../command/user/role/roleCommandHandler"; +import { UpdateRolePermissionsCommand } from "../../../command/user/role/rolePermissionCommand"; +import RolePermissionCommandHandler from "../../../command/user/role/rolePermissionCommandHandler"; /** * @description get All roles diff --git a/src/controller/admin/userController.ts b/src/controller/admin/user/userController.ts similarity index 84% rename from src/controller/admin/userController.ts rename to src/controller/admin/user/userController.ts index 0177fec..8862699 100644 --- a/src/controller/admin/userController.ts +++ b/src/controller/admin/user/userController.ts @@ -1,15 +1,15 @@ import { Request, Response } from "express"; -import UserService from "../../service/userService"; -import UserFactory from "../../factory/admin/user"; -import UserPermissionService from "../../service/userPermissionService"; -import PermissionHelper from "../../helpers/permissionHelper"; -import RoleFactory from "../../factory/admin/role"; -import { DeleteUserCommand, UpdateUserCommand, UpdateUserRolesCommand } from "../../command/userCommand"; -import UserCommandHandler from "../../command/userCommandHandler"; -import MailHelper from "../../helpers/mailHelper"; -import { CLUB_NAME } from "../../env.defaults"; -import { UpdateUserPermissionsCommand } from "../../command/userPermissionCommand"; -import UserPermissionCommandHandler from "../../command/userPermissionCommandHandler"; +import UserService from "../../../service/user/userService"; +import UserFactory from "../../../factory/admin/user/user"; +import UserPermissionService from "../../../service/user/userPermissionService"; +import PermissionHelper from "../../../helpers/permissionHelper"; +import RoleFactory from "../../../factory/admin/user/role"; +import { DeleteUserCommand, UpdateUserCommand, UpdateUserRolesCommand } from "../../../command/user/user/userCommand"; +import UserCommandHandler from "../../../command/user/user/userCommandHandler"; +import MailHelper from "../../../helpers/mailHelper"; +import { CLUB_NAME } from "../../../env.defaults"; +import { UpdateUserPermissionsCommand } from "../../../command/user/user/userPermissionCommand"; +import UserPermissionCommandHandler from "../../../command/user/user/userPermissionCommandHandler"; /** * @description get All users diff --git a/src/controller/authController.ts b/src/controller/authController.ts index 7b2494b..dd4fee7 100644 --- a/src/controller/authController.ts +++ b/src/controller/authController.ts @@ -4,13 +4,13 @@ import { JWTToken } from "../type/jwtTypes"; import InternalException from "../exceptions/internalException"; import RefreshCommandHandler from "../command/refreshCommandHandler"; import { CreateRefreshCommand, DeleteRefreshCommand } from "../command/refreshCommand"; -import UserService from "../service/userService"; +import UserService from "../service/user/userService"; import speakeasy from "speakeasy"; import UnauthorizedRequestException from "../exceptions/unauthorizedRequestException"; import RefreshService from "../service/refreshService"; -import UserPermissionService from "../service/userPermissionService"; +import UserPermissionService from "../service/user/userPermissionService"; import PermissionHelper from "../helpers/permissionHelper"; -import RolePermissionService from "../service/rolePermissionService"; +import RolePermissionService from "../service/user/rolePermissionService"; /** * @description Check authentication status by token diff --git a/src/controller/inviteController.ts b/src/controller/inviteController.ts index bb08cd6..544aa14 100644 --- a/src/controller/inviteController.ts +++ b/src/controller/inviteController.ts @@ -7,18 +7,18 @@ import { CreateRefreshCommand } from "../command/refreshCommand"; import speakeasy from "speakeasy"; import UnauthorizedRequestException from "../exceptions/unauthorizedRequestException"; import QRCode from "qrcode"; -import { CreateUserCommand } from "../command/userCommand"; -import UserCommandHandler from "../command/userCommandHandler"; -import { CreateInviteCommand, DeleteInviteCommand } from "../command/inviteCommand"; -import InviteCommandHandler from "../command/inviteCommandHandler"; +import { CreateUserCommand } from "../command/user/user/userCommand"; +import UserCommandHandler from "../command/user/user/userCommandHandler"; +import { CreateInviteCommand, DeleteInviteCommand } from "../command/user/user/inviteCommand"; +import InviteCommandHandler from "../command/user/user/inviteCommandHandler"; import MailHelper from "../helpers/mailHelper"; -import InviteService from "../service/inviteService"; -import UserService from "../service/userService"; +import InviteService from "../service/user/inviteService"; +import UserService from "../service/user/userService"; import CustomRequestException from "../exceptions/customRequestException"; import { CLUB_NAME } from "../env.defaults"; -import { CreateUserPermissionCommand } from "../command/userPermissionCommand"; -import UserPermissionCommandHandler from "../command/userPermissionCommandHandler"; -import InviteFactory from "../factory/admin/invite"; +import { CreateUserPermissionCommand } from "../command/user/user/userPermissionCommand"; +import UserPermissionCommandHandler from "../command/user/user/userPermissionCommandHandler"; +import InviteFactory from "../factory/admin/user/invite"; /** * @description get all invites diff --git a/src/controller/publicController.ts b/src/controller/publicController.ts index d933522..b3bf2b0 100644 --- a/src/controller/publicController.ts +++ b/src/controller/publicController.ts @@ -1,11 +1,11 @@ import { Request, Response } from "express"; -import CalendarService from "../service/calendarService"; -import CalendarTypeService from "../service/calendarTypeService"; -import { calendar } from "../entity/calendar"; +import CalendarService from "../service/club/calendarService"; +import CalendarTypeService from "../service/settings/calendarTypeService"; +import { calendar } from "../entity/club/calendar"; import { createEvents } from "ics"; import moment from "moment"; import InternalException from "../exceptions/internalException"; -import CalendarFactory from "../factory/admin/calendar"; +import CalendarFactory from "../factory/admin/club/calendar"; import { CalendarHelper } from "../helpers/calendarHelper"; /** diff --git a/src/controller/resetController.ts b/src/controller/resetController.ts index fe0554c..eec65b4 100644 --- a/src/controller/resetController.ts +++ b/src/controller/resetController.ts @@ -11,13 +11,13 @@ import { CreateResetCommand, DeleteResetCommand } from "../command/resetCommand" import ResetCommandHandler from "../command/resetCommandHandler"; import MailHelper from "../helpers/mailHelper"; import ResetService from "../service/resetService"; -import UserService from "../service/userService"; +import UserService from "../service/user/userService"; import { CLUB_NAME } from "../env.defaults"; import PermissionHelper from "../helpers/permissionHelper"; -import RolePermissionService from "../service/rolePermissionService"; -import UserPermissionService from "../service/userPermissionService"; -import { UpdateUserSecretCommand } from "../command/userCommand"; -import UserCommandHandler from "../command/userCommandHandler"; +import RolePermissionService from "../service/user/rolePermissionService"; +import UserPermissionService from "../service/user/userPermissionService"; +import { UpdateUserSecretCommand } from "../command/user/user/userCommand"; +import UserCommandHandler from "../command/user/user/userCommandHandler"; /** * @description request totp reset diff --git a/src/controller/userController.ts b/src/controller/userController.ts index ebea67a..a29487b 100644 --- a/src/controller/userController.ts +++ b/src/controller/userController.ts @@ -3,10 +3,10 @@ import speakeasy from "speakeasy"; import QRCode from "qrcode"; import InternalException from "../exceptions/internalException"; import { CLUB_NAME } from "../env.defaults"; -import UserService from "../service/userService"; -import UserFactory from "../factory/admin/user"; -import { TransferUserOwnerCommand, UpdateUserCommand } from "../command/userCommand"; -import UserCommandHandler from "../command/userCommandHandler"; +import UserService from "../service/user/userService"; +import UserFactory from "../factory/admin/user/user"; +import { TransferUserOwnerCommand, UpdateUserCommand } from "../command/user/user/userCommand"; +import UserCommandHandler from "../command/user/user/userCommandHandler"; import ForbiddenRequestException from "../exceptions/forbiddenRequestException"; /** diff --git a/src/data-source.ts b/src/data-source.ts index 8074d2d..7af52a0 100644 --- a/src/data-source.ts +++ b/src/data-source.ts @@ -3,18 +3,18 @@ import "reflect-metadata"; import { DataSource } from "typeorm"; import { DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME, DB_TYPE } from "./env.defaults"; -import { user } from "./entity/user"; +import { user } from "./entity/user/user"; import { refresh } from "./entity/refresh"; -import { invite } from "./entity/invite"; -import { userPermission } from "./entity/user_permission"; -import { role } from "./entity/role"; -import { rolePermission } from "./entity/role_permission"; -import { award } from "./entity/award"; -import { communication } from "./entity/communication"; -import { communicationType } from "./entity/communicationType"; -import { executivePosition } from "./entity/executivePosition"; -import { membershipStatus } from "./entity/membershipStatus"; -import { qualification } from "./entity/qualification"; +import { invite } from "./entity/user/invite"; +import { userPermission } from "./entity/user/user_permission"; +import { role } from "./entity/user/role"; +import { rolePermission } from "./entity/user/role_permission"; +import { award } from "./entity/settings/award"; +import { communication } from "./entity/club/member/communication"; +import { communicationType } from "./entity/settings/communicationType"; +import { executivePosition } from "./entity/settings/executivePosition"; +import { membershipStatus } from "./entity/settings/membershipStatus"; +import { qualification } from "./entity/settings/qualification"; import { Initial1724317398939 } from "./migrations/1724317398939-initial"; import { RefreshPrimaryChange1724573307851 } from "./migrations/1724573307851-refreshPrimaryChange"; @@ -22,48 +22,50 @@ import { Invite1724579024939 } from "./migrations/1724579024939-invite"; import { Permissions1724661484664 } from "./migrations/1724661484664-permissions"; import { RolePermission1724771491085 } from "./migrations/1724771491085-role_permission"; import { MemberBaseData1725435669492 } from "./migrations/1725435669492-member_base_data"; -import { member } from "./entity/member"; -import { memberAwards } from "./entity/memberAwards"; -import { memberExecutivePositions } from "./entity/memberExecutivePositions"; -import { memberQualifications } from "./entity/memberQualifications"; -import { membership } from "./entity/membership"; +import { member } from "./entity/club/member/member"; +import { memberAwards } from "./entity/club/member/memberAwards"; +import { memberExecutivePositions } from "./entity/club/member/memberExecutivePositions"; +import { memberQualifications } from "./entity/club/member/memberQualifications"; +import { membership } from "./entity/club/member/membership"; import { Memberdata1726301836849 } from "./migrations/1726301836849-memberdata"; import { CommunicationFields1727439800630 } from "./migrations/1727439800630-communicationFields"; import { Ownership1728313041449 } from "./migrations/1728313041449-ownership"; -import { protocol } from "./entity/protocol"; -import { protocolAgenda } from "./entity/protocolAgenda"; -import { protocolDecision } from "./entity/protocolDecision"; -import { protocolPresence } from "./entity/protocolPresence"; -import { protocolVoting } from "./entity/protocolVoting"; -import { protocolPrintout } from "./entity/protocolPrintout"; +import { protocol } from "./entity/club/protocol/protocol"; +import { protocolAgenda } from "./entity/club/protocol/protocolAgenda"; +import { protocolDecision } from "./entity/club/protocol/protocolDecision"; +import { protocolPresence } from "./entity/club/protocol/protocolPresence"; +import { protocolVoting } from "./entity/club/protocol/protocolVoting"; +import { protocolPrintout } from "./entity/club/protocol/protocolPrintout"; import { Protocol1729347911107 } from "./migrations/1729347911107-protocol"; -import { calendar } from "./entity/calendar"; -import { calendarType } from "./entity/calendarType"; +import { calendar } from "./entity/club/calendar"; +import { calendarType } from "./entity/settings/calendarType"; import { Calendar1729947763295 } from "./migrations/1729947763295-calendar"; import { reset } from "./entity/reset"; import { ResetToken1732358596823 } from "./migrations/1732358596823-resetToken"; import { SMSAlarming1732696919191 } from "./migrations/1732696919191-SMSAlarming"; import { SecuringCalendarType1733249553766 } from "./migrations/1733249553766-securingCalendarType"; -import { query } from "./entity/query"; +import { query } from "./entity/settings/query"; import { QueryStore1734187754677 } from "./migrations/1734187754677-queryStore"; import { memberView } from "./views/memberView"; import { memberExecutivePositionsView } from "./views/memberExecutivePositionView"; import { memberQualificationsView } from "./views/memberQualificationsView"; import { membershipView } from "./views/membershipsView"; import { MemberDataViews1734520998539 } from "./migrations/1734520998539-memberDataViews"; -import { template } from "./entity/template"; +import { template } from "./entity/settings/template"; import { Template1734854680201 } from "./migrations/1734854680201-template"; -import { templateUsage } from "./entity/templateUsage"; +import { templateUsage } from "./entity/settings/templateUsage"; import { TemplateUsage1734949173739 } from "./migrations/1734949173739-templateUsage"; -import { newsletter } from "./entity/newsletter"; -import { newsletterDates } from "./entity/newsletterDates"; -import { newsletterRecipients } from "./entity/newsletterRecipients"; +import { newsletter } from "./entity/club/newsletter/newsletter"; +import { newsletterDates } from "./entity/club/newsletter/newsletterDates"; +import { newsletterRecipients } from "./entity/club/newsletter/newsletterRecipients"; import { Newsletter1735118780511 } from "./migrations/1735118780511-newsletter"; -import { newsletterConfig } from "./entity/newsletterConfig"; +import { newsletterConfig } from "./entity/settings/newsletterConfig"; import { NewsletterConfig1735207446910 } from "./migrations/1735207446910-newsletterConfig"; -import { TemplateMargins1735733514043 } from "./migrations/1735733514043-templateMargins"; import { InternalId1735822722235 } from "./migrations/1735822722235-internalId"; import { PostalCode1735927918979 } from "./migrations/1735927918979-postalCode"; +import { ProtocolAbsent1736072179716 } from "./migrations/1736072179716-protocolAbsent"; +import { Memberlist1736079005086 } from "./migrations/1736079005086-memberlist"; +import { ExtendViewValues1736084198860 } from "./migrations/1736084198860-extendViewValues"; const dataSource = new DataSource({ type: DB_TYPE as any, @@ -135,9 +137,11 @@ const dataSource = new DataSource({ TemplateUsage1734949173739, Newsletter1735118780511, NewsletterConfig1735207446910, - TemplateMargins1735733514043, InternalId1735822722235, PostalCode1735927918979, + ProtocolAbsent1736072179716, + Memberlist1736079005086, + ExtendViewValues1736084198860, ], migrationsRun: true, migrationsTransactionMode: "each", diff --git a/src/demodata/member.list.data.ts b/src/demodata/member.list.data.ts new file mode 100644 index 0000000..7244fd9 --- /dev/null +++ b/src/demodata/member.list.data.ts @@ -0,0 +1,13 @@ +import { member } from "../entity/club/member/member"; +import { protocolAgenda } from "../entity/club/protocol/protocolAgenda"; +import { protocolDecision } from "../entity/club/protocol/protocolDecision"; +import { protocolVoting } from "../entity/club/protocol/protocolVoting"; + +export const memberlistDemoData: { member: Array> } = { + member: [ + { + firstname: "Julian", + lastname: "Krauser", + }, + ] +} diff --git a/src/demodata/newsletter.data.ts b/src/demodata/newsletter.data.ts index 41a81f4..8729264 100644 --- a/src/demodata/newsletter.data.ts +++ b/src/demodata/newsletter.data.ts @@ -1,5 +1,5 @@ -import { calendar } from "../entity/calendar"; -import { member } from "../entity/member"; +import { calendar } from "../entity/club/calendar"; +import { member } from "../entity/club/member/member"; import { Salutation } from "../enums/salutation"; export const newsletterDemoData: { diff --git a/src/demodata/protocol.data.ts b/src/demodata/protocol.data.ts index 1feeace..8d18b2a 100644 --- a/src/demodata/protocol.data.ts +++ b/src/demodata/protocol.data.ts @@ -1,7 +1,7 @@ -import { member } from "../entity/member"; -import { protocolAgenda } from "../entity/protocolAgenda"; -import { protocolDecision } from "../entity/protocolDecision"; -import { protocolVoting } from "../entity/protocolVoting"; +import { member } from "../entity/club/member/member"; +import { protocolAgenda } from "../entity/club/protocol/protocolAgenda"; +import { protocolDecision } from "../entity/club/protocol/protocolDecision"; +import { protocolVoting } from "../entity/club/protocol/protocolVoting"; export const protocolDemoData: { title: string; @@ -13,6 +13,7 @@ export const protocolDemoData: { agenda: Array>; decisions: Array>; presence: Array>; + absent: Array>; votings: Array>; } = { title: "Beispiel Protokoll Daten", @@ -44,6 +45,7 @@ export const protocolDemoData: { lastname: "Krauser", }, ], + absent: [], votings: [ { topic: "Abstimmung xy", diff --git a/src/entity/calendar.ts b/src/entity/club/calendar.ts similarity index 94% rename from src/entity/calendar.ts rename to src/entity/club/calendar.ts index 041a998..c8c2cb6 100644 --- a/src/entity/calendar.ts +++ b/src/entity/club/calendar.ts @@ -9,7 +9,7 @@ import { AfterUpdate, BeforeUpdate, } from "typeorm"; -import { calendarType } from "./calendarType"; +import { calendarType } from "../settings/calendarType"; @Entity() export class calendar { diff --git a/src/entity/communication.ts b/src/entity/club/member/communication.ts similarity index 95% rename from src/entity/communication.ts rename to src/entity/club/member/communication.ts index df081be..42b1bd7 100644 --- a/src/entity/communication.ts +++ b/src/entity/club/member/communication.ts @@ -1,6 +1,6 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { member } from "./member"; -import { communicationType } from "./communicationType"; +import { communicationType } from "../../settings/communicationType"; @Entity() export class communication { diff --git a/src/entity/member.ts b/src/entity/club/member/member.ts similarity index 92% rename from src/entity/member.ts rename to src/entity/club/member/member.ts index 6fef6cf..1defb1f 100644 --- a/src/entity/member.ts +++ b/src/entity/club/member/member.ts @@ -1,11 +1,11 @@ import { Column, Entity, JoinColumn, ManyToOne, OneToMany, OneToOne, PrimaryColumn } from "typeorm"; -import { Salutation } from "../enums/salutation"; +import { Salutation } from "../../../enums/salutation"; import { membership } from "./membership"; import { memberAwards } from "./memberAwards"; import { memberQualifications } from "./memberQualifications"; import { memberExecutivePositions } from "./memberExecutivePositions"; import { communication } from "./communication"; -import { CommunicationViewModel } from "../viewmodel/admin/communication.models"; +import { CommunicationViewModel } from "../../../viewmodel/admin/club/member/communication.models"; @Entity() export class member { diff --git a/src/entity/memberAwards.ts b/src/entity/club/member/memberAwards.ts similarity index 94% rename from src/entity/memberAwards.ts rename to src/entity/club/member/memberAwards.ts index e25420e..ef5b473 100644 --- a/src/entity/memberAwards.ts +++ b/src/entity/club/member/memberAwards.ts @@ -1,6 +1,6 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { member } from "./member"; -import { award } from "./award"; +import { award } from "../../settings/award"; @Entity() export class memberAwards { diff --git a/src/entity/memberExecutivePositions.ts b/src/entity/club/member/memberExecutivePositions.ts similarity index 92% rename from src/entity/memberExecutivePositions.ts rename to src/entity/club/member/memberExecutivePositions.ts index fea07e9..b4475ef 100644 --- a/src/entity/memberExecutivePositions.ts +++ b/src/entity/club/member/memberExecutivePositions.ts @@ -1,6 +1,6 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { member } from "./member"; -import { executivePosition } from "./executivePosition"; +import { executivePosition } from "../../settings/executivePosition"; @Entity() export class memberExecutivePositions { diff --git a/src/entity/memberQualifications.ts b/src/entity/club/member/memberQualifications.ts similarity index 93% rename from src/entity/memberQualifications.ts rename to src/entity/club/member/memberQualifications.ts index bbc67e9..c4d7d09 100644 --- a/src/entity/memberQualifications.ts +++ b/src/entity/club/member/memberQualifications.ts @@ -1,6 +1,6 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { member } from "./member"; -import { qualification } from "./qualification"; +import { qualification } from "../../settings/qualification"; @Entity() export class memberQualifications { diff --git a/src/entity/membership.ts b/src/entity/club/member/membership.ts similarity index 93% rename from src/entity/membership.ts rename to src/entity/club/member/membership.ts index 51801cb..9ed2e3a 100644 --- a/src/entity/membership.ts +++ b/src/entity/club/member/membership.ts @@ -1,6 +1,6 @@ import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm"; import { member } from "./member"; -import { membershipStatus } from "./membershipStatus"; +import { membershipStatus } from "../../settings/membershipStatus"; @Entity() export class membership { diff --git a/src/entity/newsletter.ts b/src/entity/club/newsletter/newsletter.ts similarity index 92% rename from src/entity/newsletter.ts rename to src/entity/club/newsletter/newsletter.ts index 9393e53..021ce23 100644 --- a/src/entity/newsletter.ts +++ b/src/entity/club/newsletter/newsletter.ts @@ -1,8 +1,8 @@ import { Column, Entity, ManyToOne, OneToMany, PrimaryColumn } from "typeorm"; import { newsletterDates } from "./newsletterDates"; -import { member } from "./member"; +import { member } from "../member/member"; import { newsletterRecipients } from "./newsletterRecipients"; -import { query } from "./query"; +import { query } from "../../settings/query"; @Entity() export class newsletter { diff --git a/src/entity/newsletterDates.ts b/src/entity/club/newsletter/newsletterDates.ts similarity index 94% rename from src/entity/newsletterDates.ts rename to src/entity/club/newsletter/newsletterDates.ts index aefb8ee..700400f 100644 --- a/src/entity/newsletterDates.ts +++ b/src/entity/club/newsletter/newsletterDates.ts @@ -1,6 +1,6 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { newsletter } from "./newsletter"; -import { calendar } from "./calendar"; +import { calendar } from "../calendar"; @Entity() export class newsletterDates { diff --git a/src/entity/newsletterRecipients.ts b/src/entity/club/newsletter/newsletterRecipients.ts similarity index 93% rename from src/entity/newsletterRecipients.ts rename to src/entity/club/newsletter/newsletterRecipients.ts index b57bce4..21f696f 100644 --- a/src/entity/newsletterRecipients.ts +++ b/src/entity/club/newsletter/newsletterRecipients.ts @@ -1,6 +1,6 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { newsletter } from "./newsletter"; -import { member } from "./member"; +import { member } from "../member/member"; @Entity() export class newsletterRecipients { diff --git a/src/entity/protocol.ts b/src/entity/club/protocol/protocol.ts similarity index 100% rename from src/entity/protocol.ts rename to src/entity/club/protocol/protocol.ts diff --git a/src/entity/protocolAgenda.ts b/src/entity/club/protocol/protocolAgenda.ts similarity index 100% rename from src/entity/protocolAgenda.ts rename to src/entity/club/protocol/protocolAgenda.ts diff --git a/src/entity/protocolDecision.ts b/src/entity/club/protocol/protocolDecision.ts similarity index 100% rename from src/entity/protocolDecision.ts rename to src/entity/club/protocol/protocolDecision.ts diff --git a/src/entity/protocolPresence.ts b/src/entity/club/protocol/protocolPresence.ts similarity index 81% rename from src/entity/protocolPresence.ts rename to src/entity/club/protocol/protocolPresence.ts index 5d80b10..ef7f0cb 100644 --- a/src/entity/protocolPresence.ts +++ b/src/entity/club/protocol/protocolPresence.ts @@ -1,6 +1,6 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { protocol } from "./protocol"; -import { member } from "./member"; +import { member } from "../member/member"; @Entity() export class protocolPresence { @@ -10,6 +10,9 @@ export class protocolPresence { @PrimaryColumn() protocolId: number; + @Column({ type: "boolean", default: false }) + absent: boolean; + @ManyToOne(() => member, { nullable: false, onDelete: "CASCADE", diff --git a/src/entity/protocolPrintout.ts b/src/entity/club/protocol/protocolPrintout.ts similarity index 100% rename from src/entity/protocolPrintout.ts rename to src/entity/club/protocol/protocolPrintout.ts diff --git a/src/entity/protocolVoting.ts b/src/entity/club/protocol/protocolVoting.ts similarity index 100% rename from src/entity/protocolVoting.ts rename to src/entity/club/protocol/protocolVoting.ts diff --git a/src/entity/refresh.ts b/src/entity/refresh.ts index bf99f21..560d7c2 100644 --- a/src/entity/refresh.ts +++ b/src/entity/refresh.ts @@ -1,5 +1,5 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; -import { user } from "./user"; +import { user } from "./user/user"; @Entity() export class refresh { diff --git a/src/entity/award.ts b/src/entity/settings/award.ts similarity index 84% rename from src/entity/award.ts rename to src/entity/settings/award.ts index cf26689..74d5260 100644 --- a/src/entity/award.ts +++ b/src/entity/settings/award.ts @@ -1,5 +1,5 @@ import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; -import { memberAwards } from "./memberAwards"; +import { memberAwards } from "../club/member/memberAwards"; @Entity() export class award { diff --git a/src/entity/calendarType.ts b/src/entity/settings/calendarType.ts similarity index 93% rename from src/entity/calendarType.ts rename to src/entity/settings/calendarType.ts index 0214117..1e99e26 100644 --- a/src/entity/calendarType.ts +++ b/src/entity/settings/calendarType.ts @@ -1,5 +1,5 @@ import { Column, Entity, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm"; -import { calendar } from "./calendar"; +import { calendar } from "../club/calendar"; @Entity() export class calendarType { diff --git a/src/entity/communicationType.ts b/src/entity/settings/communicationType.ts similarity index 90% rename from src/entity/communicationType.ts rename to src/entity/settings/communicationType.ts index c9161df..1c81be5 100644 --- a/src/entity/communicationType.ts +++ b/src/entity/settings/communicationType.ts @@ -1,6 +1,6 @@ import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; -import { communication } from "./communication"; -import { CommunicationFieldType, communicationFieldTypes } from "../type/fieldTypes"; +import { communication } from "../club/member/communication"; +import { CommunicationFieldType, communicationFieldTypes } from "../../type/fieldTypes"; @Entity() export class communicationType { diff --git a/src/entity/executivePosition.ts b/src/entity/settings/executivePosition.ts similarity index 82% rename from src/entity/executivePosition.ts rename to src/entity/settings/executivePosition.ts index e88cea2..8d77bf7 100644 --- a/src/entity/executivePosition.ts +++ b/src/entity/settings/executivePosition.ts @@ -1,5 +1,5 @@ import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; -import { memberExecutivePositions } from "./memberExecutivePositions"; +import { memberExecutivePositions } from "../club/member/memberExecutivePositions"; @Entity() export class executivePosition { diff --git a/src/entity/membershipStatus.ts b/src/entity/settings/membershipStatus.ts similarity index 86% rename from src/entity/membershipStatus.ts rename to src/entity/settings/membershipStatus.ts index 980d88b..4362171 100644 --- a/src/entity/membershipStatus.ts +++ b/src/entity/settings/membershipStatus.ts @@ -1,5 +1,5 @@ import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; -import { membership } from "./membership"; +import { membership } from "../club/member/membership"; @Entity() export class membershipStatus { diff --git a/src/entity/newsletterConfig.ts b/src/entity/settings/newsletterConfig.ts similarity index 90% rename from src/entity/newsletterConfig.ts rename to src/entity/settings/newsletterConfig.ts index 6ad74ab..ae335ce 100644 --- a/src/entity/newsletterConfig.ts +++ b/src/entity/settings/newsletterConfig.ts @@ -1,5 +1,5 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; -import { NewsletterConfigType } from "../enums/newsletterConfigType"; +import { NewsletterConfigType } from "../../enums/newsletterConfigType"; import { communicationType } from "./communicationType"; @Entity() diff --git a/src/entity/qualification.ts b/src/entity/settings/qualification.ts similarity index 86% rename from src/entity/qualification.ts rename to src/entity/settings/qualification.ts index 513a31f..8e76ff8 100644 --- a/src/entity/qualification.ts +++ b/src/entity/settings/qualification.ts @@ -1,5 +1,5 @@ import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; -import { memberQualifications } from "./memberQualifications"; +import { memberQualifications } from "../club/member/memberQualifications"; @Entity() export class qualification { diff --git a/src/entity/query.ts b/src/entity/settings/query.ts similarity index 100% rename from src/entity/query.ts rename to src/entity/settings/query.ts diff --git a/src/entity/template.ts b/src/entity/settings/template.ts similarity index 100% rename from src/entity/template.ts rename to src/entity/settings/template.ts diff --git a/src/entity/templateUsage.ts b/src/entity/settings/templateUsage.ts similarity index 88% rename from src/entity/templateUsage.ts rename to src/entity/settings/templateUsage.ts index 00f41bf..1b487f4 100644 --- a/src/entity/templateUsage.ts +++ b/src/entity/settings/templateUsage.ts @@ -1,11 +1,11 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { template } from "./template"; -import { PermissionModule } from "../type/permissionTypes"; +import { PermissionModule } from "../../type/permissionTypes"; @Entity() export class templateUsage { @PrimaryColumn({ type: "varchar", length: 255 }) - scope: PermissionModule; + scope: `${PermissionModule}`|`${PermissionModule}.${string}`; @Column({ type: "int", nullable: true }) headerId: number | null; diff --git a/src/entity/invite.ts b/src/entity/user/invite.ts similarity index 100% rename from src/entity/invite.ts rename to src/entity/user/invite.ts diff --git a/src/entity/role.ts b/src/entity/user/role.ts similarity index 100% rename from src/entity/role.ts rename to src/entity/user/role.ts diff --git a/src/entity/role_permission.ts b/src/entity/user/role_permission.ts similarity index 86% rename from src/entity/role_permission.ts rename to src/entity/user/role_permission.ts index c1d7d4d..68d4331 100644 --- a/src/entity/role_permission.ts +++ b/src/entity/user/role_permission.ts @@ -1,5 +1,5 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; -import { PermissionString } from "../type/permissionTypes"; +import { PermissionString } from "../../type/permissionTypes"; import { role } from "./role"; @Entity() diff --git a/src/entity/user.ts b/src/entity/user/user.ts similarity index 100% rename from src/entity/user.ts rename to src/entity/user/user.ts diff --git a/src/entity/user_permission.ts b/src/entity/user/user_permission.ts similarity index 83% rename from src/entity/user_permission.ts rename to src/entity/user/user_permission.ts index 34e6cf5..7d782ae 100644 --- a/src/entity/user_permission.ts +++ b/src/entity/user/user_permission.ts @@ -1,6 +1,6 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { user } from "./user"; -import { PermissionObject, PermissionString } from "../type/permissionTypes"; +import { PermissionObject, PermissionString } from "../../type/permissionTypes"; @Entity() export class userPermission { diff --git a/src/factory/admin/calendar.ts b/src/factory/admin/club/calendar.ts similarity index 81% rename from src/factory/admin/calendar.ts rename to src/factory/admin/club/calendar.ts index aa29be2..33eb7f2 100644 --- a/src/factory/admin/calendar.ts +++ b/src/factory/admin/club/calendar.ts @@ -1,6 +1,6 @@ -import { calendar } from "../../entity/calendar"; -import { CalendarViewModel } from "../../viewmodel/admin/calendar.models"; -import CalendarTypeFactory from "./calendarType"; +import { calendar } from "../../../entity/club/calendar"; +import { CalendarViewModel } from "../../../viewmodel/admin/club/calendar.models"; +import CalendarTypeFactory from "../settings/calendarType"; export default abstract class CalendarFactory { /** diff --git a/src/factory/admin/communication.ts b/src/factory/admin/club/member/communication.ts similarity index 81% rename from src/factory/admin/communication.ts rename to src/factory/admin/club/member/communication.ts index 79b5f8a..702cfc5 100644 --- a/src/factory/admin/communication.ts +++ b/src/factory/admin/club/member/communication.ts @@ -1,6 +1,6 @@ -import { communication } from "../../entity/communication"; -import { CommunicationViewModel } from "../../viewmodel/admin/communication.models"; -import CommunicationTypeFactory from "./communicationType"; +import { communication } from "../../../../entity/club/member/communication"; +import { CommunicationViewModel } from "../../../../viewmodel/admin/club/member/communication.models"; +import CommunicationTypeFactory from "../../settings/communicationType"; export default abstract class CommunicationFactory { /** diff --git a/src/factory/admin/member.ts b/src/factory/admin/club/member/member.ts similarity index 90% rename from src/factory/admin/member.ts rename to src/factory/admin/club/member/member.ts index 01419e8..42faf7c 100644 --- a/src/factory/admin/member.ts +++ b/src/factory/admin/club/member/member.ts @@ -1,5 +1,5 @@ -import { member } from "../../entity/member"; -import { MemberViewModel } from "../../viewmodel/admin/member.models"; +import { member } from "../../../../entity/club/member/member"; +import { MemberViewModel } from "../../../../viewmodel/admin/club/member/member.models"; import CommunicationFactory from "./communication"; import MembershipFactory from "./membership"; diff --git a/src/factory/admin/memberAward.ts b/src/factory/admin/club/member/memberAward.ts similarity index 80% rename from src/factory/admin/memberAward.ts rename to src/factory/admin/club/member/memberAward.ts index 756eaf3..6161da2 100644 --- a/src/factory/admin/memberAward.ts +++ b/src/factory/admin/club/member/memberAward.ts @@ -1,5 +1,5 @@ -import { memberAwards } from "../../entity/memberAwards"; -import { MemberAwardViewModel } from "../../viewmodel/admin/memberAward.models"; +import { memberAwards } from "../../../../entity/club/member/memberAwards"; +import { MemberAwardViewModel } from "../../../../viewmodel/admin/club/member/memberAward.models"; export default abstract class MemberAwardFactory { /** diff --git a/src/factory/admin/memberExecutivePosition.ts b/src/factory/admin/club/member/memberExecutivePosition.ts similarity index 80% rename from src/factory/admin/memberExecutivePosition.ts rename to src/factory/admin/club/member/memberExecutivePosition.ts index 71655e5..166d881 100644 --- a/src/factory/admin/memberExecutivePosition.ts +++ b/src/factory/admin/club/member/memberExecutivePosition.ts @@ -1,5 +1,5 @@ -import { memberExecutivePositions } from "../../entity/memberExecutivePositions"; -import { MemberExecutivePositionViewModel } from "../../viewmodel/admin/memberExecutivePosition.models"; +import { memberExecutivePositions } from "../../../../entity/club/member/memberExecutivePositions"; +import { MemberExecutivePositionViewModel } from "../../../../viewmodel/admin/club/member/memberExecutivePosition.models"; export default abstract class MemberExecutivePositionFactory { /** diff --git a/src/factory/admin/memberQualification.ts b/src/factory/admin/club/member/memberQualification.ts similarity index 81% rename from src/factory/admin/memberQualification.ts rename to src/factory/admin/club/member/memberQualification.ts index 917f78f..730dda7 100644 --- a/src/factory/admin/memberQualification.ts +++ b/src/factory/admin/club/member/memberQualification.ts @@ -1,5 +1,5 @@ -import { memberQualifications } from "../../entity/memberQualifications"; -import { MemberQualificationViewModel } from "../../viewmodel/admin/memberQualification.models"; +import { memberQualifications } from "../../../../entity/club/member/memberQualifications"; +import { MemberQualificationViewModel } from "../../../../viewmodel/admin/club/member/memberQualification.models"; export default abstract class MemberQualificationFactory { /** diff --git a/src/factory/admin/membership.ts b/src/factory/admin/club/member/membership.ts similarity index 81% rename from src/factory/admin/membership.ts rename to src/factory/admin/club/member/membership.ts index 2a711c4..8736785 100644 --- a/src/factory/admin/membership.ts +++ b/src/factory/admin/club/member/membership.ts @@ -1,5 +1,5 @@ -import { membership } from "../../entity/membership"; -import { MembershipViewModel } from "../../viewmodel/admin/membership.models"; +import { membership } from "../../../../entity/club/member/membership"; +import { MembershipViewModel } from "../../../../viewmodel/admin/club/member/membership.models"; export default abstract class MembershipFactory { /** diff --git a/src/factory/admin/newsletter.ts b/src/factory/admin/club/newsletter/newsletter.ts similarity index 81% rename from src/factory/admin/newsletter.ts rename to src/factory/admin/club/newsletter/newsletter.ts index d734564..dff2de4 100644 --- a/src/factory/admin/newsletter.ts +++ b/src/factory/admin/club/newsletter/newsletter.ts @@ -1,6 +1,6 @@ -import { newsletter } from "../../entity/newsletter"; -import { NewsletterViewModel } from "../../viewmodel/admin/newsletter.models"; -import QueryStoreFactory from "./queryStore"; +import { newsletter } from "../../../../entity/club/newsletter/newsletter"; +import { NewsletterViewModel } from "../../../../viewmodel/admin/club/newsletter/newsletter.models"; +import QueryStoreFactory from "../../settings/queryStore"; export default abstract class NewsletterFactory { /** diff --git a/src/factory/admin/newsletterDates.ts b/src/factory/admin/club/newsletter/newsletterDates.ts similarity index 74% rename from src/factory/admin/newsletterDates.ts rename to src/factory/admin/club/newsletter/newsletterDates.ts index 232e7ac..8474a47 100644 --- a/src/factory/admin/newsletterDates.ts +++ b/src/factory/admin/club/newsletter/newsletterDates.ts @@ -1,7 +1,7 @@ -import { newsletterDates } from "../../entity/newsletterDates"; -import { NewsletterDatesViewModel } from "../../viewmodel/admin/newsletterDates.models"; -import CalendarFactory from "./calendar"; -import MemberFactory from "./member"; +import { newsletterDates } from "../../../../entity/club/newsletter/newsletterDates"; +import { NewsletterDatesViewModel } from "../../../../viewmodel/admin/club/newsletter/newsletterDates.models"; +import CalendarFactory from "../calendar"; +import MemberFactory from "../member/member"; export default abstract class NewsletterDatesFactory { /** diff --git a/src/factory/admin/newsletterRecipients.ts b/src/factory/admin/club/newsletter/newsletterRecipients.ts similarity index 75% rename from src/factory/admin/newsletterRecipients.ts rename to src/factory/admin/club/newsletter/newsletterRecipients.ts index 9a1e332..eb62681 100644 --- a/src/factory/admin/newsletterRecipients.ts +++ b/src/factory/admin/club/newsletter/newsletterRecipients.ts @@ -1,6 +1,6 @@ -import { newsletterRecipients } from "../../entity/newsletterRecipients"; -import { NewsletterRecipientsViewModel } from "../../viewmodel/admin/newsletterRecipients.models"; -import MemberFactory from "./member"; +import { newsletterRecipients } from "../../../../entity/club/newsletter/newsletterRecipients"; +import { NewsletterRecipientsViewModel } from "../../../../viewmodel/admin/club/newsletter/newsletterRecipients.models"; +import MemberFactory from "../member/member"; export default abstract class NewsletterRecipientsFactory { /** diff --git a/src/factory/admin/protocol.ts b/src/factory/admin/club/protocol/protocol.ts similarity index 80% rename from src/factory/admin/protocol.ts rename to src/factory/admin/club/protocol/protocol.ts index 9b86894..9e90df7 100644 --- a/src/factory/admin/protocol.ts +++ b/src/factory/admin/club/protocol/protocol.ts @@ -1,5 +1,5 @@ -import { protocol } from "../../entity/protocol"; -import { ProtocolViewModel } from "../../viewmodel/admin/protocol.models"; +import { protocol } from "../../../../entity/club/protocol/protocol"; +import { ProtocolViewModel } from "../../../../viewmodel/admin/club/protocol/protocol.models"; export default abstract class ProtocolFactory { /** diff --git a/src/factory/admin/protocolAgenda.ts b/src/factory/admin/club/protocol/protocolAgenda.ts similarity index 78% rename from src/factory/admin/protocolAgenda.ts rename to src/factory/admin/club/protocol/protocolAgenda.ts index 432c479..aa15b75 100644 --- a/src/factory/admin/protocolAgenda.ts +++ b/src/factory/admin/club/protocol/protocolAgenda.ts @@ -1,5 +1,5 @@ -import { protocolAgenda } from "../../entity/protocolAgenda"; -import { ProtocolAgendaViewModel } from "../../viewmodel/admin/protocolAgenda.models"; +import { protocolAgenda } from "../../../../entity/club/protocol/protocolAgenda"; +import { ProtocolAgendaViewModel } from "../../../../viewmodel/admin/club/protocol/protocolAgenda.models"; export default abstract class ProtocolAgendaFactory { /** diff --git a/src/factory/admin/protocolDecision.ts b/src/factory/admin/club/protocol/protocolDecision.ts similarity index 78% rename from src/factory/admin/protocolDecision.ts rename to src/factory/admin/club/protocol/protocolDecision.ts index 3e33823..0fbfff5 100644 --- a/src/factory/admin/protocolDecision.ts +++ b/src/factory/admin/club/protocol/protocolDecision.ts @@ -1,5 +1,5 @@ -import { protocolDecision } from "../../entity/protocolDecision"; -import { ProtocolDecisionViewModel } from "../../viewmodel/admin/protocolDecision.models"; +import { protocolDecision } from "../../../../entity/club/protocol/protocolDecision"; +import { ProtocolDecisionViewModel } from "../../../../viewmodel/admin/club/protocol/protocolDecision.models"; export default abstract class ProtocolDecisionFactory { /** diff --git a/src/factory/admin/protocolPresence.ts b/src/factory/admin/club/protocol/protocolPresence.ts similarity index 71% rename from src/factory/admin/protocolPresence.ts rename to src/factory/admin/club/protocol/protocolPresence.ts index 59a70ad..37ca37a 100644 --- a/src/factory/admin/protocolPresence.ts +++ b/src/factory/admin/club/protocol/protocolPresence.ts @@ -1,6 +1,6 @@ -import { protocolPresence } from "../../entity/protocolPresence"; -import { ProtocolPresenceViewModel } from "../../viewmodel/admin/protocolPresence.models"; -import MemberFactory from "./member"; +import { protocolPresence } from "../../../../entity/club/protocol/protocolPresence"; +import { ProtocolPresenceViewModel } from "../../../../viewmodel/admin/club/protocol/protocolPresence.models"; +import MemberFactory from "../member/member"; export default abstract class ProtocolPresenceFactory { /** @@ -11,7 +11,7 @@ export default abstract class ProtocolPresenceFactory { public static mapToSingle(record: protocolPresence): ProtocolPresenceViewModel { return { memberId: record.member.id, - member: MemberFactory.mapToSingle(record.member), + absent: record.absent, protocolId: record.protocolId, }; } diff --git a/src/factory/admin/protocolPrintout.ts b/src/factory/admin/club/protocol/protocolPrintout.ts similarity index 79% rename from src/factory/admin/protocolPrintout.ts rename to src/factory/admin/club/protocol/protocolPrintout.ts index a93fad1..8d202a2 100644 --- a/src/factory/admin/protocolPrintout.ts +++ b/src/factory/admin/club/protocol/protocolPrintout.ts @@ -1,5 +1,5 @@ -import { protocolPrintout } from "../../entity/protocolPrintout"; -import { ProtocolPrintoutViewModel } from "../../viewmodel/admin/protocolPrintout.models"; +import { protocolPrintout } from "../../../../entity/club/protocol/protocolPrintout"; +import { ProtocolPrintoutViewModel } from "../../../../viewmodel/admin/club/protocol/protocolPrintout.models"; export default abstract class ProtocolPrintoutFactory { /** diff --git a/src/factory/admin/protocolVoting.ts b/src/factory/admin/club/protocol/protocolVoting.ts similarity index 80% rename from src/factory/admin/protocolVoting.ts rename to src/factory/admin/club/protocol/protocolVoting.ts index 19865fb..2f4fa4e 100644 --- a/src/factory/admin/protocolVoting.ts +++ b/src/factory/admin/club/protocol/protocolVoting.ts @@ -1,5 +1,5 @@ -import { protocolVoting } from "../../entity/protocolVoting"; -import { ProtocolVotingViewModel } from "../../viewmodel/admin/protocolVoting.models"; +import { protocolVoting } from "../../../../entity/club/protocol/protocolVoting"; +import { ProtocolVotingViewModel } from "../../../../viewmodel/admin/club/protocol/protocolVoting.models"; export default abstract class ProtocolVotingFactory { /** diff --git a/src/factory/admin/award.ts b/src/factory/admin/settings/award.ts similarity index 79% rename from src/factory/admin/award.ts rename to src/factory/admin/settings/award.ts index 440e957..3191a4f 100644 --- a/src/factory/admin/award.ts +++ b/src/factory/admin/settings/award.ts @@ -1,5 +1,5 @@ -import { award } from "../../entity/award"; -import { AwardViewModel } from "../../viewmodel/admin/award.models"; +import { award } from "../../../entity/settings/award"; +import { AwardViewModel } from "../../../viewmodel/admin/settings/award.models"; export default abstract class AwardFactory { /** diff --git a/src/factory/admin/calendarType.ts b/src/factory/admin/settings/calendarType.ts similarity index 81% rename from src/factory/admin/calendarType.ts rename to src/factory/admin/settings/calendarType.ts index 25aed4e..2ee7ce2 100644 --- a/src/factory/admin/calendarType.ts +++ b/src/factory/admin/settings/calendarType.ts @@ -1,5 +1,5 @@ -import { calendarType } from "../../entity/calendarType"; -import { CalendarTypeViewModel } from "../../viewmodel/admin/calendarType.models"; +import { calendarType } from "../../../entity/settings/calendarType"; +import { CalendarTypeViewModel } from "../../../viewmodel/admin/settings/calendarType.models"; export default abstract class CalendarTypeFactory { /** diff --git a/src/factory/admin/communicationType.ts b/src/factory/admin/settings/communicationType.ts similarity index 79% rename from src/factory/admin/communicationType.ts rename to src/factory/admin/settings/communicationType.ts index 5ee28ea..5721f0e 100644 --- a/src/factory/admin/communicationType.ts +++ b/src/factory/admin/settings/communicationType.ts @@ -1,5 +1,5 @@ -import { communicationType } from "../../entity/communicationType"; -import { CommunicationTypeViewModel } from "../../viewmodel/admin/communicationType.models"; +import { communicationType } from "../../../entity/settings/communicationType"; +import { CommunicationTypeViewModel } from "../../../viewmodel/admin/settings/communicationType.models"; export default abstract class CommunicationTypeFactory { /** diff --git a/src/factory/admin/executivePosition.ts b/src/factory/admin/settings/executivePosition.ts similarity index 78% rename from src/factory/admin/executivePosition.ts rename to src/factory/admin/settings/executivePosition.ts index 9a1b3b6..5c44bd9 100644 --- a/src/factory/admin/executivePosition.ts +++ b/src/factory/admin/settings/executivePosition.ts @@ -1,5 +1,5 @@ -import { executivePosition } from "../../entity/executivePosition"; -import { ExecutivePositionViewModel } from "../../viewmodel/admin/executivePosition.models"; +import { executivePosition } from "../../../entity/settings/executivePosition"; +import { ExecutivePositionViewModel } from "../../../viewmodel/admin/settings/executivePosition.models"; export default abstract class ExecutivePositionFactory { /** diff --git a/src/factory/admin/membershipStatus.ts b/src/factory/admin/settings/membershipStatus.ts similarity index 78% rename from src/factory/admin/membershipStatus.ts rename to src/factory/admin/settings/membershipStatus.ts index 43a11c2..f45f5b8 100644 --- a/src/factory/admin/membershipStatus.ts +++ b/src/factory/admin/settings/membershipStatus.ts @@ -1,5 +1,5 @@ -import { membershipStatus } from "../../entity/membershipStatus"; -import { MembershipStatusViewModel } from "../../viewmodel/admin/membershipStatus.models"; +import { membershipStatus } from "../../../entity/settings/membershipStatus"; +import { MembershipStatusViewModel } from "../../../viewmodel/admin/settings/membershipStatus.models"; export default abstract class MembershipStatusFactory { /** diff --git a/src/factory/admin/newsletterConfig.ts b/src/factory/admin/settings/newsletterConfig.ts similarity index 82% rename from src/factory/admin/newsletterConfig.ts rename to src/factory/admin/settings/newsletterConfig.ts index 854bd83..f71889e 100644 --- a/src/factory/admin/newsletterConfig.ts +++ b/src/factory/admin/settings/newsletterConfig.ts @@ -1,5 +1,5 @@ -import { newsletterConfig } from "../../entity/newsletterConfig"; -import { NewsletterConfigViewModel } from "../../viewmodel/admin/newsletterConfig.models"; +import { newsletterConfig } from "../../../entity/settings/newsletterConfig"; +import { NewsletterConfigViewModel } from "../../../viewmodel/admin/settings/newsletterConfig.models"; import CommunicationTypeFactory from "./communicationType"; export default abstract class NewsletterConfigFactory { diff --git a/src/factory/admin/qualification.ts b/src/factory/admin/settings/qualification.ts similarity index 79% rename from src/factory/admin/qualification.ts rename to src/factory/admin/settings/qualification.ts index f7edb62..0a6a05f 100644 --- a/src/factory/admin/qualification.ts +++ b/src/factory/admin/settings/qualification.ts @@ -1,5 +1,5 @@ -import { qualification } from "../../entity/qualification"; -import { QualificationViewModel } from "../../viewmodel/admin/qualification.models"; +import { qualification } from "../../../entity/settings/qualification"; +import { QualificationViewModel } from "../../../viewmodel/admin/settings/qualification.models"; export default abstract class QualificationFactory { /** diff --git a/src/factory/admin/queryStore.ts b/src/factory/admin/settings/queryStore.ts similarity index 82% rename from src/factory/admin/queryStore.ts rename to src/factory/admin/settings/queryStore.ts index 7574ab8..067c494 100644 --- a/src/factory/admin/queryStore.ts +++ b/src/factory/admin/settings/queryStore.ts @@ -1,5 +1,5 @@ -import { query } from "../../entity/query"; -import { QueryStoreViewModel } from "../../viewmodel/admin/queryStore.models"; +import { query } from "../../../entity/settings/query"; +import { QueryStoreViewModel } from "../../../viewmodel/admin/settings/queryStore.models"; export default abstract class QueryStoreFactory { /** diff --git a/src/factory/admin/template.ts b/src/factory/admin/settings/template.ts similarity index 81% rename from src/factory/admin/template.ts rename to src/factory/admin/settings/template.ts index 7da05e0..ba87719 100644 --- a/src/factory/admin/template.ts +++ b/src/factory/admin/settings/template.ts @@ -1,5 +1,5 @@ -import { template } from "../../entity/template"; -import { TemplateViewModel } from "../../viewmodel/admin/template.models"; +import { template } from "../../../entity/settings/template"; +import { TemplateViewModel } from "../../../viewmodel/admin/settings/template.models"; export default abstract class TemplateFactory { /** diff --git a/src/factory/admin/templateUsage.ts b/src/factory/admin/settings/templateUsage.ts similarity index 85% rename from src/factory/admin/templateUsage.ts rename to src/factory/admin/settings/templateUsage.ts index 3472d52..a34f50f 100644 --- a/src/factory/admin/templateUsage.ts +++ b/src/factory/admin/settings/templateUsage.ts @@ -1,5 +1,5 @@ -import { templateUsage } from "../../entity/templateUsage"; -import { TemplateUsageViewModel } from "../../viewmodel/admin/templateUsage.models"; +import { templateUsage } from "../../../entity/settings/templateUsage"; +import { TemplateUsageViewModel } from "../../../viewmodel/admin/settings/templateUsage.models"; export default abstract class TemplateUsageFactory { /** diff --git a/src/factory/admin/invite.ts b/src/factory/admin/user/invite.ts similarity index 82% rename from src/factory/admin/invite.ts rename to src/factory/admin/user/invite.ts index a1ac7a7..6aa5647 100644 --- a/src/factory/admin/invite.ts +++ b/src/factory/admin/user/invite.ts @@ -1,5 +1,5 @@ -import { invite } from "../../entity/invite"; -import { InviteViewModel } from "../../viewmodel/admin/invite.models"; +import { invite } from "../../../entity/user/invite"; +import { InviteViewModel } from "../../../viewmodel/admin/user/invite.models"; export default abstract class InviteFactory { /** diff --git a/src/factory/admin/role.ts b/src/factory/admin/user/role.ts similarity index 76% rename from src/factory/admin/role.ts rename to src/factory/admin/user/role.ts index 6e1817c..8490735 100644 --- a/src/factory/admin/role.ts +++ b/src/factory/admin/user/role.ts @@ -1,6 +1,6 @@ -import { role } from "../../entity/role"; -import PermissionHelper from "../../helpers/permissionHelper"; -import { RoleViewModel } from "../../viewmodel/admin/role.models"; +import { role } from "../../../entity/user/role"; +import PermissionHelper from "../../../helpers/permissionHelper"; +import { RoleViewModel } from "../../../viewmodel/admin/user/role.models"; export default abstract class RoleFactory { /** diff --git a/src/factory/admin/user.ts b/src/factory/admin/user/user.ts similarity index 86% rename from src/factory/admin/user.ts rename to src/factory/admin/user/user.ts index ca8524f..0a82ace 100644 --- a/src/factory/admin/user.ts +++ b/src/factory/admin/user/user.ts @@ -1,6 +1,6 @@ -import { user } from "../../entity/user"; -import PermissionHelper from "../../helpers/permissionHelper"; -import { UserViewModel } from "../../viewmodel/admin/user.models"; +import { user } from "../../../entity/user/user"; +import PermissionHelper from "../../../helpers/permissionHelper"; +import { UserViewModel } from "../../../viewmodel/admin/user/user.models"; import RoleFactory from "./role"; export default abstract class UserFactory { diff --git a/src/helpers/calendarHelper.ts b/src/helpers/calendarHelper.ts index 86409be..32ec7fc 100644 --- a/src/helpers/calendarHelper.ts +++ b/src/helpers/calendarHelper.ts @@ -1,5 +1,5 @@ import { createEvents } from "ics"; -import { calendar } from "../entity/calendar"; +import { calendar } from "../entity/club/calendar"; import moment from "moment"; import { CLUB_NAME, CLUB_WEBSITE, MAIL_USERNAME } from "../env.defaults"; diff --git a/src/helpers/demoDataHelper.ts b/src/helpers/demoDataHelper.ts index e02e5b5..3187ca1 100644 --- a/src/helpers/demoDataHelper.ts +++ b/src/helpers/demoDataHelper.ts @@ -1,14 +1,17 @@ import { newsletterDemoData } from "../demodata/newsletter.data"; import { protocolDemoData } from "../demodata/protocol.data"; import { PermissionModule } from "../type/permissionTypes"; +import {memberlistDemoData} from "../demodata/member.list.data"; export abstract class DemoDataHelper { - static getData(scope: PermissionModule) { + static getData(scope: `${PermissionModule}`|`${PermissionModule}.${string}`) { switch (scope) { case "protocol": return protocolDemoData; case "newsletter": return newsletterDemoData; + case "member.list": + return memberlistDemoData; default: return {}; } diff --git a/src/helpers/dynamicQueryBuilder.ts b/src/helpers/dynamicQueryBuilder.ts index a97e7a2..f0962d3 100644 --- a/src/helpers/dynamicQueryBuilder.ts +++ b/src/helpers/dynamicQueryBuilder.ts @@ -252,7 +252,7 @@ export default abstract class DynamicQueryBuilder { }); }); results = tempResults; - } else if (value && typeof value === "object" && !Array.isArray(value)) { + } else if (value && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date)) { const objResults = flatten(value as QueryResult, newKey); const tempResults: Array<{ [key: string]: FieldType }> = []; results.forEach((res) => { diff --git a/src/helpers/fileSystemHelper.ts b/src/helpers/fileSystemHelper.ts index 5813f6a..db6b95e 100644 --- a/src/helpers/fileSystemHelper.ts +++ b/src/helpers/fileSystemHelper.ts @@ -29,7 +29,7 @@ export abstract class FileSystemHelper { } static formatPath(...args: string[]) { - return join(process.cwd(), "export", ...args); + return join(process.cwd(), "files", ...args); } static normalizePath(...args: string[]) { diff --git a/src/helpers/jwtHelper.ts b/src/helpers/jwtHelper.ts index 993f41f..b8a62a5 100644 --- a/src/helpers/jwtHelper.ts +++ b/src/helpers/jwtHelper.ts @@ -2,9 +2,9 @@ import jwt from "jsonwebtoken"; import { JWTData, JWTToken } from "../type/jwtTypes"; import { JWT_SECRET, JWT_EXPIRATION } from "../env.defaults"; import InternalException from "../exceptions/internalException"; -import RolePermissionService from "../service/rolePermissionService"; -import UserPermissionService from "../service/userPermissionService"; -import UserService from "../service/userService"; +import RolePermissionService from "../service/user/rolePermissionService"; +import UserPermissionService from "../service/user/userPermissionService"; +import UserService from "../service/user/userService"; import PermissionHelper from "./permissionHelper"; export abstract class JWTHelper { diff --git a/src/helpers/newsletterHelper.ts b/src/helpers/newsletterHelper.ts index 70d71c9..458f854 100644 --- a/src/helpers/newsletterHelper.ts +++ b/src/helpers/newsletterHelper.ts @@ -1,12 +1,12 @@ import Mail from "nodemailer/lib/mailer"; -import { member } from "../entity/member"; -import { newsletter } from "../entity/newsletter"; -import { newsletterDates } from "../entity/newsletterDates"; -import { newsletterRecipients } from "../entity/newsletterRecipients"; -import MemberService from "../service/memberService"; -import NewsletterDatesService from "../service/newsletterDatesService"; -import NewsletterRecipientsService from "../service/newsletterRecipientsService"; -import NewsletterService from "../service/newsletterService"; +import { member } from "../entity/club/member/member"; +import { newsletter } from "../entity/club/newsletter/newsletter"; +import { newsletterDates } from "../entity/club/newsletter/newsletterDates"; +import { newsletterRecipients } from "../entity/club/newsletter/newsletterRecipients"; +import MemberService from "../service/club/member/memberService"; +import NewsletterDatesService from "../service/club/newsletter/newsletterDatesService"; +import NewsletterRecipientsService from "../service/club/newsletter/newsletterRecipientsService"; +import NewsletterService from "../service/club/newsletter/newsletterService"; import { CalendarHelper } from "./calendarHelper"; import DynamicQueryBuilder from "./dynamicQueryBuilder"; import { FileSystemHelper } from "./fileSystemHelper"; @@ -14,7 +14,7 @@ import MailHelper from "./mailHelper"; import { CLUB_NAME } from "../env.defaults"; import { TemplateHelper } from "./templateHelper"; import { PdfExport } from "./pdfExport"; -import NewsletterConfigService from "../service/newsletterConfigService"; +import NewsletterConfigService from "../service/settings/newsletterConfigService"; import { NewsletterConfigType } from "../enums/newsletterConfigType"; import InternalException from "../exceptions/internalException"; import EventEmitter from "events"; @@ -251,7 +251,10 @@ export abstract class NewsletterHelper { this.formatJobEmit("progress", "pdf", newsletterId, pdfRecipients.length, 0, "starting sending"); - for (const [index, rec] of pdfRecipients.entries()) { + for (const [index, rec] of [ + ...pdfRecipients, + { id: 0, firstname: "Alle Mitglieder", lastname: CLUB_NAME } as member, + ].entries()) { this.formatJobEmit( "progress", "pdf", diff --git a/src/helpers/pdfExport.ts b/src/helpers/pdfExport.ts index ee1af97..00a65a8 100644 --- a/src/helpers/pdfExport.ts +++ b/src/helpers/pdfExport.ts @@ -13,7 +13,7 @@ export abstract class PdfExport { saveToDisk = true, folder = "", }: { - template: PermissionModule; + template: `${PermissionModule}`|`${PermissionModule}.${string}`; title?: string; filename?: string; data?: any; diff --git a/src/helpers/templateHelper.ts b/src/helpers/templateHelper.ts index eb681b6..f7d8aa6 100644 --- a/src/helpers/templateHelper.ts +++ b/src/helpers/templateHelper.ts @@ -1,6 +1,6 @@ -import TemplateService from "../service/templateService"; +import TemplateService from "../service/settings/templateService"; import { PermissionModule } from "../type/permissionTypes"; -import TemplateUsageService from "../service/templateUsageService"; +import TemplateUsageService from "../service/settings/templateUsageService"; import Handlebars, { template } from "handlebars"; import { FileSystemHelper } from "./fileSystemHelper"; @@ -34,7 +34,7 @@ export abstract class TemplateHelper { bodyData = {}, footerData = {}, }: { - module: PermissionModule; + module: `${PermissionModule}`|`${PermissionModule}.${string}`; title?: string; headerData?: any; bodyData?: any; diff --git a/src/middleware/allowSetup.ts b/src/middleware/allowSetup.ts index e2306bf..18844bd 100644 --- a/src/middleware/allowSetup.ts +++ b/src/middleware/allowSetup.ts @@ -1,5 +1,5 @@ import { Request, Response } from "express"; -import UserService from "../service/userService"; +import UserService from "../service/user/userService"; import CustomRequestException from "../exceptions/customRequestException"; export default async function allowSetup(req: Request, res: Response, next: Function) { diff --git a/src/migrations/1734520998539-memberDataViews.ts b/src/migrations/1734520998539-memberDataViews.ts index d03fd94..4e0df38 100644 --- a/src/migrations/1734520998539-memberDataViews.ts +++ b/src/migrations/1734520998539-memberDataViews.ts @@ -1,8 +1,8 @@ import { DataSource, MigrationInterface, QueryRunner, View } from "typeorm"; -import { member } from "../entity/member"; -import { memberExecutivePositions } from "../entity/memberExecutivePositions"; -import { memberQualifications } from "../entity/memberQualifications"; -import { membership } from "../entity/membership"; +import { member } from "../entity/club/member/member"; +import { memberExecutivePositions } from "../entity/club/member/memberExecutivePositions"; +import { memberQualifications } from "../entity/club/member/memberQualifications"; +import { membership } from "../entity/club/member/membership"; export class MemberDataViews1734520998539 implements MigrationInterface { name = "MemberDataViews1734520998539"; diff --git a/src/migrations/1734949173739-templateUsage.ts b/src/migrations/1734949173739-templateUsage.ts index 2f419d4..de98006 100644 --- a/src/migrations/1734949173739-templateUsage.ts +++ b/src/migrations/1734949173739-templateUsage.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner, Table, TableForeignKey } from "typeorm"; import { DB_TYPE } from "../env.defaults"; -import { templateUsage } from "../entity/templateUsage"; +import { templateUsage } from "../entity/settings/templateUsage"; export class TemplateUsage1734949173739 implements MigrationInterface { name = "TemplateUsage1734949173739"; @@ -16,6 +16,8 @@ export class TemplateUsage1734949173739 implements MigrationInterface { { name: "headerId", type: variableType_int, isNullable: true }, { name: "bodyId", type: variableType_int, isNullable: true }, { name: "footerId", type: variableType_int, isNullable: true }, + { name: "headerHeight", type: variableType_int, default: null, isNullable: true }, + { name: "footerHeight", type: variableType_int, default: null, isNullable: true }, ], }), true diff --git a/src/migrations/1735118780511-newsletter.ts b/src/migrations/1735118780511-newsletter.ts index a6294d0..16985f9 100644 --- a/src/migrations/1735118780511-newsletter.ts +++ b/src/migrations/1735118780511-newsletter.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner, Table, TableForeignKey } from "typeorm"; import { DB_TYPE } from "../env.defaults"; -import { templateUsage } from "../entity/templateUsage"; +import { templateUsage } from "../entity/settings/templateUsage"; export class Newsletter1735118780511 implements MigrationInterface { name = "Newsletter1735118780511"; diff --git a/src/migrations/1735733514043-templateMargins.ts b/src/migrations/1735733514043-templateMargins.ts deleted file mode 100644 index 784d4fd..0000000 --- a/src/migrations/1735733514043-templateMargins.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { MigrationInterface, QueryRunner, TableColumn } from "typeorm"; -import { DB_TYPE } from "../env.defaults"; - -export class TemplateMargins1735733514043 implements MigrationInterface { - name = "TemplateMargins1735733514043"; - - public async up(queryRunner: QueryRunner): Promise { - const variableType_int = DB_TYPE == "mysql" ? "int" : "integer"; - - await queryRunner.addColumn( - "template_usage", - new TableColumn({ - name: "headerHeight", - type: variableType_int, - default: null, - isNullable: true, - }) - ); - - await queryRunner.addColumn( - "template_usage", - new TableColumn({ - name: "footerHeight", - type: variableType_int, - default: null, - isNullable: true, - }) - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.dropColumn("template_usage", "footerHeight"); - await queryRunner.dropColumn("template_usage", "headerHeight"); - } -} diff --git a/src/migrations/1735822722235-internalId.ts b/src/migrations/1735822722235-internalId.ts index 9dccc0f..02063a2 100644 --- a/src/migrations/1735822722235-internalId.ts +++ b/src/migrations/1735822722235-internalId.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner, TableColumn } from "typeorm"; -import { membership } from "../entity/membership"; -import { member } from "../entity/member"; +import { membership } from "../entity/club/member/membership"; +import { member } from "../entity/club/member/member"; export class InternalId1735822722235 implements MigrationInterface { name = "InternalId1735822722235"; diff --git a/src/migrations/1736072179716-protocolAbsent.ts b/src/migrations/1736072179716-protocolAbsent.ts new file mode 100644 index 0000000..d6a859f --- /dev/null +++ b/src/migrations/1736072179716-protocolAbsent.ts @@ -0,0 +1,21 @@ +import { MigrationInterface, QueryRunner, TableColumn } from "typeorm"; + +export class ProtocolAbsent1736072179716 implements MigrationInterface { + name = "ProtocolAbsent1736072179716"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.addColumn( + "protocol_presence", + new TableColumn({ + name: "absent", + type: "tinyint", + default: "0", + isNullable: false, + }) + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropColumn("protocol_presence", "absent"); + } +} diff --git a/src/migrations/1736079005086-memberlist.ts b/src/migrations/1736079005086-memberlist.ts new file mode 100644 index 0000000..6cb6241 --- /dev/null +++ b/src/migrations/1736079005086-memberlist.ts @@ -0,0 +1,26 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; +import { templateUsage } from "../entity/settings/templateUsage"; +import {PermissionModule} from "../type/permissionTypes"; + +export class Memberlist1736079005086 implements MigrationInterface { + name = "Memberlist1736079005086"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.manager + .createQueryBuilder() + .insert() + .into(templateUsage) + .values({ scope: "member.list" }) + .orIgnore() + .execute(); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.manager + .createQueryBuilder() + .delete() + .from(templateUsage) + .where({ scope: "member.list" }) + .execute(); + } +} diff --git a/src/migrations/1736084198860-extendViewValues.ts b/src/migrations/1736084198860-extendViewValues.ts new file mode 100644 index 0000000..c09064d --- /dev/null +++ b/src/migrations/1736084198860-extendViewValues.ts @@ -0,0 +1,112 @@ +import { DataSource, MigrationInterface, QueryRunner, View } from "typeorm"; +import { member } from "../entity/club/member/member"; +import { memberExecutivePositions } from "../entity/club/member/memberExecutivePositions"; +import { memberQualifications } from "../entity/club/member/memberQualifications"; +import { membership } from "../entity/club/member/membership"; + +export class ExtendViewValues1736084198860 implements MigrationInterface { + name = "ExtendViewValues1736084198860"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.dropView("membership_view"); + await queryRunner.dropView("member_view"); + + await queryRunner.createView( + new View({ + name: "member_view", + expression: (datasource: DataSource) => + datasource + .getRepository(member) + .createQueryBuilder("member") + .select("member.id", "id") + .addSelect("member.salutation", "salutation") + .addSelect("member.firstname", "firstname") + .addSelect("member.lastname", "lastname") + .addSelect("member.nameaffix", "nameaffix") + .addSelect("member.birthdate", "birthdate") + .addSelect("TIMESTAMPDIFF(YEAR, member.birthdate, CURDATE())", "todayAge") + .addSelect("YEAR(CURDATE()) - YEAR(member.birthdate)", "ageThisYear") + .addSelect("CONCAT('_', FROM_DAYS(TIMESTAMPDIFF(DAY, member.birthdate, CURDATE())))", "exactAge"), + }), + true + ); + await queryRunner.createView( + new View({ + name: "membership_view", + expression: (datasource: DataSource) => + datasource + .getRepository(membership) + .createQueryBuilder("membership") + .select("status.id", "statusId") + .addSelect("status.status", "status") + .addSelect("member.id", "memberId") + .addSelect("member.salutation", "memberSalutation") + .addSelect("member.firstname", "memberFirstname") + .addSelect("member.lastname", "memberLastname") + .addSelect("member.nameaffix", "memberNameaffix") + .addSelect("member.birthdate", "memberBirthdate") + .addSelect( + "SUM(TIMESTAMPDIFF(DAY, membership.start, COALESCE(membership.end, CURRENT_DATE)))", + "durationInDays" + ) + .addSelect( + "CONCAT('_', FROM_DAYS(SUM(TIMESTAMPDIFF(DAY, membership.start, COALESCE(membership.end, CURRENT_DATE)))))", + "durationInYears" + ) + .leftJoin("membership.status", "status") + .leftJoin("membership.member", "member") + .groupBy("status.id"), + }), + true + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropView("membership_view"); + await queryRunner.dropView("member_view"); + + await queryRunner.createView( + new View({ + name: "member_view", + expression: (datasource: DataSource) => + datasource + .getRepository(member) + .createQueryBuilder("member") + .select("member.id", "id") + .addSelect("member.salutation", "salutation") + .addSelect("member.firstname", "firstname") + .addSelect("member.lastname", "lastname") + .addSelect("member.nameaffix", "nameaffix") + .addSelect("member.birthdate", "birthdate") + .addSelect("TIMESTAMPDIFF(YEAR, member.birthdate, CURDATE())", "todayAge") + .addSelect("YEAR(CURDATE()) - YEAR(member.birthdate)", "ageThisYear"), + }), + true + ); + await queryRunner.createView( + new View({ + name: "membership_view", + expression: (datasource: DataSource) => + datasource + .getRepository(membership) + .createQueryBuilder("membership") + .select("status.id", "statusId") + .addSelect("status.status", "status") + .addSelect("member.id", "memberId") + .addSelect("member.salutation", "memberSalutation") + .addSelect("member.firstname", "memberFirstname") + .addSelect("member.lastname", "memberLastname") + .addSelect("member.nameaffix", "memberNameaffix") + .addSelect("member.birthdate", "memberBirthdate") + .addSelect( + "SUM(TIMESTAMPDIFF(DAY, membership.start, COALESCE(membership.end, CURRENT_DATE)))", + "durationInDays" + ) + .leftJoin("membership.status", "status") + .leftJoin("membership.member", "member") + .groupBy("status.id"), + }), + true + ); + } +} diff --git a/src/routes/admin/calendar.ts b/src/routes/admin/club/calendar.ts similarity index 89% rename from src/routes/admin/calendar.ts rename to src/routes/admin/club/calendar.ts index 7503dee..3cfff57 100644 --- a/src/routes/admin/calendar.ts +++ b/src/routes/admin/club/calendar.ts @@ -10,8 +10,8 @@ import { updateCalendarType, deleteCalendarItem, deleteCalendarType, -} from "../../controller/admin/calendarController"; -import PermissionHelper from "../../helpers/permissionHelper"; +} from "../../../controller/admin/club/calendarController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/member.ts b/src/routes/admin/club/member.ts similarity index 82% rename from src/routes/admin/member.ts rename to src/routes/admin/club/member.ts index bd45549..f014d37 100644 --- a/src/routes/admin/member.ts +++ b/src/routes/admin/club/member.ts @@ -1,37 +1,38 @@ import express, { Request, Response } from "express"; import { - addAwardToMember, - addCommunicationToMember, - addExecutivePositionToMember, - addMembershipToMember, - addQualificationToMember, - createMember, - deleteAwardOfMember, - deleteCommunicationOfMember, - deleteExecutivePositionOfMember, - deleteMemberById, - deleteMembershipOfMember, - deleteQualificationOfMember, - getAllMembers, - getAwardByMemberAndRecord, - getAwardsByMember, - getCommunicationByMemberAndRecord, - getCommunicationsByMember, - getExecutivePositionByMemberAndRecord, - getExecutivePositionsByMember, - getMemberById, - getMembershipByMemberAndRecord, - getMembershipsByMember, - getQualificationByMemberAndRecord, - getQualificationsByMember, - updateAwardOfMember, - updateCommunicationOfMember, - updateExecutivePositionOfMember, - updateMemberById, - updateMembershipOfMember, - updateQualificationOfMember, -} from "../../controller/admin/memberController"; -import PermissionHelper from "../../helpers/permissionHelper"; + addAwardToMember, + addCommunicationToMember, + addExecutivePositionToMember, + addMembershipToMember, + addQualificationToMember, + createMember, + createMemberPrintoutList, + deleteAwardOfMember, + deleteCommunicationOfMember, + deleteExecutivePositionOfMember, + deleteMemberById, + deleteMembershipOfMember, + deleteQualificationOfMember, + getAllMembers, + getAwardByMemberAndRecord, + getAwardsByMember, + getCommunicationByMemberAndRecord, + getCommunicationsByMember, + getExecutivePositionByMemberAndRecord, + getExecutivePositionsByMember, + getMemberById, + getMembershipByMemberAndRecord, + getMembershipsByMember, + getQualificationByMemberAndRecord, + getQualificationsByMember, + updateAwardOfMember, + updateCommunicationOfMember, + updateExecutivePositionOfMember, + updateMemberById, + updateMembershipOfMember, + updateQualificationOfMember, +} from "../../../controller/admin/club/memberController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); @@ -43,6 +44,10 @@ router.get("/:id", async (req: Request, res: Response) => { await getMemberById(req, res); }); +router.get("/print/namelist", async (req: Request, res: Response) => { + await createMemberPrintoutList(req, res); +}); + router.get("/:memberId/memberships", async (req: Request, res: Response) => { await getMembershipsByMember(req, res); }); diff --git a/src/routes/admin/newsletter.ts b/src/routes/admin/club/newsletter.ts similarity index 96% rename from src/routes/admin/newsletter.ts rename to src/routes/admin/club/newsletter.ts index d7b6edb..9a71bbf 100644 --- a/src/routes/admin/newsletter.ts +++ b/src/routes/admin/club/newsletter.ts @@ -16,8 +16,8 @@ import { createNewsletterPrintoutPreviewById, getNewsletterPrintoutProgressById, getNewsletterSendingProgressById, -} from "../../controller/admin/newsletterController"; -import PermissionHelper from "../../helpers/permissionHelper"; +} from "../../../controller/admin/club/newsletterController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/protocol.ts b/src/routes/admin/club/protocol.ts similarity index 96% rename from src/routes/admin/protocol.ts rename to src/routes/admin/club/protocol.ts index 48c5e6c..245fb2f 100644 --- a/src/routes/admin/protocol.ts +++ b/src/routes/admin/club/protocol.ts @@ -18,8 +18,8 @@ import { synchronizeProtocolDecisonsById, synchronizeProtocolPrecenseById, synchronizeProtocolVotingsById, -} from "../../controller/admin/protocolController"; -import PermissionHelper from "../../helpers/permissionHelper"; +} from "../../../controller/admin/club/protocolController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/queryBuilder.ts b/src/routes/admin/club/queryBuilder.ts similarity index 89% rename from src/routes/admin/queryBuilder.ts rename to src/routes/admin/club/queryBuilder.ts index d09b9c3..5578b9d 100644 --- a/src/routes/admin/queryBuilder.ts +++ b/src/routes/admin/club/queryBuilder.ts @@ -1,5 +1,5 @@ import express, { Request, Response } from "express"; -import { executeQuery, getAllTableMeta, getTableMetaByTablename } from "../../controller/admin/queryBuilderController"; +import { executeQuery, getAllTableMeta, getTableMetaByTablename } from "../../../controller/admin/club/queryBuilderController"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/index.ts b/src/routes/admin/index.ts index 8d627af..cd7c935 100644 --- a/src/routes/admin/index.ts +++ b/src/routes/admin/index.ts @@ -1,26 +1,26 @@ import express from "express"; import PermissionHelper from "../../helpers/permissionHelper"; -import award from "./award"; -import communicationType from "./communicationType"; -import executivePosition from "./executivePosition"; -import membershipStatus from "./membershipStatus"; -import qualification from "./qualification"; -import calendarType from "./calendarType"; -import queryStore from "./queryStore"; -import template from "./template"; -import templateUsage from "./templateUsage"; -import newsletterConfig from "./newsletterConfig"; +import award from "./settings/award"; +import communicationType from "./settings/communicationType"; +import executivePosition from "./settings/executivePosition"; +import membershipStatus from "./settings/membershipStatus"; +import qualification from "./settings/qualification"; +import calendarType from "./settings/calendarType"; +import queryStore from "./settings/queryStore"; +import template from "./settings/template"; +import templateUsage from "./settings/templateUsage"; +import newsletterConfig from "./settings/newsletterConfig"; -import member from "./member"; -import protocol from "./protocol"; -import calendar from "./calendar"; -import queryBuilder from "./queryBuilder"; -import newsletter from "./newsletter"; +import member from "./club/member"; +import protocol from "./club/protocol"; +import calendar from "./club/calendar"; +import queryBuilder from "./club/queryBuilder"; +import newsletter from "./club/newsletter"; -import role from "./role"; -import user from "./user"; -import invite from "./invite"; +import role from "./user/role"; +import user from "./user/user"; +import invite from "./user/invite"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/award.ts b/src/routes/admin/settings/award.ts similarity index 88% rename from src/routes/admin/award.ts rename to src/routes/admin/settings/award.ts index f9781df..d5eddeb 100644 --- a/src/routes/admin/award.ts +++ b/src/routes/admin/settings/award.ts @@ -5,8 +5,8 @@ import { getAllAwards, getAwardById, updateAward, -} from "../../controller/admin/awardController"; -import PermissionHelper from "../../helpers/permissionHelper"; +} from "../../../controller/admin/settings/awardController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/calendarType.ts b/src/routes/admin/settings/calendarType.ts similarity index 90% rename from src/routes/admin/calendarType.ts rename to src/routes/admin/settings/calendarType.ts index 953036d..37cf230 100644 --- a/src/routes/admin/calendarType.ts +++ b/src/routes/admin/settings/calendarType.ts @@ -10,8 +10,8 @@ import { updateCalendarType, deleteCalendarItem, deleteCalendarType, -} from "../../controller/admin/calendarController"; -import PermissionHelper from "../../helpers/permissionHelper"; +} from "../../../controller/admin/club/calendarController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/communicationType.ts b/src/routes/admin/settings/communicationType.ts similarity index 90% rename from src/routes/admin/communicationType.ts rename to src/routes/admin/settings/communicationType.ts index 4fc185f..aaf3c46 100644 --- a/src/routes/admin/communicationType.ts +++ b/src/routes/admin/settings/communicationType.ts @@ -6,8 +6,8 @@ import { getCommunicationTypeAvailableColumns, getCommunicationTypeById, updateCommunicationType, -} from "../../controller/admin/communicationTypeController"; -import PermissionHelper from "../../helpers/permissionHelper"; +} from "../../../controller/admin/settings/communicationTypeController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/executivePosition.ts b/src/routes/admin/settings/executivePosition.ts similarity index 88% rename from src/routes/admin/executivePosition.ts rename to src/routes/admin/settings/executivePosition.ts index 2d0c934..dd698ea 100644 --- a/src/routes/admin/executivePosition.ts +++ b/src/routes/admin/settings/executivePosition.ts @@ -5,8 +5,8 @@ import { getAllExecutivePositions, getExecutivePositionById, updateExecutivePosition, -} from "../../controller/admin/executivePositionController"; -import PermissionHelper from "../../helpers/permissionHelper"; +} from "../../../controller/admin/settings/executivePositionController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/membershipStatus.ts b/src/routes/admin/settings/membershipStatus.ts similarity index 88% rename from src/routes/admin/membershipStatus.ts rename to src/routes/admin/settings/membershipStatus.ts index 665d97b..72673f1 100644 --- a/src/routes/admin/membershipStatus.ts +++ b/src/routes/admin/settings/membershipStatus.ts @@ -5,8 +5,8 @@ import { getAllMembershipStatus, getMembershipStatusById, updateMembershipStatus, -} from "../../controller/admin/membershipStatusController"; -import PermissionHelper from "../../helpers/permissionHelper"; +} from "../../../controller/admin/settings/membershipStatusController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/newsletterConfig.ts b/src/routes/admin/settings/newsletterConfig.ts similarity index 86% rename from src/routes/admin/newsletterConfig.ts rename to src/routes/admin/settings/newsletterConfig.ts index 05cb0e9..a874cc7 100644 --- a/src/routes/admin/newsletterConfig.ts +++ b/src/routes/admin/settings/newsletterConfig.ts @@ -4,8 +4,8 @@ import { getAllNewsletterConfigs, getNewsletterConfigById, setNewsletterConfig, -} from "../../controller/admin/newsletterConfigController"; -import PermissionHelper from "../../helpers/permissionHelper"; +} from "../../../controller/admin/settings/newsletterConfigController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/qualification.ts b/src/routes/admin/settings/qualification.ts similarity index 88% rename from src/routes/admin/qualification.ts rename to src/routes/admin/settings/qualification.ts index cab8f22..efa34a8 100644 --- a/src/routes/admin/qualification.ts +++ b/src/routes/admin/settings/qualification.ts @@ -5,8 +5,8 @@ import { getAllQualifications, getQualificationById, updateQualification, -} from "../../controller/admin/qualificationController"; -import PermissionHelper from "../../helpers/permissionHelper"; +} from "../../../controller/admin/settings/qualificationController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/queryStore.ts b/src/routes/admin/settings/queryStore.ts similarity index 88% rename from src/routes/admin/queryStore.ts rename to src/routes/admin/settings/queryStore.ts index e160187..85b408c 100644 --- a/src/routes/admin/queryStore.ts +++ b/src/routes/admin/settings/queryStore.ts @@ -1,12 +1,12 @@ import express, { Request, Response } from "express"; -import PermissionHelper from "../../helpers/permissionHelper"; +import PermissionHelper from "../../../helpers/permissionHelper"; import { createQueryStore, deleteQueryStore, getAllQueryStores, getQueryStoreById, updateQueryStore, -} from "../../controller/admin/queryStoreController"; +} from "../../../controller/admin/settings/queryStoreController"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/template.ts b/src/routes/admin/settings/template.ts similarity index 90% rename from src/routes/admin/template.ts rename to src/routes/admin/settings/template.ts index 492837e..e04f7d4 100644 --- a/src/routes/admin/template.ts +++ b/src/routes/admin/settings/template.ts @@ -6,8 +6,8 @@ import { getAllTemplates, getTemplateById, updateTemplate, -} from "../../controller/admin/templateController"; -import PermissionHelper from "../../helpers/permissionHelper"; +} from "../../../controller/admin/settings/templateController"; +import PermissionHelper from "../../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/templateUsage.ts b/src/routes/admin/settings/templateUsage.ts similarity index 68% rename from src/routes/admin/templateUsage.ts rename to src/routes/admin/settings/templateUsage.ts index d25b321..6c8f3a9 100644 --- a/src/routes/admin/templateUsage.ts +++ b/src/routes/admin/settings/templateUsage.ts @@ -1,12 +1,12 @@ import express, { Request, Response } from "express"; -import PermissionHelper from "../../helpers/permissionHelper"; +import PermissionHelper from "../../../helpers/permissionHelper"; import { getAllTemplateUsages, printTemplateUsageDemo, updateTemplateUsage, -} from "../../controller/admin/templateUsageController"; -import { PermissionModule } from "../../type/permissionTypes"; -import ForbiddenRequestException from "../../exceptions/forbiddenRequestException"; +} from "../../../controller/admin/settings/templateUsageController"; +import { PermissionModule } from "../../../type/permissionTypes"; +import ForbiddenRequestException from "../../../exceptions/forbiddenRequestException"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/invite.ts b/src/routes/admin/user/invite.ts similarity index 78% rename from src/routes/admin/invite.ts rename to src/routes/admin/user/invite.ts index 0eb5070..814a13c 100644 --- a/src/routes/admin/invite.ts +++ b/src/routes/admin/user/invite.ts @@ -1,6 +1,6 @@ import express, { Request, Response } from "express"; -import PermissionHelper from "../../helpers/permissionHelper"; -import { deleteInvite, getInvites, inviteUser } from "../../controller/inviteController"; +import PermissionHelper from "../../../helpers/permissionHelper"; +import { deleteInvite, getInvites, inviteUser } from "../../../controller/inviteController"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/role.ts b/src/routes/admin/user/role.ts similarity index 91% rename from src/routes/admin/role.ts rename to src/routes/admin/user/role.ts index 4f50b7c..c9f831c 100644 --- a/src/routes/admin/role.ts +++ b/src/routes/admin/user/role.ts @@ -1,5 +1,5 @@ import express, { Request, Response } from "express"; -import PermissionHelper from "../../helpers/permissionHelper"; +import PermissionHelper from "../../../helpers/permissionHelper"; import { createRole, deleteRole, @@ -8,7 +8,7 @@ import { getRolePermissions, updateRole, updateRolePermissions, -} from "../../controller/admin/roleController"; +} from "../../../controller/admin/user/roleController"; var router = express.Router({ mergeParams: true }); diff --git a/src/routes/admin/user.ts b/src/routes/admin/user/user.ts similarity index 88% rename from src/routes/admin/user.ts rename to src/routes/admin/user/user.ts index 6c774cd..693e8ea 100644 --- a/src/routes/admin/user.ts +++ b/src/routes/admin/user/user.ts @@ -1,5 +1,5 @@ import express, { Request, Response } from "express"; -import PermissionHelper from "../../helpers/permissionHelper"; +import PermissionHelper from "../../../helpers/permissionHelper"; import { deleteUser, getAllUsers, @@ -9,8 +9,8 @@ import { updateUser, updateUserPermissions, updateUserRoles, -} from "../../controller/admin/userController"; -import { inviteUser } from "../../controller/inviteController"; +} from "../../../controller/admin/user/userController"; +import { inviteUser } from "../../../controller/inviteController"; var router = express.Router({ mergeParams: true }); diff --git a/src/service/calendarService.ts b/src/service/club/calendarService.ts similarity index 92% rename from src/service/calendarService.ts rename to src/service/club/calendarService.ts index 5bbf4f4..0714cd3 100644 --- a/src/service/calendarService.ts +++ b/src/service/club/calendarService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { calendar } from "../entity/calendar"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { calendar } from "../../entity/club/calendar"; +import InternalException from "../../exceptions/internalException"; export default abstract class CalendarService { /** diff --git a/src/service/communicationService.ts b/src/service/club/member/communicationService.ts similarity index 91% rename from src/service/communicationService.ts rename to src/service/club/member/communicationService.ts index 03073fa..f0c2f04 100644 --- a/src/service/communicationService.ts +++ b/src/service/club/member/communicationService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { communication } from "../entity/communication"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { communication } from "../../../entity/club/member/communication"; +import InternalException from "../../../exceptions/internalException"; export default abstract class CommunicationService { /** diff --git a/src/service/memberAwardService.ts b/src/service/club/member/memberAwardService.ts similarity index 87% rename from src/service/memberAwardService.ts rename to src/service/club/member/memberAwardService.ts index a9998c2..16ed55c 100644 --- a/src/service/memberAwardService.ts +++ b/src/service/club/member/memberAwardService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { memberAwards } from "../entity/memberAwards"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { memberAwards } from "../../../entity/club/member/memberAwards"; +import InternalException from "../../../exceptions/internalException"; export default abstract class MemberAwardService { /** diff --git a/src/service/memberExecutivePositionService.ts b/src/service/club/member/memberExecutivePositionService.ts similarity index 88% rename from src/service/memberExecutivePositionService.ts rename to src/service/club/member/memberExecutivePositionService.ts index 7f903be..89cf23c 100644 --- a/src/service/memberExecutivePositionService.ts +++ b/src/service/club/member/memberExecutivePositionService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { memberExecutivePositions } from "../entity/memberExecutivePositions"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { memberExecutivePositions } from "../../../entity/club/member/memberExecutivePositions"; +import InternalException from "../../../exceptions/internalException"; export default abstract class MemberExecutivePositionService { /** diff --git a/src/service/memberQualificationService.ts b/src/service/club/member/memberQualificationService.ts similarity index 88% rename from src/service/memberQualificationService.ts rename to src/service/club/member/memberQualificationService.ts index a90503e..9685c19 100644 --- a/src/service/memberQualificationService.ts +++ b/src/service/club/member/memberQualificationService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { memberQualifications } from "../entity/memberQualifications"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { memberQualifications } from "../../../entity/club/member/memberQualifications"; +import InternalException from "../../../exceptions/internalException"; export default abstract class MemberQualificationService { /** diff --git a/src/service/memberService.ts b/src/service/club/member/memberService.ts similarity index 85% rename from src/service/memberService.ts rename to src/service/club/member/memberService.ts index 531c4b6..4ac3a6d 100644 --- a/src/service/memberService.ts +++ b/src/service/club/member/memberService.ts @@ -1,7 +1,7 @@ -import { dataSource } from "../data-source"; -import { member } from "../entity/member"; -import { membership } from "../entity/membership"; -import InternalException from "../exceptions/internalException"; +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 { /** @@ -9,7 +9,7 @@ export default abstract class MemberService { * @returns {Promise<[Array, number]>} */ static async getAll(offset: number = 0, count: number = 25, search: string = ""): Promise<[Array, number]> { - let query = await dataSource + let query = dataSource .getRepository(member) .createQueryBuilder("member") .leftJoinAndMapOne( @@ -54,7 +54,7 @@ export default abstract class MemberService { }); } - return query + return await query .offset(offset) .limit(count) .orderBy("member.lastname") @@ -114,6 +114,25 @@ export default abstract class MemberService { }); } + /** + * @description get members where membership is setz + * @returns {Promise} + */ + static async getByRunningMembership(): Promise> { + 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 diff --git a/src/service/membershipService.ts b/src/service/club/member/membershipService.ts similarity index 88% rename from src/service/membershipService.ts rename to src/service/club/member/membershipService.ts index 96805cc..a00daf2 100644 --- a/src/service/membershipService.ts +++ b/src/service/club/member/membershipService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { membership } from "../entity/membership"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { membership } from "../../../entity/club/member/membership"; +import InternalException from "../../../exceptions/internalException"; export default abstract class MembershipService { /** diff --git a/src/service/newsletterDatesService.ts b/src/service/club/newsletter/newsletterDatesService.ts similarity index 74% rename from src/service/newsletterDatesService.ts rename to src/service/club/newsletter/newsletterDatesService.ts index 08c4b0e..10c4e7a 100644 --- a/src/service/newsletterDatesService.ts +++ b/src/service/club/newsletter/newsletterDatesService.ts @@ -1,7 +1,7 @@ -import { dataSource } from "../data-source"; -import { newsletterDates } from "../entity/newsletterDates"; -import { member } from "../entity/member"; -import InternalException from "../exceptions/internalException"; +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 { /** diff --git a/src/service/newsletterRecipientsService.ts b/src/service/club/newsletter/newsletterRecipientsService.ts similarity index 76% rename from src/service/newsletterRecipientsService.ts rename to src/service/club/newsletter/newsletterRecipientsService.ts index 8e0f9a5..fe570de 100644 --- a/src/service/newsletterRecipientsService.ts +++ b/src/service/club/newsletter/newsletterRecipientsService.ts @@ -1,7 +1,7 @@ -import { dataSource } from "../data-source"; -import { newsletterRecipients } from "../entity/newsletterRecipients"; -import { member } from "../entity/member"; -import InternalException from "../exceptions/internalException"; +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 { /** diff --git a/src/service/newsletterService.ts b/src/service/club/newsletter/newsletterService.ts similarity index 85% rename from src/service/newsletterService.ts rename to src/service/club/newsletter/newsletterService.ts index f522233..24c2a3f 100644 --- a/src/service/newsletterService.ts +++ b/src/service/club/newsletter/newsletterService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { newsletter } from "../entity/newsletter"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { newsletter } from "../../../entity/club/newsletter/newsletter"; +import InternalException from "../../../exceptions/internalException"; export default abstract class NewsletterService { /** diff --git a/src/service/protocolAgendaService.ts b/src/service/club/protocol/protocolAgendaService.ts similarity index 84% rename from src/service/protocolAgendaService.ts rename to src/service/club/protocol/protocolAgendaService.ts index 4409d05..c0899bd 100644 --- a/src/service/protocolAgendaService.ts +++ b/src/service/club/protocol/protocolAgendaService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { protocolAgenda } from "../entity/protocolAgenda"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { protocolAgenda } from "../../../entity/club/protocol/protocolAgenda"; +import InternalException from "../../../exceptions/internalException"; export default abstract class ProtocolAgendaService { /** diff --git a/src/service/protocolDecisionService.ts b/src/service/club/protocol/protocolDecisionService.ts similarity index 84% rename from src/service/protocolDecisionService.ts rename to src/service/club/protocol/protocolDecisionService.ts index b818313..62dd672 100644 --- a/src/service/protocolDecisionService.ts +++ b/src/service/club/protocol/protocolDecisionService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { protocolDecision } from "../entity/protocolDecision"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { protocolDecision } from "../../../entity/club/protocol/protocolDecision"; +import InternalException from "../../../exceptions/internalException"; export default abstract class ProtocolDecisionService { /** diff --git a/src/service/protocolPrecenseService.ts b/src/service/club/protocol/protocolPrecenseService.ts similarity index 76% rename from src/service/protocolPrecenseService.ts rename to src/service/club/protocol/protocolPrecenseService.ts index 2fc9c94..ac3a82f 100644 --- a/src/service/protocolPrecenseService.ts +++ b/src/service/club/protocol/protocolPrecenseService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { protocolPresence } from "../entity/protocolPresence"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { protocolPresence } from "../../../entity/club/protocol/protocolPresence"; +import InternalException from "../../../exceptions/internalException"; export default abstract class ProtocolPresenceService { /** diff --git a/src/service/protocolPrintoutService.ts b/src/service/club/protocol/protocolPrintoutService.ts similarity index 89% rename from src/service/protocolPrintoutService.ts rename to src/service/club/protocol/protocolPrintoutService.ts index aaf39ed..a1815fb 100644 --- a/src/service/protocolPrintoutService.ts +++ b/src/service/club/protocol/protocolPrintoutService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { protocolPrintout } from "../entity/protocolPrintout"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { protocolPrintout } from "../../../entity/club/protocol/protocolPrintout"; +import InternalException from "../../../exceptions/internalException"; export default abstract class ProtocolPrintoutService { /** diff --git a/src/service/protocolService.ts b/src/service/club/protocol/protocolService.ts similarity index 84% rename from src/service/protocolService.ts rename to src/service/club/protocol/protocolService.ts index 53e0baf..12526fe 100644 --- a/src/service/protocolService.ts +++ b/src/service/club/protocol/protocolService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { protocol } from "../entity/protocol"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { protocol } from "../../../entity/club/protocol/protocol"; +import InternalException from "../../../exceptions/internalException"; export default abstract class ProtocolService { /** diff --git a/src/service/protocolVotingService.ts b/src/service/club/protocol/protocolVotingService.ts similarity index 84% rename from src/service/protocolVotingService.ts rename to src/service/club/protocol/protocolVotingService.ts index 55792fe..cc7c5f6 100644 --- a/src/service/protocolVotingService.ts +++ b/src/service/club/protocol/protocolVotingService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { protocolVoting } from "../entity/protocolVoting"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../../data-source"; +import { protocolVoting } from "../../../entity/club/protocol/protocolVoting"; +import InternalException from "../../../exceptions/internalException"; export default abstract class ProtocolVotingService { /** diff --git a/src/service/awardService.ts b/src/service/settings/awardService.ts similarity index 79% rename from src/service/awardService.ts rename to src/service/settings/awardService.ts index a24f126..414ea01 100644 --- a/src/service/awardService.ts +++ b/src/service/settings/awardService.ts @@ -1,7 +1,7 @@ -import { dataSource } from "../data-source"; -import { award } from "../entity/award"; -import { member } from "../entity/member"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { award } from "../../entity/settings/award"; +import { member } from "../../entity/club/member/member"; +import InternalException from "../../exceptions/internalException"; export default abstract class AwardService { /** diff --git a/src/service/calendarTypeService.ts b/src/service/settings/calendarTypeService.ts similarity index 89% rename from src/service/calendarTypeService.ts rename to src/service/settings/calendarTypeService.ts index 08e76ea..0bbc5bb 100644 --- a/src/service/calendarTypeService.ts +++ b/src/service/settings/calendarTypeService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { calendarType } from "../entity/calendarType"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { calendarType } from "../../entity/settings/calendarType"; +import InternalException from "../../exceptions/internalException"; export default abstract class CalendarTypeService { /** diff --git a/src/service/communicationTypeService.ts b/src/service/settings/communicationTypeService.ts similarity index 84% rename from src/service/communicationTypeService.ts rename to src/service/settings/communicationTypeService.ts index 7edb4e2..cecc1fc 100644 --- a/src/service/communicationTypeService.ts +++ b/src/service/settings/communicationTypeService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { communicationType } from "../entity/communicationType"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { communicationType } from "../../entity/settings/communicationType"; +import InternalException from "../../exceptions/internalException"; export default abstract class CommunicationTypeService { /** diff --git a/src/service/executivePositionService.ts b/src/service/settings/executivePositionService.ts similarity index 78% rename from src/service/executivePositionService.ts rename to src/service/settings/executivePositionService.ts index 344ad20..e69e96f 100644 --- a/src/service/executivePositionService.ts +++ b/src/service/settings/executivePositionService.ts @@ -1,7 +1,7 @@ -import { dataSource } from "../data-source"; -import { executivePosition } from "../entity/executivePosition"; -import { memberExecutivePositions } from "../entity/memberExecutivePositions"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { executivePosition } from "../../entity/settings/executivePosition"; +import { memberExecutivePositions } from "../../entity/club/member/memberExecutivePositions"; +import InternalException from "../../exceptions/internalException"; export default abstract class ExecutivePositionService { /** diff --git a/src/service/membershipStatusService.ts b/src/service/settings/membershipStatusService.ts similarity index 80% rename from src/service/membershipStatusService.ts rename to src/service/settings/membershipStatusService.ts index b1032c6..23269f1 100644 --- a/src/service/membershipStatusService.ts +++ b/src/service/settings/membershipStatusService.ts @@ -1,7 +1,7 @@ -import { dataSource } from "../data-source"; -import { membershipStatus } from "../entity/membershipStatus"; -import InternalException from "../exceptions/internalException"; -import { membership } from "../entity/membership"; +import { dataSource } from "../../data-source"; +import { membershipStatus } from "../../entity/settings/membershipStatus"; +import InternalException from "../../exceptions/internalException"; +import { membership } from "../../entity/club/member/membership"; export default abstract class MembershipStatusService { /** diff --git a/src/service/newsletterConfigService.ts b/src/service/settings/newsletterConfigService.ts similarity index 82% rename from src/service/newsletterConfigService.ts rename to src/service/settings/newsletterConfigService.ts index f85970d..5ef66a3 100644 --- a/src/service/newsletterConfigService.ts +++ b/src/service/settings/newsletterConfigService.ts @@ -1,7 +1,7 @@ -import { dataSource } from "../data-source"; -import { newsletterConfig } from "../entity/newsletterConfig"; -import { member } from "../entity/member"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { newsletterConfig } from "../../entity/settings/newsletterConfig"; +import { member } from "../../entity/club/member/member"; +import InternalException from "../../exceptions/internalException"; export default abstract class NewsletterConfigService { /** diff --git a/src/service/qualification.ts b/src/service/settings/qualification.ts similarity index 75% rename from src/service/qualification.ts rename to src/service/settings/qualification.ts index 4009b64..585d1ae 100644 --- a/src/service/qualification.ts +++ b/src/service/settings/qualification.ts @@ -1,8 +1,8 @@ -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"; +import { dataSource } from "../../data-source"; +import { memberQualifications } from "../../entity/club/member/memberQualifications"; +import { qualification } from "../../entity/settings/qualification"; +import { user } from "../../entity/user/user"; +import InternalException from "../../exceptions/internalException"; export default abstract class QualificationService { /** diff --git a/src/service/queryStoreService.ts b/src/service/settings/queryStoreService.ts similarity index 84% rename from src/service/queryStoreService.ts rename to src/service/settings/queryStoreService.ts index 93145f9..8dfbcf8 100644 --- a/src/service/queryStoreService.ts +++ b/src/service/settings/queryStoreService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { query } from "../entity/query"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { query } from "../../entity/settings/query"; +import InternalException from "../../exceptions/internalException"; export default abstract class QueryStoreService { /** diff --git a/src/service/templateService.ts b/src/service/settings/templateService.ts similarity index 79% rename from src/service/templateService.ts rename to src/service/settings/templateService.ts index 52517bc..4ace459 100644 --- a/src/service/templateService.ts +++ b/src/service/settings/templateService.ts @@ -1,7 +1,7 @@ -import { dataSource } from "../data-source"; -import { template } from "../entity/template"; -import { member } from "../entity/member"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { template } from "../../entity/settings/template"; +import { member } from "../../entity/club/member/member"; +import InternalException from "../../exceptions/internalException"; export default abstract class TemplateService { /** diff --git a/src/service/templateUsageService.ts b/src/service/settings/templateUsageService.ts similarity index 88% rename from src/service/templateUsageService.ts rename to src/service/settings/templateUsageService.ts index 25b61ee..e944edc 100644 --- a/src/service/templateUsageService.ts +++ b/src/service/settings/templateUsageService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { templateUsage } from "../entity/templateUsage"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { templateUsage } from "../../entity/settings/templateUsage"; +import InternalException from "../../exceptions/internalException"; export default abstract class TemplateUsageService { /** diff --git a/src/service/inviteService.ts b/src/service/user/inviteService.ts similarity index 86% rename from src/service/inviteService.ts rename to src/service/user/inviteService.ts index f6e6a7c..6b2a701 100644 --- a/src/service/inviteService.ts +++ b/src/service/user/inviteService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { invite } from "../entity/invite"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { invite } from "../../entity/user/invite"; +import InternalException from "../../exceptions/internalException"; export default abstract class InviteService { /** diff --git a/src/service/rolePermissionService.ts b/src/service/user/rolePermissionService.ts similarity index 82% rename from src/service/rolePermissionService.ts rename to src/service/user/rolePermissionService.ts index 7021a2a..e40930f 100644 --- a/src/service/rolePermissionService.ts +++ b/src/service/user/rolePermissionService.ts @@ -1,7 +1,7 @@ -import { dataSource } from "../data-source"; -import { rolePermission } from "../entity/role_permission"; -import { userPermission } from "../entity/user_permission"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { rolePermission } from "../../entity/user/role_permission"; +import { userPermission } from "../../entity/user/user_permission"; +import InternalException from "../../exceptions/internalException"; export default abstract class RolePermissionService { /** diff --git a/src/service/roleService.ts b/src/service/user/roleService.ts similarity index 86% rename from src/service/roleService.ts rename to src/service/user/roleService.ts index a344a0a..82cdaae 100644 --- a/src/service/roleService.ts +++ b/src/service/user/roleService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { role } from "../entity/role"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { role } from "../../entity/user/role"; +import InternalException from "../../exceptions/internalException"; export default abstract class RoleService { /** diff --git a/src/service/userPermissionService.ts b/src/service/user/userPermissionService.ts similarity index 76% rename from src/service/userPermissionService.ts rename to src/service/user/userPermissionService.ts index c060264..2f5a059 100644 --- a/src/service/userPermissionService.ts +++ b/src/service/user/userPermissionService.ts @@ -1,6 +1,6 @@ -import { dataSource } from "../data-source"; -import { userPermission } from "../entity/user_permission"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { userPermission } from "../../entity/user/user_permission"; +import InternalException from "../../exceptions/internalException"; export default abstract class UserPermissionService { /** diff --git a/src/service/userService.ts b/src/service/user/userService.ts similarity index 94% rename from src/service/userService.ts rename to src/service/user/userService.ts index bc880b1..2ff9ed1 100644 --- a/src/service/userService.ts +++ b/src/service/user/userService.ts @@ -1,7 +1,7 @@ -import { dataSource } from "../data-source"; -import { role } from "../entity/role"; -import { user } from "../entity/user"; -import InternalException from "../exceptions/internalException"; +import { dataSource } from "../../data-source"; +import { role } from "../../entity/user/role"; +import { user } from "../../entity/user/user"; +import InternalException from "../../exceptions/internalException"; export default abstract class UserService { /** diff --git a/src/templates/member.list.body.template.html b/src/templates/member.list.body.template.html new file mode 100644 index 0000000..9cb0396 --- /dev/null +++ b/src/templates/member.list.body.template.html @@ -0,0 +1,46 @@ + + + + + Mitgliederliste + + +

Mitgliederliste

+
+ + + {{#each member}} + + + + + {{/each}} +
{{this.firstname}} {{this.lastname}} {{this.nameaffix}}
+ + + diff --git a/src/templates/member.list.footer.template.html b/src/templates/member.list.footer.template.html new file mode 100644 index 0000000..7a3190b --- /dev/null +++ b/src/templates/member.list.footer.template.html @@ -0,0 +1,3 @@ +
+ Seite von +
diff --git a/src/templates/newsletter.body.template.html b/src/templates/newsletter.body.template.html index 941d89e..01433c0 100644 --- a/src/templates/newsletter.body.template.html +++ b/src/templates/newsletter.body.template.html @@ -13,6 +13,7 @@

{{this.formattedStarttime}}: {{this.title}}

{{{this.content}}} +
{{/each}}

diff --git a/src/templates/protocol.body.template.html b/src/templates/protocol.body.template.html index 98a2a21..c37fa75 100644 --- a/src/templates/protocol.body.template.html +++ b/src/templates/protocol.body.template.html @@ -14,11 +14,9 @@

Anwesenheit ({{presence.length}})

-
    - {{#each presence}} -
  • {{this.firstname}} {{this.lastname}}
  • - {{/each}} -
+

{{#each presence}} {{this.firstname}} {{this.lastname}}{{#unless @last}}, {{/unless}} {{/each}}

+

Abwesenheit ({{absent.length}})

+

{{#each absent}} {{this.firstname}} {{this.lastname}}{{#unless @last}}, {{/unless}} {{/each}}


Agenda

{{#each agenda}} diff --git a/src/viewmodel/admin/calendar.models.ts b/src/viewmodel/admin/club/calendar.models.ts similarity index 76% rename from src/viewmodel/admin/calendar.models.ts rename to src/viewmodel/admin/club/calendar.models.ts index b65fb88..77a9622 100644 --- a/src/viewmodel/admin/calendar.models.ts +++ b/src/viewmodel/admin/club/calendar.models.ts @@ -1,4 +1,4 @@ -import { CalendarTypeViewModel } from "./calendarType.models"; +import { CalendarTypeViewModel } from "../settings/calendarType.models"; export interface CalendarViewModel { id: string; diff --git a/src/viewmodel/admin/communication.models.ts b/src/viewmodel/admin/club/member/communication.models.ts similarity index 78% rename from src/viewmodel/admin/communication.models.ts rename to src/viewmodel/admin/club/member/communication.models.ts index b7f9dd7..b6c0b29 100644 --- a/src/viewmodel/admin/communication.models.ts +++ b/src/viewmodel/admin/club/member/communication.models.ts @@ -1,4 +1,4 @@ -import { CommunicationTypeViewModel } from "./communicationType.models"; +import { CommunicationTypeViewModel } from "../../settings/communicationType.models"; export interface CommunicationViewModel { id: number; diff --git a/src/viewmodel/admin/member.models.ts b/src/viewmodel/admin/club/member/member.models.ts similarity index 90% rename from src/viewmodel/admin/member.models.ts rename to src/viewmodel/admin/club/member/member.models.ts index 76f1a9a..60e1a27 100644 --- a/src/viewmodel/admin/member.models.ts +++ b/src/viewmodel/admin/club/member/member.models.ts @@ -1,4 +1,4 @@ -import { Salutation } from "../../enums/salutation"; +import { Salutation } from "../../../../enums/salutation"; import { CommunicationViewModel } from "./communication.models"; import { MembershipViewModel } from "./membership.models"; diff --git a/src/viewmodel/admin/memberAward.models.ts b/src/viewmodel/admin/club/member/memberAward.models.ts similarity index 100% rename from src/viewmodel/admin/memberAward.models.ts rename to src/viewmodel/admin/club/member/memberAward.models.ts diff --git a/src/viewmodel/admin/memberExecutivePosition.models.ts b/src/viewmodel/admin/club/member/memberExecutivePosition.models.ts similarity index 100% rename from src/viewmodel/admin/memberExecutivePosition.models.ts rename to src/viewmodel/admin/club/member/memberExecutivePosition.models.ts diff --git a/src/viewmodel/admin/memberQualification.models.ts b/src/viewmodel/admin/club/member/memberQualification.models.ts similarity index 100% rename from src/viewmodel/admin/memberQualification.models.ts rename to src/viewmodel/admin/club/member/memberQualification.models.ts diff --git a/src/viewmodel/admin/membership.models.ts b/src/viewmodel/admin/club/member/membership.models.ts similarity index 100% rename from src/viewmodel/admin/membership.models.ts rename to src/viewmodel/admin/club/member/membership.models.ts diff --git a/src/viewmodel/admin/newsletter.models.ts b/src/viewmodel/admin/club/newsletter/newsletter.models.ts similarity index 79% rename from src/viewmodel/admin/newsletter.models.ts rename to src/viewmodel/admin/club/newsletter/newsletter.models.ts index cfd8b42..9cf9bb6 100644 --- a/src/viewmodel/admin/newsletter.models.ts +++ b/src/viewmodel/admin/club/newsletter/newsletter.models.ts @@ -1,4 +1,4 @@ -import { QueryStoreViewModel } from "./queryStore.models"; +import { QueryStoreViewModel } from "../../settings/queryStore.models"; export interface NewsletterViewModel { id: number; diff --git a/src/viewmodel/admin/newsletterDates.models.ts b/src/viewmodel/admin/club/newsletter/newsletterDates.models.ts similarity index 76% rename from src/viewmodel/admin/newsletterDates.models.ts rename to src/viewmodel/admin/club/newsletter/newsletterDates.models.ts index 074056d..b8254ca 100644 --- a/src/viewmodel/admin/newsletterDates.models.ts +++ b/src/viewmodel/admin/club/newsletter/newsletterDates.models.ts @@ -1,4 +1,4 @@ -import { CalendarViewModel } from "./calendar.models"; +import { CalendarViewModel } from "../calendar.models"; export interface NewsletterDatesViewModel { newsletterId: number; diff --git a/src/viewmodel/admin/newsletterRecipients.models.ts b/src/viewmodel/admin/club/newsletter/newsletterRecipients.models.ts similarity index 67% rename from src/viewmodel/admin/newsletterRecipients.models.ts rename to src/viewmodel/admin/club/newsletter/newsletterRecipients.models.ts index a1030a7..7db108a 100644 --- a/src/viewmodel/admin/newsletterRecipients.models.ts +++ b/src/viewmodel/admin/club/newsletter/newsletterRecipients.models.ts @@ -1,4 +1,4 @@ -import { MemberViewModel } from "./member.models"; +import { MemberViewModel } from "../member/member.models"; export interface NewsletterRecipientsViewModel { newsletterId: number; diff --git a/src/viewmodel/admin/protocol.models.ts b/src/viewmodel/admin/club/protocol/protocol.models.ts similarity index 100% rename from src/viewmodel/admin/protocol.models.ts rename to src/viewmodel/admin/club/protocol/protocol.models.ts diff --git a/src/viewmodel/admin/protocolAgenda.models.ts b/src/viewmodel/admin/club/protocol/protocolAgenda.models.ts similarity index 100% rename from src/viewmodel/admin/protocolAgenda.models.ts rename to src/viewmodel/admin/club/protocol/protocolAgenda.models.ts diff --git a/src/viewmodel/admin/protocolDecision.models.ts b/src/viewmodel/admin/club/protocol/protocolDecision.models.ts similarity index 100% rename from src/viewmodel/admin/protocolDecision.models.ts rename to src/viewmodel/admin/club/protocol/protocolDecision.models.ts diff --git a/src/viewmodel/admin/protocolPresence.models.ts b/src/viewmodel/admin/club/protocol/protocolPresence.models.ts similarity index 53% rename from src/viewmodel/admin/protocolPresence.models.ts rename to src/viewmodel/admin/club/protocol/protocolPresence.models.ts index 9c10f59..476dc99 100644 --- a/src/viewmodel/admin/protocolPresence.models.ts +++ b/src/viewmodel/admin/club/protocol/protocolPresence.models.ts @@ -1,7 +1,7 @@ -import { MemberViewModel } from "./member.models"; +import { MemberViewModel } from "../member/member.models"; export interface ProtocolPresenceViewModel { memberId: number; - member: MemberViewModel; + absent: boolean; protocolId: number; } diff --git a/src/viewmodel/admin/protocolPrintout.models.ts b/src/viewmodel/admin/club/protocol/protocolPrintout.models.ts similarity index 100% rename from src/viewmodel/admin/protocolPrintout.models.ts rename to src/viewmodel/admin/club/protocol/protocolPrintout.models.ts diff --git a/src/viewmodel/admin/protocolVoting.models.ts b/src/viewmodel/admin/club/protocol/protocolVoting.models.ts similarity index 100% rename from src/viewmodel/admin/protocolVoting.models.ts rename to src/viewmodel/admin/club/protocol/protocolVoting.models.ts diff --git a/src/viewmodel/admin/award.models.ts b/src/viewmodel/admin/settings/award.models.ts similarity index 100% rename from src/viewmodel/admin/award.models.ts rename to src/viewmodel/admin/settings/award.models.ts diff --git a/src/viewmodel/admin/calendarType.models.ts b/src/viewmodel/admin/settings/calendarType.models.ts similarity index 100% rename from src/viewmodel/admin/calendarType.models.ts rename to src/viewmodel/admin/settings/calendarType.models.ts diff --git a/src/viewmodel/admin/communicationType.models.ts b/src/viewmodel/admin/settings/communicationType.models.ts similarity index 64% rename from src/viewmodel/admin/communicationType.models.ts rename to src/viewmodel/admin/settings/communicationType.models.ts index 845b555..a4b8881 100644 --- a/src/viewmodel/admin/communicationType.models.ts +++ b/src/viewmodel/admin/settings/communicationType.models.ts @@ -1,4 +1,4 @@ -import { CommunicationFieldType } from "../../type/fieldTypes"; +import { CommunicationFieldType } from "../../../type/fieldTypes"; export interface CommunicationTypeViewModel { id: number; diff --git a/src/viewmodel/admin/executivePosition.models.ts b/src/viewmodel/admin/settings/executivePosition.models.ts similarity index 100% rename from src/viewmodel/admin/executivePosition.models.ts rename to src/viewmodel/admin/settings/executivePosition.models.ts diff --git a/src/viewmodel/admin/membershipStatus.models.ts b/src/viewmodel/admin/settings/membershipStatus.models.ts similarity index 100% rename from src/viewmodel/admin/membershipStatus.models.ts rename to src/viewmodel/admin/settings/membershipStatus.models.ts diff --git a/src/viewmodel/admin/newsletterConfig.models.ts b/src/viewmodel/admin/settings/newsletterConfig.models.ts similarity index 73% rename from src/viewmodel/admin/newsletterConfig.models.ts rename to src/viewmodel/admin/settings/newsletterConfig.models.ts index d21e4bf..3538bfe 100644 --- a/src/viewmodel/admin/newsletterConfig.models.ts +++ b/src/viewmodel/admin/settings/newsletterConfig.models.ts @@ -1,4 +1,4 @@ -import { NewsletterConfigType } from "../../enums/newsletterConfigType"; +import { NewsletterConfigType } from "../../../enums/newsletterConfigType"; import { CommunicationTypeViewModel } from "./communicationType.models"; export interface NewsletterConfigViewModel { diff --git a/src/viewmodel/admin/qualification.models.ts b/src/viewmodel/admin/settings/qualification.models.ts similarity index 100% rename from src/viewmodel/admin/qualification.models.ts rename to src/viewmodel/admin/settings/qualification.models.ts diff --git a/src/viewmodel/admin/queryStore.models.ts b/src/viewmodel/admin/settings/queryStore.models.ts similarity index 61% rename from src/viewmodel/admin/queryStore.models.ts rename to src/viewmodel/admin/settings/queryStore.models.ts index ff697c6..2e8ce4a 100644 --- a/src/viewmodel/admin/queryStore.models.ts +++ b/src/viewmodel/admin/settings/queryStore.models.ts @@ -1,4 +1,4 @@ -import { DynamicQueryStructure } from "../../type/dynamicQueries"; +import { DynamicQueryStructure } from "../../../type/dynamicQueries"; export interface QueryStoreViewModel { id: number; diff --git a/src/viewmodel/admin/template.models.ts b/src/viewmodel/admin/settings/template.models.ts similarity index 100% rename from src/viewmodel/admin/template.models.ts rename to src/viewmodel/admin/settings/template.models.ts diff --git a/src/viewmodel/admin/templateUsage.models.ts b/src/viewmodel/admin/settings/templateUsage.models.ts similarity index 66% rename from src/viewmodel/admin/templateUsage.models.ts rename to src/viewmodel/admin/settings/templateUsage.models.ts index 8783eac..d5f6e0f 100644 --- a/src/viewmodel/admin/templateUsage.models.ts +++ b/src/viewmodel/admin/settings/templateUsage.models.ts @@ -1,7 +1,7 @@ -import { PermissionModule } from "../../type/permissionTypes"; +import { PermissionModule } from "../../../type/permissionTypes"; export interface TemplateUsageViewModel { - scope: PermissionModule; + scope: `${PermissionModule}`|`${PermissionModule}.${string}`; header: { id: number; template: string } | null; body: { id: number; template: string } | null; footer: { id: number; template: string } | null; diff --git a/src/viewmodel/admin/invite.models.ts b/src/viewmodel/admin/user/invite.models.ts similarity index 100% rename from src/viewmodel/admin/invite.models.ts rename to src/viewmodel/admin/user/invite.models.ts diff --git a/src/viewmodel/admin/role.models.ts b/src/viewmodel/admin/user/role.models.ts similarity index 60% rename from src/viewmodel/admin/role.models.ts rename to src/viewmodel/admin/user/role.models.ts index c810ca2..ba0e76a 100644 --- a/src/viewmodel/admin/role.models.ts +++ b/src/viewmodel/admin/user/role.models.ts @@ -1,4 +1,4 @@ -import { PermissionObject } from "../../type/permissionTypes"; +import { PermissionObject } from "../../../type/permissionTypes"; export interface RoleViewModel { id: number; diff --git a/src/viewmodel/admin/user.models.ts b/src/viewmodel/admin/user/user.models.ts similarity index 81% rename from src/viewmodel/admin/user.models.ts rename to src/viewmodel/admin/user/user.models.ts index df6eaa3..8bc495b 100644 --- a/src/viewmodel/admin/user.models.ts +++ b/src/viewmodel/admin/user/user.models.ts @@ -1,4 +1,4 @@ -import { PermissionObject } from "../../type/permissionTypes"; +import { PermissionObject } from "../../../type/permissionTypes"; import { RoleViewModel } from "./role.models"; export interface UserViewModel { diff --git a/src/views/memberExecutivePositionView.ts b/src/views/memberExecutivePositionView.ts index ffc859e..23722cb 100644 --- a/src/views/memberExecutivePositionView.ts +++ b/src/views/memberExecutivePositionView.ts @@ -1,5 +1,5 @@ import { DataSource, ViewColumn, ViewEntity } from "typeorm"; -import { memberExecutivePositions } from "../entity/memberExecutivePositions"; +import { memberExecutivePositions } from "../entity/club/member/memberExecutivePositions"; import { Salutation } from "../enums/salutation"; @ViewEntity({ diff --git a/src/views/memberQualificationsView.ts b/src/views/memberQualificationsView.ts index 9cd8bd6..4ae436d 100644 --- a/src/views/memberQualificationsView.ts +++ b/src/views/memberQualificationsView.ts @@ -1,5 +1,5 @@ import { DataSource, ViewColumn, ViewEntity } from "typeorm"; -import { memberQualifications } from "../entity/memberQualifications"; +import { memberQualifications } from "../entity/club/member/memberQualifications"; import { Salutation } from "../enums/salutation"; @ViewEntity({ diff --git a/src/views/memberView.ts b/src/views/memberView.ts index 08f147c..1743ed4 100644 --- a/src/views/memberView.ts +++ b/src/views/memberView.ts @@ -1,5 +1,5 @@ import { DataSource, ViewColumn, ViewEntity } from "typeorm"; -import { member } from "../entity/member"; +import { member } from "../entity/club/member/member"; import { Salutation } from "../enums/salutation"; @ViewEntity({ @@ -14,7 +14,8 @@ import { Salutation } from "../enums/salutation"; .addSelect("member.nameaffix", "nameaffix") .addSelect("member.birthdate", "birthdate") .addSelect("TIMESTAMPDIFF(YEAR, member.birthdate, CURDATE())", "todayAge") - .addSelect("YEAR(CURDATE()) - YEAR(member.birthdate)", "ageThisYear"), + .addSelect("YEAR(CURDATE()) - YEAR(member.birthdate)", "ageThisYear") + .addSelect("CONCAT('_', FROM_DAYS(TIMESTAMPDIFF(DAY, member.birthdate, CURDATE())))", "exactAge"), }) export class memberView { @ViewColumn() @@ -40,4 +41,7 @@ export class memberView { @ViewColumn() ageThisYear: number; + + @ViewColumn() + exactAge: Date; } diff --git a/src/views/membershipsView.ts b/src/views/membershipsView.ts index 6d72bcc..2beb33f 100644 --- a/src/views/membershipsView.ts +++ b/src/views/membershipsView.ts @@ -1,5 +1,5 @@ import { DataSource, ViewColumn, ViewEntity } from "typeorm"; -import { membership } from "../entity/membership"; +import { membership } from "../entity/club/member/membership"; import { Salutation } from "../enums/salutation"; @ViewEntity({ @@ -16,6 +16,10 @@ import { Salutation } from "../enums/salutation"; .addSelect("member.nameaffix", "memberNameaffix") .addSelect("member.birthdate", "memberBirthdate") .addSelect("SUM(TIMESTAMPDIFF(DAY, membership.start, COALESCE(membership.end, CURRENT_DATE)))", "durationInDays") + .addSelect( + "CONCAT('_', FROM_DAYS(SUM(TIMESTAMPDIFF(DAY, membership.start, COALESCE(membership.end, CURRENT_DATE)))))", + "durationInYears" + ) .leftJoin("membership.status", "status") .leftJoin("membership.member", "member") .groupBy("status.id"), @@ -24,6 +28,9 @@ export class membershipView { @ViewColumn() durationInDays: number; + @ViewColumn() + durationInYears: Date; + @ViewColumn() status: string;