import { dataSource } from "../../data-source"; import { award } from "../../entity/settings/award"; import { member } from "../../entity/club/member/member"; import InternalException from "../../exceptions/internalException"; export default abstract class AwardService { /** * @description get all awards * @returns {Promise>} */ static async getAll(): Promise> { return await dataSource .getRepository(award) .createQueryBuilder("award") .orderBy("award", "ASC") .getMany() .then((res) => { return res; }) .catch((err) => { throw new InternalException("awards not found", err); }); } /** * @description get award by id * @returns {Promise} */ static async getById(id: number): Promise { return await dataSource .getRepository(award) .createQueryBuilder("award") .where("award.id = :id", { id: id }) .getOneOrFail() .then((res) => { return res; }) .catch((err) => { throw new InternalException("award not found by id", err); }); } }