Compare commits
4 commits
03036c8b77
...
e738be4e13
Author | SHA1 | Date | |
---|---|---|---|
e738be4e13 | |||
c9b8c3090d | |||
a2cc408e85 | |||
d206d7a77c |
15 changed files with 49 additions and 66 deletions
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,3 @@ export interface SetNewsletterConfigCommand {
|
|||
comTypeId: number;
|
||||
config: NewsletterConfigType;
|
||||
}
|
||||
|
||||
export interface DeleteNewsletterConfigCommand {
|
||||
comTypeId: number;
|
||||
}
|
||||
|
|
|
@ -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<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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<any> {
|
||||
const comTypeId = parseInt(req.params.comTypeId);
|
||||
|
||||
let deleteNewsletterConfig: DeleteNewsletterConfigCommand = {
|
||||
comTypeId: comTypeId,
|
||||
};
|
||||
await NewsletterConfigCommandHandler.delete(deleteNewsletterConfig);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 })
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue