ff-admin-server/src/service/communicationTypeService.ts

62 lines
2 KiB
TypeScript
Raw Normal View History

2024-09-04 14:01:22 +02:00
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;
})
2024-09-06 10:08:19 +02:00
.catch((err) => {
throw new InternalException("communicationTypes not found", err);
2024-09-04 14:01:22 +02:00
});
}
/**
* @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;
})
2024-09-06 10:08:19 +02:00
.catch((err) => {
throw new InternalException("communicationType not found by id", err);
2024-09-04 14:01:22 +02:00
});
}
// /**
// * @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 [];
// })
2024-09-06 10:08:19 +02:00
// .catch((err) => {
// throw new InternalException("communicationType assigned members not found by id", err);
2024-09-04 14:01:22 +02:00
// });
// }
}