Compare commits

..

No commits in common. "e738be4e13f7e35a4c3d306737d1ab4e74301c11" and "03036c8b77cc82e3dc90009adead1726a5421f31" have entirely different histories.

15 changed files with 66 additions and 49 deletions

View file

@ -31,7 +31,7 @@ export default abstract class MembershipCommandHandler {
.createQueryBuilder() .createQueryBuilder()
.update(membership) .update(membership)
.set({ .set({
end: new Date(new Date(createMembership.start).setDate(new Date(createMembership.start).getDate() - 1)), end: new Date(createMembership.start).setDate(new Date(createMembership.start).getDate() - 1),
terminationReason: "beendet durch neuen Eintrag.", terminationReason: "beendet durch neuen Eintrag.",
}) })
.where("end IS NULL") .where("end IS NULL")

View file

@ -60,10 +60,7 @@ export default abstract class AwardCommandHandler {
.execute() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException( throw new InternalException("Failed deleting award", err);
`Failed deleting award ${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`,
err
);
}); });
} }
} }

View file

@ -66,10 +66,7 @@ export default abstract class CalendarTypeCommandHandler {
.execute() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException( throw new InternalException("Failed deleting calendarType", err);
`Failed deleting calendarType${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`,
err
);
}); });
} }
} }

View file

@ -66,12 +66,7 @@ export default abstract class CommunicationTypeCommandHandler {
.execute() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException( throw new InternalException("Failed deleting communicationType", err);
`Failed deleting communicationType${
err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""
}`,
err
);
}); });
} }
} }

View file

@ -64,12 +64,7 @@ export default abstract class ExecutivePositionCommandHandler {
.execute() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException( throw new InternalException("Failed deleting executivePosition", err);
`Failed deleting executivePosition${
err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""
}`,
err
);
}); });
} }
} }

View file

@ -64,12 +64,7 @@ export default abstract class MembershipStatusCommandHandler {
.execute() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException( throw new InternalException("Failed deleting membershipStatus", err);
`Failed deleting membershipStatus${
err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""
}`,
err
);
}); });
} }
} }

View file

@ -4,3 +4,7 @@ export interface SetNewsletterConfigCommand {
comTypeId: number; comTypeId: number;
config: NewsletterConfigType; config: NewsletterConfigType;
} }
export interface DeleteNewsletterConfigCommand {
comTypeId: number;
}

View file

@ -1,7 +1,7 @@
import { dataSource } from "../../../data-source"; import { dataSource } from "../../../data-source";
import { newsletterConfig } from "../../../entity/settings/newsletterConfig"; import { newsletterConfig } from "../../../entity/settings/newsletterConfig";
import InternalException from "../../../exceptions/internalException"; import InternalException from "../../../exceptions/internalException";
import { SetNewsletterConfigCommand } from "./newsletterConfigCommand"; import { DeleteNewsletterConfigCommand, SetNewsletterConfigCommand } from "./newsletterConfigCommand";
export default abstract class NewsletterConfigCommandHandler { export default abstract class NewsletterConfigCommandHandler {
/** /**
@ -27,4 +27,21 @@ export default abstract class NewsletterConfigCommandHandler {
throw new InternalException("Failed setting newsletterConfig", err); throw new InternalException("Failed setting newsletterConfig", err);
}); });
} }
/**
* @description delete newsletterConfig
* @param {DeleteNewsletterConfigCommand} deleteNewsletterConfig
* @returns {Promise<void>}
*/
static async delete(deleteNewsletterConfig: DeleteNewsletterConfigCommand): Promise<void> {
return await dataSource
.createQueryBuilder()
.delete()
.from(newsletterConfig)
.where("comTypeId = :comTypeId", { comTypeId: deleteNewsletterConfig.comTypeId })
.execute()
.then(() => {})
.catch((err) => {
throw new InternalException("Failed setting newsletterConfig", err);
});
}
} }

