diff --git a/src/command/club/member/membershipCommandHandler.ts b/src/command/club/member/membershipCommandHandler.ts index 602d6d7..0cd0e5a 100644 --- a/src/command/club/member/membershipCommandHandler.ts +++ b/src/command/club/member/membershipCommandHandler.ts @@ -31,7 +31,7 @@ export default abstract class MembershipCommandHandler { .createQueryBuilder() .update(membership) .set({ - end: new Date(createMembership.start).setDate(new Date(createMembership.start).getDate() - 1), + end: new Date(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/settings/award/awardCommandHandler.ts b/src/command/settings/award/awardCommandHandler.ts index af0000f..2a525a9 100644 --- a/src/command/settings/award/awardCommandHandler.ts +++ b/src/command/settings/award/awardCommandHandler.ts @@ -60,7 +60,10 @@ export default abstract class AwardCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting award", err); + throw new InternalException( + `Failed deleting award ${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`, + err + ); }); } } diff --git a/src/command/settings/calendarType/calendarTypeCommandHandler.ts b/src/command/settings/calendarType/calendarTypeCommandHandler.ts index bc20d6a..702728d 100644 --- a/src/command/settings/calendarType/calendarTypeCommandHandler.ts +++ b/src/command/settings/calendarType/calendarTypeCommandHandler.ts @@ -66,7 +66,10 @@ export default abstract class CalendarTypeCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting calendarType", err); + throw new InternalException( + `Failed deleting calendarType${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`, + err + ); }); } } diff --git a/src/command/settings/communicationType/communicationTypeCommandHandler.ts b/src/command/settings/communicationType/communicationTypeCommandHandler.ts index 04c7f10..df11e20 100644 --- a/src/command/settings/communicationType/communicationTypeCommandHandler.ts +++ b/src/command/settings/communicationType/communicationTypeCommandHandler.ts @@ -66,7 +66,12 @@ export default abstract class CommunicationTypeCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting communicationType", err); + throw new InternalException( + `Failed deleting communicationType${ + err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : "" + }`, + err + ); }); } } diff --git a/src/command/settings/executivePosition/executivePositionCommandHandler.ts b/src/command/settings/executivePosition/executivePositionCommandHandler.ts index d1be38d..14a31a5 100644 --- a/src/command/settings/executivePosition/executivePositionCommandHandler.ts +++ b/src/command/settings/executivePosition/executivePositionCommandHandler.ts @@ -64,7 +64,12 @@ export default abstract class ExecutivePositionCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting executivePosition", err); + throw new InternalException( + `Failed deleting executivePosition${ + err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : "" + }`, + err + ); }); } } diff --git a/src/command/settings/membershipStatus/membershipStatusCommandHandler.ts b/src/command/settings/membershipStatus/membershipStatusCommandHandler.ts index bc9f30f..7e5e953 100644 --- a/src/command/settings/membershipStatus/membershipStatusCommandHandler.ts +++ b/src/command/settings/membershipStatus/membershipStatusCommandHandler.ts @@ -64,7 +64,12 @@ export default abstract class MembershipStatusCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting membershipStatus", err); + throw new InternalException( + `Failed deleting membershipStatus${ + err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : "" + }`, + err + ); }); } } diff --git a/src/command/settings/newsletterConfig/newsletterConfigCommand.ts b/src/command/settings/newsletterConfig/newsletterConfigCommand.ts index f07de54..be28649 100644 --- a/src/command/settings/newsletterConfig/newsletterConfigCommand.ts +++ b/src/command/settings/newsletterConfig/newsletterConfigCommand.ts @@ -4,7 +4,3 @@ export interface SetNewsletterConfigCommand { comTypeId: number; config: NewsletterConfigType; } - -export interface DeleteNewsletterConfigCommand { - comTypeId: number; -} diff --git a/src/command/settings/newsletterConfig/newsletterConfigCommandHandler.ts b/src/command/settings/newsletterConfig/newsletterConfigCommandHandler.ts index 56b41bd..4f26df4 100644 --- a/src/command/settings/newsletterConfig/newsletterConfigCommandHandler.ts +++ b/src/command/settings/newsletterConfig/newsletterConfigCommandHandler.ts @@ -1,7 +1,7 @@ import { dataSource } from "../../../data-source"; import { newsletterConfig } from "../../../entity/settings/newsletterConfig"; import InternalException from "../../../exceptions/internalException"; -import { DeleteNewsletterConfigCommand, SetNewsletterConfigCommand } from "./newsletterConfigCommand"; +import { SetNewsletterConfigCommand } from "./newsletterConfigCommand"; export default abstract class NewsletterConfigCommandHandler { /** @@ -27,21 +27,4 @@ export default abstract class NewsletterConfigCommandHandler { throw new InternalException("Failed setting newsletterConfig", err); }); } - /** - * @description delete newsletterConfig - * @param {DeleteNewsletterConfigCommand} deleteNewsletterConfig - * @returns {Promise} - */ - static async delete(deleteNewsletterConfig: DeleteNewsletterConfigCommand): Promise { - return await dataSource - .createQueryBuilder() - .delete() - .from(newsletterConfig) - .where("comTypeId = :comTypeId", { comTypeId: deleteNewsletterConfig.comTypeId }) - .execute() - .then(() => {}) - .catch((err) => { - throw new InternalException("Failed setting newsletterConfig", err); - }); - } } diff --git a/src/command/settings/qualification/qualificationCommandHandler.ts b/src/command/settings/qualification/qualificationCommandHandler.ts index 0abd401..b0b9f22 100644 --- a/src/command/settings/qualification/qualificationCommandHandler.ts +++ b/src/command/settings/qualification/qualificationCommandHandler.ts @@ -66,7 +66,10 @@ export default abstract class QualificationCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting qualification", err); + throw new InternalException( + `Failed deleting qualification${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`, + err + ); }); } } diff --git a/src/command/settings/queryStore/queryStoreCommandHandler.ts b/src/command/settings/queryStore/queryStoreCommandHandler.ts index 3776b5e..e8c6917 100644 --- a/src/command/settings/queryStore/queryStoreCommandHandler.ts +++ b/src/command/settings/queryStore/queryStoreCommandHandler.ts @@ -63,7 +63,10 @@ export default abstract class QueryStoreCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting queryStore", err); + throw new InternalException( + `Failed deleting queryStore${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`, + err + ); }); } } diff --git a/src/command/settings/template/templateCommandHandler.ts b/src/command/settings/template/templateCommandHandler.ts index 54ea6f7..6a88353 100644 --- a/src/command/settings/template/templateCommandHandler.ts +++ b/src/command/settings/template/templateCommandHandler.ts @@ -64,7 +64,10 @@ export default abstract class TemplateCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting template", err); + throw new InternalException( + `Failed deleting template${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`, + err + ); }); } } diff --git a/src/controller/admin/settings/newsletterConfigController.ts b/src/controller/admin/settings/newsletterConfigController.ts index f047816..7d0ff95 100644 --- a/src/controller/admin/settings/newsletterConfigController.ts +++ b/src/controller/admin/settings/newsletterConfigController.ts @@ -2,7 +2,7 @@ import { Request, Response } from "express"; 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"; +import { SetNewsletterConfigCommand } from "../../../command/settings/newsletterConfig/newsletterConfigCommand"; /** * @description get all newsletterConfigs @@ -47,20 +47,3 @@ export async function setNewsletterConfig(req: Request, res: Response): Promise< res.send(id); } - -/** - * @description delete award - * @param req {Request} Express req object - * @param res {Response} Express res object - * @returns {Promise<*>} - */ -export async function deleteNewsletterConfig(req: Request, res: Response): Promise { - const comTypeId = parseInt(req.params.comTypeId); - - let deleteNewsletterConfig: DeleteNewsletterConfigCommand = { - comTypeId: comTypeId, - }; - await NewsletterConfigCommandHandler.delete(deleteNewsletterConfig); - - res.sendStatus(204); -} diff --git a/src/entity/club/member/communication.ts b/src/entity/club/member/communication.ts index 42b1bd7..f50d1a9 100644 --- a/src/entity/club/member/communication.ts +++ b/src/entity/club/member/communication.ts @@ -40,17 +40,17 @@ export class communication { @Column() typeId: number; - @ManyToOne(() => communicationType, (communicationType) => communicationType.communications, { - nullable: false, - onDelete: "RESTRICT", - onUpdate: "RESTRICT", - }) - type: communicationType; - @ManyToOne(() => member, (member) => member.awards, { nullable: false, onDelete: "CASCADE", onUpdate: "RESTRICT", }) member: member; + + @ManyToOne(() => communicationType, (communicationType) => communicationType.communications, { + nullable: false, + onDelete: "RESTRICT", + onUpdate: "RESTRICT", + }) + type: communicationType; } diff --git a/src/entity/club/protocol/protocolPrintout.ts b/src/entity/club/protocol/protocolPrintout.ts index 311b407..a369ccb 100644 --- a/src/entity/club/protocol/protocolPrintout.ts +++ b/src/entity/club/protocol/protocolPrintout.ts @@ -9,7 +9,7 @@ export class protocolPrintout { @Column({ type: "varchar", length: 255 }) title: string; - @Column({ type: "int" }) + @Column({ type: "int", default: "1" }) iteration: number; @Column({ type: "varchar", length: 255 }) diff --git a/src/routes/admin/settings/newsletterConfig.ts b/src/routes/admin/settings/newsletterConfig.ts index a874cc7..94fe205 100644 --- a/src/routes/admin/settings/newsletterConfig.ts +++ b/src/routes/admin/settings/newsletterConfig.ts @@ -1,6 +1,5 @@ import express, { Request, Response } from "express"; import { - deleteNewsletterConfig, getAllNewsletterConfigs, getNewsletterConfigById, setNewsletterConfig, @@ -25,12 +24,4 @@ router.put( } ); -router.delete( - "/:comTypeId", - PermissionHelper.passCheckMiddleware("create", "settings", "newsletter_config"), - async (req: Request, res: Response) => { - await deleteNewsletterConfig(req, res); - } -); - export default router;