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

@ -21,23 +21,4 @@ export default abstract class InspectionPointResultService {
throw new DatabaseActionException("SELECT", "inspectionPointResult", err);
});
}
/**
* @description get inspectionPointResult by id
* @returns {Promise<inspectionPointResult>}
*/
static async getById(id: string): Promise<inspectionPointResult> {
return await dataSource
.getRepository(inspectionPointResult)
.createQueryBuilder("inspectionPointResult")
.leftJoinAndSelect("inspectionPointResult.inspectionPoint", "inspectionPoint")
.where({ id })
.getOneOrFail()
.then((res) => {
return res;
})
.catch((err) => {
throw new DatabaseActionException("SELECT", "inspectionPointResult", err);
});
}
}

View file

@ -23,6 +23,27 @@ export default abstract class InspectionVersionedPlanService {
});
}
/**
* @description get latest inspectionVersionedPlan for plan
* @returns {Promise<Array<inspectionVersionedPlan>>}
*/
static async getLatestForInspectionPlan(inspectionPlanId: string): Promise<inspectionVersionedPlan> {
return await dataSource
.getRepository(inspectionVersionedPlan)
.createQueryBuilder("inspectionVersionedPlan")
.leftJoinAndSelect("inspectionVersionedPlan.inspectionPoints", "inspectionPoints")
.where({ inspectionPlanId })
.orderBy("inspectionVersionedPlan.version", "DESC")
.limit(1)
.getOneOrFail()
.then((res) => {
return res;
})
.catch((err) => {
throw new DatabaseActionException("SELECT", "inspectionVersionedPlan", err);
});
}
/**
* @description get inspectionVersionedPlan by id
* @returns {Promise<inspectionVersionedPlan>}