import { dataSource } from "../data-source"; import { protocolPresence } from "../entity/protocolPresence"; import InternalException from "../exceptions/internalException"; export default abstract class ProtocolPresenceService { /** * @description get all protocolPresences * @returns {Promise>} */ static async getAll(protocolId: number): Promise> { return await dataSource .getRepository(protocolPresence) .createQueryBuilder("protocolPresence") .where("protocolAgenda.protocolId = :protocolId", { protocolId }) .getMany() .then((res) => { return res; }) .catch((err) => { throw new InternalException("protocolPresence not found", err); }); } /** * @description get protocolDecision by id * @returns {Promise} */ static async getById(id: number): Promise { return await dataSource .getRepository(protocolPresence) .createQueryBuilder("protocolPresence") .where("protocolPresence.id = :id", { id: id }) .getOneOrFail() .then((res) => { return res; }) .catch((err) => { throw new InternalException("protocolDecision not found by id", err); }); } }