import { dataSource } from "../data-source"; import { communication } from "../entity/communication"; import { communicationType } from "../entity/communicationType"; import { user } from "../entity/user"; import InternalException from "../exceptions/internalException"; export default abstract class CommunicationTypeService { /** * @description get all communicationTypes * @returns {Promise<Array<communicationType>>} */ static async getAll(): Promise<Array<communicationType>> { return await dataSource .getRepository(communicationType) .createQueryBuilder("communicationType") .getMany() .then((res) => { return res; }) .catch(() => { throw new InternalException("communicationTypes not found"); }); } /** * @description get communicationType by id * @returns {Promise<communicationType>} */ static async getById(id: number): Promise<communicationType> { return await dataSource .getRepository(communicationType) .createQueryBuilder("communicationType") .andWhere("communicationType.id = :id", { id: id }) .getOneOrFail() .then((res) => { return res; }) .catch(() => { throw new InternalException("communicationType not found by id"); }); } // /** // * @description get members assigned to communicationType // * @returns {Promise<Array<member>>} // */ // static async getMembersBycommunicationTypeId(id: number): Promise<Array<member>> { // return await dataSource // .getRepository(communicationType) // .createQueryBuilder("communicationType") // .leftJoinAndSelect("communicationType.members", "members") // .andWhere("communicationType.id = :id", { id: id }) // .getOneOrFail() // .then((res) => { // return []; // }) // .catch(() => { // throw new InternalException("communicationType assigned members not found by id"); // }); // } }