newsletter config CRUD
This commit is contained in:
parent
01ce3fdd39
commit
7d36ed3121
14 changed files with 274 additions and 1 deletions
49
src/controller/admin/newsletterConfigController.ts
Normal file
49
src/controller/admin/newsletterConfigController.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { Request, Response } from "express";
|
||||
import NewsletterConfigService from "../../service/newsletterConfigService";
|
||||
import NewsletterConfigFactory from "../../factory/admin/newsletterConfig";
|
||||
import NewsletterConfigCommandHandler from "../../command/newsletterConfigCommandHandler";
|
||||
import { SetNewsletterConfigCommand } from "../../command/newsletterConfigCommand";
|
||||
|
||||
/**
|
||||
* @description get all newsletterConfigs
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getAllNewsletterConfigs(req: Request, res: Response): Promise<any> {
|
||||
let newsletterConfigs = await NewsletterConfigService.getAll();
|
||||
|
||||
res.json(NewsletterConfigFactory.mapToBase(newsletterConfigs));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get newsletterConfig by id
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getNewsletterConfigById(req: Request, res: Response): Promise<any> {
|
||||
let comId = parseInt(req.params.comId);
|
||||
let newsletterConfig = await NewsletterConfigService.getByComId(comId);
|
||||
|
||||
res.json(NewsletterConfigFactory.mapToSingle(newsletterConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description set newsletterConfig
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function setNewsletterConfig(req: Request, res: Response): Promise<any> {
|
||||
let comTypeId = req.body.comTypeId;
|
||||
let config = req.body.config;
|
||||
|
||||
let createNewsletterConfig: SetNewsletterConfigCommand = {
|
||||
comTypeId,
|
||||
config,
|
||||
};
|
||||
let id = await NewsletterConfigCommandHandler.setConfig(createNewsletterConfig);
|
||||
|
||||
res.send(id);
|
||||
}
|
|
@ -146,6 +146,7 @@ export async function createNewsletterPrintoutById(req: Request, res: Response):
|
|||
// check if all users have mail or adress
|
||||
// squash all files to single for printing
|
||||
// use Helper for Newsletter printing and mail sending
|
||||
// default template
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue