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>} */ static async getAll(): Promise> { return await dataSource .getRepository(communicationType) .createQueryBuilder("communicationType") .getMany() .then((res) => { return res; }) .catch((err) => { throw new InternalException("communicationTypes not found", err); }); } /** * @description get communicationType by id * @returns {Promise} */ static async getById(id: number): Promise { return await dataSource .getRepository(communicationType) .createQueryBuilder("communicationType") .andWhere("communicationType.id = :id", { id: id }) .getOneOrFail() .then((res) => { return res; }) .catch((err) => { throw new InternalException("communicationType not found by id", err); }); } // /** // * @description get members assigned to communicationType // * @returns {Promise>} // */ // static async getMembersBycommunicationTypeId(id: number): Promise> { // return await dataSource // .getRepository(communicationType) // .createQueryBuilder("communicationType") // .leftJoinAndSelect("communicationType.members", "members") // .andWhere("communicationType.id = :id", { id: id }) // .getOneOrFail() // .then((res) => { // return []; // }) // .catch((err) => { // throw new InternalException("communicationType assigned members not found by id", err); // }); // } }