30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
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,
|
|
headerHeight: updateTemplateUsage.headerHeight,
|
|
footerHeight: updateTemplateUsage.footerHeight,
|
|
})
|
|
.where("scope = :scope", { scope: updateTemplateUsage.scope })
|
|
.execute()
|
|
.then(() => {})
|
|
.catch((err) => {
|
|
throw new InternalException("Failed updating templateUsage", err);
|
|
});
|
|
}
|
|
}
|