31 lines
1 KiB
TypeScript
31 lines
1 KiB
TypeScript
import { dataSource } from "../../../data-source";
|
|
import { protocolPrintout } from "../../../entity/club/protocol/protocolPrintout";
|
|
import InternalException from "../../../exceptions/internalException";
|
|
import { CreateProtocolPrintoutCommand } from "./protocolPrintoutCommand";
|
|
|
|
export default abstract class ProtocolPrintoutCommandHandler {
|
|
/**
|
|
* @description create protocolPrintout
|
|
* @param {CreateProtocolPrintoutCommand} printout
|
|
* @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);
|
|
});
|
|
}
|
|
}
|