View file

@ -66,10 +66,7 @@ export default abstract class QualificationCommandHandler {
.execute() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException( throw new InternalException("Failed deleting qualification", err);
`Failed deleting qualification${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`,
err
);
}); });
} }
} }

View file

@ -63,10 +63,7 @@ export default abstract class QueryStoreCommandHandler {
.execute() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException( throw new InternalException("Failed deleting queryStore", err);
`Failed deleting queryStore${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`,
err
);
}); });
} }
} }

View file

@ -64,10 +64,7 @@ export default abstract class TemplateCommandHandler {
.execute() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException( throw new InternalException("Failed deleting template", err);
`Failed deleting template${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`,
err
);
}); });
} }
} }

View file

@ -2,7 +2,7 @@ import { Request, Response } from "express";
import NewsletterConfigService from "../../../service/settings/newsletterConfigService"; import NewsletterConfigService from "../../../service/settings/newsletterConfigService";
import NewsletterConfigFactory from "../../../factory/admin/settings/newsletterConfig"; import NewsletterConfigFactory from "../../../factory/admin/settings/newsletterConfig";
import NewsletterConfigCommandHandler from "../../../command/settings/newsletterConfig/newsletterConfigCommandHandler"; import NewsletterConfigCommandHandler from "../../../command/settings/newsletterConfig/newsletterConfigCommandHandler";
import { SetNewsletterConfigCommand } from "../../../command/settings/newsletterConfig/newsletterConfigCommand"; import { DeleteNewsletterConfigCommand, SetNewsletterConfigCommand } from "../../../command/settings/newsletterConfig/newsletterConfigCommand";
/** /**
* @description get all newsletterConfigs * @description get all newsletterConfigs
@ -47,3 +47,20 @@ export async function setNewsletterConfig(req: Request, res: Response): Promise<
res.send(id); 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<any> {
const comTypeId = parseInt(req.params.comTypeId);
let deleteNewsletterConfig: DeleteNewsletterConfigCommand = {
comTypeId: comTypeId,
};
await NewsletterConfigCommandHandler.delete(deleteNewsletterConfig);
res.sendStatus(204);
}

View file

@ -40,17 +40,17 @@ export class communication {
@Column() @Column()
typeId: number; typeId: number;
@ManyToOne(() => member, (member) => member.awards, {
nullable: false,
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
member: member;
@ManyToOne(() => communicationType, (communicationType) => communicationType.communications, { @ManyToOne(() => communicationType, (communicationType) => communicationType.communications, {
nullable: false, nullable: false,
onDelete: "RESTRICT", onDelete: "RESTRICT",
onUpdate: "RESTRICT", onUpdate: "RESTRICT",
}) })
type: communicationType; type: communicationType;
@ManyToOne(() => member, (member) => member.awards, {
nullable: false,
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
member: member;
} }

View file

@ -9,7 +9,7 @@ export class protocolPrintout {
@Column({ type: "varchar", length: 255 }) @Column({ type: "varchar", length: 255 })
title: string; title: string;
@Column({ type: "int", default: "1" }) @Column({ type: "int" })
iteration: number; iteration: number;
@Column({ type: "varchar", length: 255 }) @Column({ type: "varchar", length: 255 })

View file

@ -1,5 +1,6 @@
import express, { Request, Response } from "express"; import express, { Request, Response } from "express";
import { import {
deleteNewsletterConfig,
getAllNewsletterConfigs, getAllNewsletterConfigs,
getNewsletterConfigById, getNewsletterConfigById,
setNewsletterConfig, setNewsletterConfig,
@ -24,4 +25,12 @@ router.put(
} }
); );
router.delete(
"/:comTypeId",
PermissionHelper.passCheckMiddleware("create", "settings", "newsletter_config"),
async (req: Request, res: Response) => {
await deleteNewsletterConfig(req, res);
}
);
export default router; export default router;