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