2025-01-05 14:14:00 +01:00
|
|
|
import { dataSource } from "../../../data-source";
|
|
|
|
import { protocolVoting } from "../../../entity/club/protocol/protocolVoting";
|
2025-01-29 09:42:22 +01:00
|
|
|
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
2025-01-05 14:14:00 +01:00
|
|
|
import InternalException from "../../../exceptions/internalException";
|
2024-10-11 14:44:09 +02:00
|
|
|
|
|
|
|
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")
|
2024-10-13 15:48:01 +02:00
|
|
|
.where("protocolVotings.protocolId = :protocolId", { protocolId })
|
2024-10-11 14:44:09 +02:00
|
|
|
.getMany()
|
|
|
|
.then((res) => {
|
|
|
|
return res;
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2025-01-29 09:42:22 +01:00
|
|
|
throw new DatabaseActionException("SELECT", "protocolVoting", err);
|
2024-10-11 14:44:09 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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) => {
|
2025-01-29 09:42:22 +01:00
|
|
|
throw new DatabaseActionException("SELECT", "protocolVoting", err);
|
2024-10-11 14:44:09 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|