ff-admin-server/src/command/club/protocol/protocolPrintoutCommandHandler.ts

32 lines
1 KiB
TypeScript
Raw Normal View History

2025-01-05 14:14:00 +01:00
import { dataSource } from "../../../data-source";
import { protocolPrintout } from "../../../entity/club/protocol/protocolPrintout";
import InternalException from "../../../exceptions/internalException";
2024-10-19 16:24:41 +02:00
import { CreateProtocolPrintoutCommand } from "./protocolPrintoutCommand";
export default abstract class ProtocolPrintoutCommandHandler {
/**
* @description create protocolPrintout
2025-01-05 14:29:31 +01:00
* @param {CreateProtocolPrintoutCommand} printout
2024-10-19 16:24:41 +02:00
* @returns {Promise<number>}
*/
static async create(printout: CreateProtocolPrintoutCommand): Promise<number> {
return await dataSource
.createQueryBuilder()
.insert()
.into(protocolPrintout)
.values({
title: printout.title,
iteration: printout.iteration,
filename: printout.filename,
protocolId: printout.protocolId,
})
.execute()
.then((result) => {
return result.identifiers[0].id;
})
.catch((err) => {
throw new InternalException("Failed creating protocol", err);
});
}
}