2025-05-28 17:06:56 +02:00
|
|
|
import { dataSource } from "../../data-source";
|
|
|
|
import { damageReport } from "../../entity/unit/damageReport";
|
|
|
|
import DatabaseActionException from "../../exceptions/databaseActionException";
|
|
|
|
|
|
|
|
export default abstract class DamageReportService {
|
|
|
|
/**
|
2025-05-28 17:32:07 +02:00
|
|
|
* @description get all damageReports
|
2025-05-28 17:06:56 +02:00
|
|
|
* @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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|