template preparation

This commit is contained in:
Julian Krauser 2024-12-23 14:00:50 +01:00
parent 5f18e614be
commit 6cb8ca0a12
16 changed files with 414 additions and 21 deletions

View file

@ -0,0 +1,6 @@
export interface UpdateTemplateUsageCommand {
scope: string;
headerId: number | null;
bodyId: number | null;
footerId: number | null;
}

View file

@ -0,0 +1,28 @@
import { dataSource } from "../data-source";
import { templateUsage } from "../entity/templateUsage";
import InternalException from "../exceptions/internalException";
import { UpdateTemplateUsageCommand } from "./templateUsageCommand";
export default abstract class TemplateUsageCommandHandler {
/**
* @description update templateUsage
* @param UpdateTemplateUsageCommand
* @returns {Promise<void>}
*/
static async update(updateTemplateUsage: UpdateTemplateUsageCommand): Promise<void> {
return await dataSource
.createQueryBuilder()
.update(templateUsage)
.set({
headerId: updateTemplateUsage.headerId,
bodyId: updateTemplateUsage.bodyId,
footerId: updateTemplateUsage.footerId,
})
.where("scope = :scope", { scope: updateTemplateUsage.scope })
.execute()
.then(() => {})
.catch((err) => {
throw new InternalException("Failed updating templateUsage", err);
});
}
}