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

41 lines
1.3 KiB
TypeScript

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