protcol table services
This commit is contained in:
parent
dd74005043
commit
475a13ce36
19 changed files with 502 additions and 10 deletions
41
src/service/protocolAgendaService.ts
Normal file
41
src/service/protocolAgendaService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
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);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/protocolDecisionService.ts
Normal file
41
src/service/protocolDecisionService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
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("protocolAgenda.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);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/protocolPrecenseService.ts
Normal file
41
src/service/protocolPrecenseService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
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);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/protocolVotingService.ts
Normal file
41
src/service/protocolVotingService.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { protocolVoting } from "../entity/protocolVoting";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
||||
export default abstract class ProtocolVotingService {
|
||||
/**
|
||||
* @description get all protocolVotingss
|
||||
* @returns {Promise<Array<protocolVoting>>}
|
||||
*/
|
||||
static async getAll(protocolId: number): Promise<Array<protocolVoting>> {
|
||||
return await dataSource
|
||||
.getRepository(protocolVoting)
|
||||
.createQueryBuilder("protocolVotings")
|
||||
.where("protocolAgenda.protocolId = :protocolId", { protocolId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolVotings not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get protocolVoting by id
|
||||
* @returns {Promise<protocolVoting>}
|
||||
*/
|
||||
static async getById(id: number): Promise<protocolVoting> {
|
||||
return await dataSource
|
||||
.getRepository(protocolVoting)
|
||||
.createQueryBuilder("protocolVotings")
|
||||
.where("protocolVotings.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolVoting not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue