printout
This commit is contained in:
parent
58213923e5
commit
9da2a98f55
12 changed files with 341 additions and 54 deletions
6
src/command/protocolPrintoutCommand.ts
Normal file
6
src/command/protocolPrintoutCommand.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
export interface CreateProtocolPrintoutCommand {
|
||||
title: string;
|
||||
iteration: number;
|
||||
filename: string;
|
||||
protocolId: number;
|
||||
}
|
31
src/command/protocolPrintoutCommandHandler.ts
Normal file
31
src/command/protocolPrintoutCommandHandler.ts
Normal 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);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue