factory and restructure view models

This commit is contained in:
Julian Krauser 2025-05-28 18:30:00 +02:00
parent fcbfe560c3
commit 117ced38ab
33 changed files with 479 additions and 46 deletions

View file

@ -11,6 +11,9 @@ export default abstract class DamageReportService {
return await dataSource
.getRepository(damageReport)
.createQueryBuilder("damageReport")
.leftJoinAndSelect("damageReport.equipment", "equipment")
.leftJoinAndSelect("damageReport.vehicle", "vehicle")
.leftJoinAndSelect("damageReport.wearable", "wearable")
.orderBy("type", "ASC")
.getMany()
.then((res) => {

View file

@ -23,6 +23,8 @@ export default abstract class InspectionPlanService {
: "latestVersionedPlan.inspectionPlanId = inspectionPlan.id AND latestVersionedPlan.version = (SELECT MAX(ivp.start) FROM inspection_versioned_plan ivp WHERE ivp.inspectionPlanId = inspectionPlan.id)"
)
.leftJoinAndSelect("latestVersionedPlan.inspectionPoints", "inspectionPoints")
.leftJoinAndSelect("inspectionPlan.equipment", "equipment")
.leftJoinAndSelect("inspectionPlan.vehicle", "vehicle")
.where(where)
.orderBy("title", "ASC")
.getMany()
@ -51,6 +53,8 @@ export default abstract class InspectionPlanService {
: "latestVersionedPlan.inspectionPlanId = inspectionPlan.id AND latestVersionedPlan.version = (SELECT MAX(ivp.start) FROM inspection_versioned_plan ivp WHERE ivp.inspectionPlanId = inspectionPlan.id)"
)
.leftJoinAndSelect("latestVersionedPlan.inspectionPoints", "inspectionPoints")
.leftJoinAndSelect("inspectionPlan.equipment", "equipment")
.leftJoinAndSelect("inspectionPlan.vehicle", "vehicle")
.where({ id })
.getOneOrFail()
.then((res) => {

View file

@ -16,6 +16,8 @@ export default abstract class InspectionService {
.leftJoinAndSelect("inspectionVersionedPlan.inspectionPoints", "inspectionPoints")
.leftJoinAndSelect("inspection.pointResults", "pointResults")
.leftJoinAndSelect("pointResults.inspectionPoint", "inspectionPoint")
.leftJoinAndSelect("inspection.equipment", "equipment")
.leftJoinAndSelect("inspection.vehicle", "vehicle")
.where(where)
.orderBy("createdAt", "DESC")
.getMany()
@ -40,6 +42,8 @@ export default abstract class InspectionService {
.leftJoinAndSelect("inspectionVersionedPlan.inspectionPoints", "inspectionPoints")
.leftJoinAndSelect("inspection.pointResults", "pointResults")
.leftJoinAndSelect("pointResults.inspectionPoint", "inspectionPoint")
.leftJoinAndSelect("inspection.equipment", "equipment")
.leftJoinAndSelect("inspection.vehicle", "vehicle")
.where({ id })
.getOneOrFail()
.then((res) => {

View file

@ -12,6 +12,7 @@ export default abstract class WearableService {
.getRepository(wearable)
.createQueryBuilder("wearable")
.leftJoinAndSelect("wearable.wearableType", "wearabletype")
.leftJoinAndSelect("wearable.wearer", "wearer")
.orderBy("name", "ASC")
.getMany()
.then((res) => {