command Handlers and schema update
This commit is contained in:
parent
0f6401953f
commit
7883bb7d7f
42 changed files with 1076 additions and 159 deletions
34
src/command/unit/inspection/inspectionPointCommandHandler.ts
Normal file
34
src/command/unit/inspection/inspectionPointCommandHandler.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
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);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue