service base
This commit is contained in:
parent
8c81c8f336
commit
2433120e26
13 changed files with 494 additions and 0 deletions
41
src/service/unit/damageReport.ts
Normal file
41
src/service/unit/damageReport.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../data-source";
|
||||
import { damageReport } from "../../entity/unit/damageReport";
|
||||
import DatabaseActionException from "../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class DamageReportService {
|
||||
/**
|
||||
* @description get all damageReport types
|
||||
* @returns {Promise<Array<damageReport>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<damageReport>> {
|
||||
return await dataSource
|
||||
.getRepository(damageReport)
|
||||
.createQueryBuilder("damageReport")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "damageReport", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get damageReport by id
|
||||
* @returns {Promise<damageReport>}
|
||||
*/
|
||||
static async getById(id: string): Promise<damageReport> {
|
||||
return await dataSource
|
||||
.getRepository(damageReport)
|
||||
.createQueryBuilder("damageReport")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "damageReport", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/unit/equipment/equipmentService.ts
Normal file
41
src/service/unit/equipment/equipmentService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { equipment } from "../../../entity/unit/equipment/equipment";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class EquipmentService {
|
||||
/**
|
||||
* @description get all equipment types
|
||||
* @returns {Promise<Array<equipment>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<equipment>> {
|
||||
return await dataSource
|
||||
.getRepository(equipment)
|
||||
.createQueryBuilder("equipment")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "equipment", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get equipment by id
|
||||
* @returns {Promise<equipment>}
|
||||
*/
|
||||
static async getById(id: string): Promise<equipment> {
|
||||
return await dataSource
|
||||
.getRepository(equipment)
|
||||
.createQueryBuilder("equipment")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "equipment", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/unit/equipment/equipmentTypeService.ts
Normal file
41
src/service/unit/equipment/equipmentTypeService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { equipmentType } from "../../../entity/unit/equipment/equipmentType";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class EquipmentTypeService {
|
||||
/**
|
||||
* @description get all equipment types
|
||||
* @returns {Promise<Array<equipmentType>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<equipmentType>> {
|
||||
return await dataSource
|
||||
.getRepository(equipmentType)
|
||||
.createQueryBuilder("equipmentType")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "equipmentType", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get equipmentType by id
|
||||
* @returns {Promise<equipmentType>}
|
||||
*/
|
||||
static async getById(id: string): Promise<equipmentType> {
|
||||
return await dataSource
|
||||
.getRepository(equipmentType)
|
||||
.createQueryBuilder("equipmentType")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "equipmentType", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/unit/inspection/inspectionPlanService.ts
Normal file
41
src/service/unit/inspection/inspectionPlanService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { inspectionPlan } from "../../../entity/unit/inspection/inspectionPlan";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class InspectionPlanService {
|
||||
/**
|
||||
* @description get all inspectionPlan types
|
||||
* @returns {Promise<Array<inspectionPlan>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<inspectionPlan>> {
|
||||
return await dataSource
|
||||
.getRepository(inspectionPlan)
|
||||
.createQueryBuilder("inspectionPlan")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "inspectionPlan", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get inspectionPlan by id
|
||||
* @returns {Promise<inspectionPlan>}
|
||||
*/
|
||||
static async getById(id: string): Promise<inspectionPlan> {
|
||||
return await dataSource
|
||||
.getRepository(inspectionPlan)
|
||||
.createQueryBuilder("inspectionPlan")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "inspectionPlan", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/unit/inspection/inspectionPointResultService.ts
Normal file
41
src/service/unit/inspection/inspectionPointResultService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { inspectionPointResult } from "../../../entity/unit/inspection/inspectionPointResult";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class InspectionPointResultService {
|
||||
/**
|
||||
* @description get all inspectionPointResult types
|
||||
* @returns {Promise<Array<inspectionPointResult>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<inspectionPointResult>> {
|
||||
return await dataSource
|
||||
.getRepository(inspectionPointResult)
|
||||
.createQueryBuilder("inspectionPointResult")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
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")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "inspectionPointResult", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/unit/inspection/inspectionPointService.ts
Normal file
41
src/service/unit/inspection/inspectionPointService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { inspectionPoint } from "../../../entity/unit/inspection/inspectionPoint";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class InspectionPointService {
|
||||
/**
|
||||
* @description get all inspectionPoint types
|
||||
* @returns {Promise<Array<inspectionPoint>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<inspectionPoint>> {
|
||||
return await dataSource
|
||||
.getRepository(inspectionPoint)
|
||||
.createQueryBuilder("inspectionPoint")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "inspectionPoint", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get inspectionPoint by id
|
||||
* @returns {Promise<inspectionPoint>}
|
||||
*/
|
||||
static async getById(id: string): Promise<inspectionPoint> {
|
||||
return await dataSource
|
||||
.getRepository(inspectionPoint)
|
||||
.createQueryBuilder("inspectionPoint")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "inspectionPoint", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/unit/inspection/inspectionService.ts
Normal file
41
src/service/unit/inspection/inspectionService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { inspection } from "../../../entity/unit/inspection/inspection";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class InspectionService {
|
||||
/**
|
||||
* @description get all inspection types
|
||||
* @returns {Promise<Array<inspection>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<inspection>> {
|
||||
return await dataSource
|
||||
.getRepository(inspection)
|
||||
.createQueryBuilder("inspection")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "inspection", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get inspection by id
|
||||
* @returns {Promise<inspection>}
|
||||
*/
|
||||
static async getById(id: string): Promise<inspection> {
|
||||
return await dataSource
|
||||
.getRepository(inspection)
|
||||
.createQueryBuilder("inspection")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "inspection", err);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { inspectionVersionedPlan } from "../../../entity/unit/inspection/inspectionVersionedPlan";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class InspectionVersionedPlanService {
|
||||
/**
|
||||
* @description get all inspectionVersionedPlan types
|
||||
* @returns {Promise<Array<inspectionVersionedPlan>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<inspectionVersionedPlan>> {
|
||||
return await dataSource
|
||||
.getRepository(inspectionVersionedPlan)
|
||||
.createQueryBuilder("inspectionVersionedPlan")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "inspectionVersionedPlan", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get inspectionVersionedPlan by id
|
||||
* @returns {Promise<inspectionVersionedPlan>}
|
||||
*/
|
||||
static async getById(id: string): Promise<inspectionVersionedPlan> {
|
||||
return await dataSource
|
||||
.getRepository(inspectionVersionedPlan)
|
||||
.createQueryBuilder("inspectionVersionedPlan")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "inspectionVersionedPlan", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/unit/vehicle/vehicleService.ts
Normal file
41
src/service/unit/vehicle/vehicleService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { vehicle } from "../../../entity/unit/vehicle/vehicle";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class VehicleService {
|
||||
/**
|
||||
* @description get all vehicle types
|
||||
* @returns {Promise<Array<vehicle>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<vehicle>> {
|
||||
return await dataSource
|
||||
.getRepository(vehicle)
|
||||
.createQueryBuilder("vehicle")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "vehicle", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get vehicle by id
|
||||
* @returns {Promise<vehicle>}
|
||||
*/
|
||||
static async getById(id: string): Promise<vehicle> {
|
||||
return await dataSource
|
||||
.getRepository(vehicle)
|
||||
.createQueryBuilder("vehicle")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "vehicle", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/unit/vehicle/vehicleTypeService.ts
Normal file
41
src/service/unit/vehicle/vehicleTypeService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { vehicleType } from "../../../entity/unit/vehicle/vehicleType";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class VehicleTypeService {
|
||||
/**
|
||||
* @description get all vehicleType types
|
||||
* @returns {Promise<Array<vehicleType>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<vehicleType>> {
|
||||
return await dataSource
|
||||
.getRepository(vehicleType)
|
||||
.createQueryBuilder("vehicleType")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "vehicleType", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get vehicleType by id
|
||||
* @returns {Promise<vehicleType>}
|
||||
*/
|
||||
static async getById(id: string): Promise<vehicleType> {
|
||||
return await dataSource
|
||||
.getRepository(vehicleType)
|
||||
.createQueryBuilder("vehicleType")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "vehicleType", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/unit/wearable/wearableService.ts
Normal file
41
src/service/unit/wearable/wearableService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { wearable } from "../../../entity/unit/wearable/wearable";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class WearableService {
|
||||
/**
|
||||
* @description get all wearable types
|
||||
* @returns {Promise<Array<wearable>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<wearable>> {
|
||||
return await dataSource
|
||||
.getRepository(wearable)
|
||||
.createQueryBuilder("wearable")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "wearable", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get wearable by id
|
||||
* @returns {Promise<wearable>}
|
||||
*/
|
||||
static async getById(id: string): Promise<wearable> {
|
||||
return await dataSource
|
||||
.getRepository(wearable)
|
||||
.createQueryBuilder("wearable")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "wearable", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/unit/wearable/wearableTypeService.ts
Normal file
41
src/service/unit/wearable/wearableTypeService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { wearableType } from "../../../entity/unit/wearable/wearableType";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class WearableTypeService {
|
||||
/**
|
||||
* @description get all wearableType types
|
||||
* @returns {Promise<Array<wearableType>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<wearableType>> {
|
||||
return await dataSource
|
||||
.getRepository(wearableType)
|
||||
.createQueryBuilder("wearableType")
|
||||
.orderBy("type", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "wearableType", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get wearableType by id
|
||||
* @returns {Promise<wearableType>}
|
||||
*/
|
||||
static async getById(id: string): Promise<wearableType> {
|
||||
return await dataSource
|
||||
.getRepository(wearableType)
|
||||
.createQueryBuilder("wearableType")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "wearableType", err);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ export type DamageReportViewModel = {
|
|||
done: boolean;
|
||||
description: string;
|
||||
providedImage: Array<string>;
|
||||
reportedBy: string;
|
||||
relatedId: string;
|
||||
} & (
|
||||
| {
|
||||
|
@ -27,6 +28,7 @@ export type DamageReportViewModel = {
|
|||
|
||||
export interface CreateDamageReportViewModel {
|
||||
description: string;
|
||||
reportedBy: string;
|
||||
affectedId: string;
|
||||
affected: "equipment" | "vehicle" | "wearable";
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue