command Handlers and schema update
This commit is contained in:
parent
0f6401953f
commit
7883bb7d7f
42 changed files with 1076 additions and 159 deletions
|
@ -0,0 +1,31 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { inspectionPointResult } from "../../../entity/unit/inspection/inspectionPointResult";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import { CreateInspectionPointResultCommand } from "./inspectionPointResultCommand";
|
||||
|
||||
export default abstract class InspectionPointResultCommandHandler {
|
||||
/**
|
||||
* @description create inspectionPointResult
|
||||
* @param {CreateInspectionPointResultCommand} createInspectionPointResult
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
static async createOrUpdate(createInspectionPointResult: CreateInspectionPointResultCommand): Promise<number> {
|
||||
return await dataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(inspectionPointResult)
|
||||
.values({
|
||||
inspectionId: createInspectionPointResult.inspectionId,
|
||||
inspectionPointId: createInspectionPointResult.inspectionPointId,
|
||||
value: createInspectionPointResult.value,
|
||||
})
|
||||
.orUpdate(["value"], ["inspectionId", "inspectionPointId"])
|
||||
.execute()
|
||||
.then((result) => {
|
||||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("CREATE", "inspectionPointResult", err);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue