2025-01-05 14:14:00 +01:00
|
|
|
import { dataSource } from "../../../data-source";
|
|
|
|
import { templateUsage } from "../../../entity/settings/templateUsage";
|
|
|
|
import InternalException from "../../../exceptions/internalException";
|
2024-12-23 14:00:50 +01:00
|
|
|
import { UpdateTemplateUsageCommand } from "./templateUsageCommand";
|
|
|
|
|
|
|
|
export default abstract class TemplateUsageCommandHandler {
|
|
|
|
/**
|
|
|
|
* @description update templateUsage
|
2025-01-05 14:29:31 +01:00
|
|
|
* @param {UpdateTemplateUsageCommand} updateTemplateUsage
|
2024-12-23 14:00:50 +01:00
|
|
|
* @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,
|
2025-01-01 13:21:28 +01:00
|
|
|
headerHeight: updateTemplateUsage.headerHeight,
|
|
|
|
footerHeight: updateTemplateUsage.footerHeight,
|
2024-12-23 14:00:50 +01:00
|
|
|
})
|
|
|
|
.where("scope = :scope", { scope: updateTemplateUsage.scope })
|
|
|
|
.execute()
|
|
|
|
.then(() => {})
|
|
|
|
.catch((err) => {
|
|
|
|
throw new InternalException("Failed updating templateUsage", err);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|