ff-admin-server/src/service/configuration/salutationService.ts

43 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-01-25 11:58:10 +01:00
import { dataSource } from "../../data-source";
2025-02-15 10:59:54 +01:00
import { salutation } from "../../entity/configuration/salutation";
2025-01-29 09:42:22 +01:00
import DatabaseActionException from "../../exceptions/databaseActionException";
2025-01-25 11:58:10 +01:00
import InternalException from "../../exceptions/internalException";
export default abstract class SalutationService {
/**
* @description get all salutations
* @returns {Promise<Array<salutation>>}
*/
static async getAll(): Promise<Array<salutation>> {
return await dataSource
.getRepository(salutation)
.createQueryBuilder("salutation")
2025-07-14 14:28:48 +02:00
.orderBy("salutation.salutation", "ASC")
2025-01-25 11:58:10 +01:00
.getMany()
.then((res) => {
return res;
})
.catch((err) => {
2025-01-29 09:42:22 +01:00
throw new DatabaseActionException("SELECT", "salutation", err);
2025-01-25 11:58:10 +01:00
});
}
/**
* @description get salutation by id
* @returns {Promise<salutation>}
*/
static async getById(id: number): Promise<salutation> {
return await dataSource
.getRepository(salutation)
.createQueryBuilder("salutation")
.where("salutation.id = :id", { id: id })
.getOneOrFail()
.then((res) => {
return res;
})
.catch((err) => {
2025-01-29 09:42:22 +01:00
throw new DatabaseActionException("SELECT", "salutation", err);
2025-01-25 11:58:10 +01:00
});
}
}