fix newsletter routing and service
This commit is contained in:
parent
6dcd650cad
commit
dad54c97ed
4 changed files with 12 additions and 13 deletions
|
@ -177,10 +177,6 @@ export async function synchronizeNewsletterById(req: Request, res: Response): Pr
|
||||||
};
|
};
|
||||||
await NewsletterCommandHandler.sync(syncNewsletter);
|
await NewsletterCommandHandler.sync(syncNewsletter);
|
||||||
|
|
||||||
if (recipientsByQueryId) {
|
|
||||||
// TODO! set all recipients to query selection
|
|
||||||
}
|
|
||||||
|
|
||||||
res.sendStatus(204);
|
res.sendStatus(204);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@ export class newsletter {
|
||||||
@Column({ type: "boolean", default: false })
|
@Column({ type: "boolean", default: false })
|
||||||
isSent: boolean;
|
isSent: boolean;
|
||||||
|
|
||||||
|
@Column({ type: "int", nullable: true })
|
||||||
|
recipientsByQueryId?: number;
|
||||||
|
|
||||||
@OneToMany(() => newsletterDates, (dates) => dates.newsletter)
|
@OneToMany(() => newsletterDates, (dates) => dates.newsletter)
|
||||||
dates: newsletterDates[];
|
dates: newsletterDates[];
|
||||||
|
|
||||||
|
|
|
@ -24,19 +24,19 @@ router.get("/:id", async (req: Request, res: Response) => {
|
||||||
await getNewsletterById(req, res);
|
await getNewsletterById(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/:protocolId/dates", async (req: Request, res: Response) => {
|
router.get("/:newsletterId/dates", async (req: Request, res: Response) => {
|
||||||
await getNewsletterDatesById(req, res);
|
await getNewsletterDatesById(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/:protocolId/recipients", async (req: Request, res: Response) => {
|
router.get("/:newsletterId/recipients", async (req: Request, res: Response) => {
|
||||||
await getNewsletterRecipientsById(req, res);
|
await getNewsletterRecipientsById(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/:protocolId/printouts", async (req: Request, res: Response) => {
|
router.get("/:newsletterId/printouts", async (req: Request, res: Response) => {
|
||||||
await getNewsletterPrintoutsById(req, res);
|
await getNewsletterPrintoutsById(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/:protocolId/printout/:filename", async (req: Request, res: Response) => {
|
router.get("/:newsletterId/printout/:filename", async (req: Request, res: Response) => {
|
||||||
await getNewsletterPrintoutByIdAndPrint(req, res);
|
await getNewsletterPrintoutByIdAndPrint(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ router.post(
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/:protocolId/printout",
|
"/:newsletterId/printout",
|
||||||
PermissionHelper.passCheckMiddleware("create", "club", "protocol"),
|
PermissionHelper.passCheckMiddleware("create", "club", "protocol"),
|
||||||
async (req: Request, res: Response) => {
|
async (req: Request, res: Response) => {
|
||||||
await createNewsletterPrintoutById(req, res);
|
await createNewsletterPrintoutById(req, res);
|
||||||
|
@ -65,7 +65,7 @@ router.patch(
|
||||||
);
|
);
|
||||||
|
|
||||||
router.patch(
|
router.patch(
|
||||||
"/:protocolId/synchronize/dates",
|
"/:newsletterId/synchronize/dates",
|
||||||
PermissionHelper.passCheckMiddleware("update", "club", "protocol"),
|
PermissionHelper.passCheckMiddleware("update", "club", "protocol"),
|
||||||
async (req: Request, res: Response) => {
|
async (req: Request, res: Response) => {
|
||||||
await synchronizeNewsletterDatesById(req, res);
|
await synchronizeNewsletterDatesById(req, res);
|
||||||
|
@ -73,7 +73,7 @@ router.patch(
|
||||||
);
|
);
|
||||||
|
|
||||||
router.patch(
|
router.patch(
|
||||||
"/:protocolId/synchronize/recipients",
|
"/:newsletterId/synchronize/recipients",
|
||||||
PermissionHelper.passCheckMiddleware("update", "club", "protocol"),
|
PermissionHelper.passCheckMiddleware("update", "club", "protocol"),
|
||||||
async (req: Request, res: Response) => {
|
async (req: Request, res: Response) => {
|
||||||
await synchronizeNewsletterRecipientsById(req, res);
|
await synchronizeNewsletterRecipientsById(req, res);
|
||||||
|
|
|
@ -16,13 +16,13 @@ export default abstract class NewsletterRecipientsService {
|
||||||
.leftJoinAndSelect("member.sendNewsletter", "sendNewsletter")
|
.leftJoinAndSelect("member.sendNewsletter", "sendNewsletter")
|
||||||
.leftJoinAndSelect("sendNewsletter.type", "communicationtype")
|
.leftJoinAndSelect("sendNewsletter.type", "communicationtype")
|
||||||
.leftJoinAndSelect("newsletterRecipients.newsletter", "newsletter")
|
.leftJoinAndSelect("newsletterRecipients.newsletter", "newsletter")
|
||||||
.where("newsletterDates.newsletterId = :id", { id: newsletterId })
|
.where("newsletterRecipients.newsletterId = :id", { id: newsletterId })
|
||||||
.getMany()
|
.getMany()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
throw new InternalException("newsletterRecipientss not found", err);
|
throw new InternalException("newsletterRecipients not found", err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue