import BaseService from "@Services/BaseService"; import { Service } from "typedi"; import AppointmentsRepository from "@Repositories/AppointmentsRepository"; import { Prisma, Appointments, EAppointmentStatus } from "@prisma/client"; @Service() export default class AppointmentService extends BaseService { constructor(private appointmentRepository: AppointmentsRepository) { super(); } /** * @description : Get all appointments * @throws {Error} If appointments cannot be get */ public get(query: Prisma.AppointmentsFindManyArgs) { return this.appointmentRepository.findMany(query); } /** * @description : Modify a appointment * @throws {Error} If appointment cannot be modified */ public async update(uid: string, status: EAppointmentStatus): Promise { return this.appointmentRepository.update(uid, status); } /** * @description : Get a appointment by uid * @throws {Error} If appointment cannot be get by uid */ public getByUid(uid: string, query?: Prisma.AppointmentsInclude): Promise { return this.appointmentRepository.findOneByUid(uid, query); } /** * @description : Get a appointment by uid * @throws {Error} If appointment cannot be get by uid */ public getByUidWithVotes(uid: string) { return this.appointmentRepository.findOneByUidWithVotes(uid); } /** * @description : delete a appointment by uid * @throws {Error} If appointment cannot be get by uid */ public delete(uid: string) { return this.appointmentRepository.delete(uid); } }