28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { dataSource } from "../../../data-source";
|
|
import { inspectionVersionedPlan } from "../../../entity/unit/inspection/inspectionVersionedPlan";
|
|
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
|
import { CreateInspectionVersionedPlanCommand } from "./inspectionVersionedPlanCommand";
|
|
|
|
export default abstract class InspectionVersionedPlanCommandHandler {
|
|
/**
|
|
* @description create inspectionVersionedPlan
|
|
* @param {CreateInspectionVersionedPlanCommand} createInspectionVersionedPlan
|
|
* @returns {Promise<number>}
|
|
*/
|
|
static async create(createInspectionVersionedPlan: CreateInspectionVersionedPlanCommand): Promise<number> {
|
|
return await dataSource
|
|
.createQueryBuilder()
|
|
.insert()
|
|
.into(inspectionVersionedPlan)
|
|
.values({
|
|
inspectionPlanId: createInspectionVersionedPlan.inspectionPlanId,
|
|
})
|
|
.execute()
|
|
.then((result) => {
|
|
return result.identifiers[0].id;
|
|
})
|
|
.catch((err) => {
|
|
throw new DatabaseActionException("CREATE", "inspectionVersionedPlan", err);
|
|
});
|
|
}
|
|
}
|