Merge branch 'main' into #3-calendar
# Conflicts: # package-lock.json # src/data-source.ts # src/routes/admin/index.ts # src/type/permissionTypes.ts
This commit is contained in:
commit
98eb870385
48 changed files with 2672 additions and 9 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("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);
|
||||
});
|
||||
}
|
||||
}
|
43
src/service/protocolPrecenseService.ts
Normal file
43
src/service/protocolPrecenseService.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
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")
|
||||
.leftJoinAndSelect("protocolPresence.member", "member")
|
||||
.where("protocolPresence.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")
|
||||
.leftJoinAndSelect("protocolPresence.member", "member")
|
||||
.where("protocolPresence.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolDecision not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
60
src/service/protocolPrintoutService.ts
Normal file
60
src/service/protocolPrintoutService.ts
Normal file
|
@ -0,0 +1,60 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { protocolPrintout } from "../entity/protocolPrintout";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
||||
export default abstract class ProtocolPrintoutService {
|
||||
/**
|
||||
* @description get all protocolPrintouts
|
||||
* @returns {Promise<Array<protocolPrintout>>}
|
||||
*/
|
||||
static async getAll(protocolId: number): Promise<Array<protocolPrintout>> {
|
||||
return await dataSource
|
||||
.getRepository(protocolPrintout)
|
||||
.createQueryBuilder("protocolPrintout")
|
||||
.where("protocolPrintout.protocolId = :protocolId", { protocolId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolPrintouts not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get protocolPrintout by id
|
||||
* @returns {Promise<protocolPrintout>}
|
||||
*/
|
||||
static async getById(id: number, protocolId: number): Promise<protocolPrintout> {
|
||||
return await dataSource
|
||||
.getRepository(protocolPrintout)
|
||||
.createQueryBuilder("protocolPrintout")
|
||||
.where("protocolPrintout.protocolId = :protocolId", { protocolId })
|
||||
.andWhere("protocolPrintout.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolPrintout not found by id", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get count of printouts by id
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
static async getCount(protocolId: number): Promise<number> {
|
||||
return await dataSource
|
||||
.getRepository(protocolPrintout)
|
||||
.createQueryBuilder("protocolPrintout")
|
||||
.where("protocolPrintout.protocolId = :protocolId", { protocolId })
|
||||
.getCount()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocolPrintout not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
43
src/service/protocolService.ts
Normal file
43
src/service/protocolService.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { protocol } from "../entity/protocol";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
||||
export default abstract class ProtocolService {
|
||||
/**
|
||||
* @description get all protocols
|
||||
* @returns {Promise<[Array<protocol>, number]>}
|
||||
*/
|
||||
static async getAll(offset: number = 0, count: number = 25): Promise<[Array<protocol>, number]> {
|
||||
return await dataSource
|
||||
.getRepository(protocol)
|
||||
.createQueryBuilder("protocol")
|
||||
.offset(offset)
|
||||
.limit(count)
|
||||
.orderBy("date", "DESC")
|
||||
.getManyAndCount()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocols not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get protocol by id
|
||||
* @returns {Promise<protocol>}
|
||||
*/
|
||||
static async getById(id: number): Promise<protocol> {
|
||||
return await dataSource
|
||||
.getRepository(protocol)
|
||||
.createQueryBuilder("protocol")
|
||||
.where("protocol.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("protocol 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("protocolVotings.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