This commit is contained in:
Julian Krauser 2024-10-19 16:24:41 +02:00
parent 58213923e5
commit 9da2a98f55
12 changed files with 341 additions and 54 deletions

View file

@ -0,0 +1,6 @@
export interface CreateProtocolPrintoutCommand {
title: string;
iteration: number;
filename: string;
protocolId: number;
}

View file

@ -0,0 +1,31 @@
import { dataSource } from "../data-source";
import { protocolPrintout } from "../entity/protocolPrintout";
import InternalException from "../exceptions/internalException";
import { CreateProtocolPrintoutCommand } from "./protocolPrintoutCommand";
export default abstract class ProtocolPrintoutCommandHandler {
/**
* @description create protocolPrintout
* @param {number}
* @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);
});
}
}