From 5f18e614be64937c774e9e3da73739074feaa24d Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Sun, 22 Dec 2024 17:29:11 +0100 Subject: [PATCH] changed data structure to single html --- src/command/templateCommand.ts | 4 +--- src/command/templateCommandHandler.ts | 4 +--- src/controller/admin/templateController.ts | 8 ++------ src/entity/template.ts | 8 +------- src/factory/admin/template.ts | 4 +--- src/migrations/1734854680201-template.ts | 4 +--- src/viewmodel/admin/template.models.ts | 4 +--- 7 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/command/templateCommand.ts b/src/command/templateCommand.ts index 9823d20..55a5f44 100644 --- a/src/command/templateCommand.ts +++ b/src/command/templateCommand.ts @@ -8,9 +8,7 @@ export interface UpdateTemplateCommand { template: string; description: string | null; design: object; - headerHTML: string; - bodyHTML: string; - footerHTML: string; + html: string; } export interface DeleteTemplateCommand { diff --git a/src/command/templateCommandHandler.ts b/src/command/templateCommandHandler.ts index 3cf9871..1f9b4ce 100644 --- a/src/command/templateCommandHandler.ts +++ b/src/command/templateCommandHandler.ts @@ -40,9 +40,7 @@ export default abstract class TemplateCommandHandler { template: updateTemplate.template, description: updateTemplate.description, design: updateTemplate.design, - headerHTML: updateTemplate.headerHTML, - bodyHTML: updateTemplate.bodyHTML, - footerHTML: updateTemplate.footerHTML, + html: updateTemplate.html, }) .where("id = :id", { id: updateTemplate.id }) .execute() diff --git a/src/controller/admin/templateController.ts b/src/controller/admin/templateController.ts index 6f46ae6..9c8a2a0 100644 --- a/src/controller/admin/templateController.ts +++ b/src/controller/admin/templateController.ts @@ -59,18 +59,14 @@ export async function updateTemplate(req: Request, res: Response): Promise const template = req.body.template; const description = req.body.description; const design = req.body.design; - const headerHTML = req.body.headerHTML; - const bodyHTML = req.body.bodyHTML; - const footerHTML = req.body.footerHTML; + const html = req.body.html; let updateTemplate: UpdateTemplateCommand = { id: id, template: template, description: description, design: design, - headerHTML: headerHTML, - bodyHTML: bodyHTML, - footerHTML: footerHTML, + html: html, }; await TemplateCommandHandler.update(updateTemplate); diff --git a/src/entity/template.ts b/src/entity/template.ts index 2b5d366..6a25724 100644 --- a/src/entity/template.ts +++ b/src/entity/template.ts @@ -26,11 +26,5 @@ export class template { design: object; @Column({ type: "text", default: "" }) - headerHTML: string; - - @Column({ type: "text", default: "" }) - bodyHTML: string; - - @Column({ type: "text", default: "" }) - footerHTML: string; + html: string; } diff --git a/src/factory/admin/template.ts b/src/factory/admin/template.ts index c1d721d..7da05e0 100644 --- a/src/factory/admin/template.ts +++ b/src/factory/admin/template.ts @@ -13,9 +13,7 @@ export default abstract class TemplateFactory { template: record.template, description: record.description, design: record.design, - headerHTML: record.headerHTML, - bodyHTML: record.bodyHTML, - footerHTML: record.footerHTML, + html: record.html, }; } diff --git a/src/migrations/1734854680201-template.ts b/src/migrations/1734854680201-template.ts index df30687..7ccd1e9 100644 --- a/src/migrations/1734854680201-template.ts +++ b/src/migrations/1734854680201-template.ts @@ -15,9 +15,7 @@ export class Template1734854680201 implements MigrationInterface { { name: "template", type: "varchar", length: "255", isNullable: false }, { name: "description", type: "varchar", length: "255", isNullable: true }, { name: "design", type: "text", isNullable: false, default: "'{}'" }, - { name: "headerHTML", type: "text", isNullable: false, default: "''" }, - { name: "bodyHTML", type: "text", isNullable: false, default: "''" }, - { name: "footerHTML", type: "text", isNullable: false, default: "''" }, + { name: "html", type: "text", isNullable: false, default: "''" }, ], }), true diff --git a/src/viewmodel/admin/template.models.ts b/src/viewmodel/admin/template.models.ts index 264a1bb..eb1ceaa 100644 --- a/src/viewmodel/admin/template.models.ts +++ b/src/viewmodel/admin/template.models.ts @@ -3,7 +3,5 @@ export interface TemplateViewModel { template: string; description: string | null; design: object; - headerHTML: string; - bodyHTML: string; - footerHTML: string; + html: string; }