34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { dataSource } from "../../../data-source";
|
|
import { inspectionPoint } from "../../../entity/unit/inspection/inspectionPoint";
|
|
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
|
import { CreateInspectionPointCommand } from "./inspectionPointCommand";
|
|
|
|
export default abstract class InspectionPointCommandHandler {
|
|
/**
|
|
* @description create inspectionPoint
|
|
* @param {CreateInspectionPointCommand} createInspectionPoint
|
|
* @returns {Promise<number>}
|
|
*/
|
|
static async create(createInspectionPoint: CreateInspectionPointCommand): Promise<number> {
|
|
return await dataSource
|
|
.createQueryBuilder()
|
|
.insert()
|
|
.into(inspectionPoint)
|
|
.values({
|
|
title: createInspectionPoint.title,
|
|
description: createInspectionPoint.description,
|
|
type: createInspectionPoint.type,
|
|
min: createInspectionPoint.min,
|
|
max: createInspectionPoint.max,
|
|
sort: createInspectionPoint.sort,
|
|
versionedPlanId: createInspectionPoint.versionedPointId,
|
|
})
|
|
.execute()
|
|
.then((result) => {
|
|
return result.identifiers[0].id;
|
|
})
|
|
.catch((err) => {
|
|
throw new DatabaseActionException("CREATE", "inspectionPoint", err);
|
|
});
|
|
}
|
|
}
|