command Handlers and schema update

This commit is contained in:
Julian Krauser 2025-05-29 10:31:40 +02:00
parent 0f6401953f
commit 7883bb7d7f
42 changed files with 1076 additions and 159 deletions

View file

@ -0,0 +1,28 @@
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);
});
}
}