54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
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<Appointments> {
|
|
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<Appointments | null> {
|
|
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);
|
|
}
|
|
|
|
|
|
}
|