ff-admin-server/src/service/protocolPrecenseService.ts

42 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-10-11 12:44:09 +00:00
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<Array<protocolPresence>>}
*/
static async getAll(protocolId: number): Promise<Array<protocolPresence>> {
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<protocolPresence>}
*/
static async getById(id: number): Promise<protocolPresence> {
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);
});
}
}