import { dataSource } from "../../data-source"; import { salutation } from "../../entity/configuration/salutation"; import DatabaseActionException from "../../exceptions/databaseActionException"; import InternalException from "../../exceptions/internalException"; export default abstract class SalutationService { /** * @description get all salutations * @returns {Promise>} */ static async getAll(): Promise> { return await dataSource .getRepository(salutation) .createQueryBuilder("salutation") .orderBy("salutation.salutation", "ASC") .getMany() .then((res) => { return res; }) .catch((err) => { throw new DatabaseActionException("SELECT", "salutation", err); }); } /** * @description get salutation by id * @returns {Promise} */ static async getById(id: number): Promise { return await dataSource .getRepository(salutation) .createQueryBuilder("salutation") .where("salutation.id = :id", { id: id }) .getOneOrFail() .then((res) => { return res; }) .catch((err) => { throw new DatabaseActionException("SELECT", "salutation", err); }); } }