update or create inspection versioned plan

This commit is contained in:
Julian Krauser 2025-07-09 16:01:44 +02:00
parent 95b6cec66d
commit db3004fa04
13 changed files with 229 additions and 11 deletions

View file

@ -125,4 +125,22 @@ export default abstract class InspectionService {
throw new DatabaseActionException("SELECT", "inspection", err);
});
}
/**
* @description uses versionedPlan
* @returns {Promise<boolean>}
*/
static async usesVersionedInspectionPlan(inspectionVersionedPlanId: string): Promise<boolean> {
return await dataSource
.getRepository(inspection)
.createQueryBuilder("inspection")
.where({ inspectionVersionedPlanId })
.getExists()
.then((res) => {
return res;
})
.catch((err) => {
throw new DatabaseActionException("SELECT", "used inspection", err);
});
}
}

View file

@ -62,4 +62,22 @@ export default abstract class InspectionVersionedPlanService {
throw new DatabaseActionException("SELECT", "inspectionVersionedPlan", err);
});
}
/**
* @description count for plan id
* @returns {Promise<number>}
*/
static async countForPlanId(planId: string): Promise<number> {
return await dataSource
.getRepository(inspectionVersionedPlan)
.createQueryBuilder("inspectionVersionedPlan")
.where({ inspectionPlanId: planId })
.getCount()
.then((res) => {
return res;
})
.catch((err) => {
throw new DatabaseActionException("SELECT", "inspectionVersionedPlan", err);
});
}
}