Spaces:
Running
Running
| import { | |
| Controller, | |
| Get, | |
| Post, | |
| Put, | |
| Delete, | |
| Body, | |
| Param, | |
| UseGuards, | |
| Request, | |
| HttpCode, | |
| HttpStatus, | |
| SetMetadata, | |
| } from "@nestjs/common"; | |
| import { AppointmentsService } from "./appointments.service"; | |
| import { CreateAppointmentDto } from "./dto/create-appointment.dto"; | |
| import { UpdateAppointmentDto } from "./dto/update-appointment.dto"; | |
| import { JwtAuthGuard } from "../auth/guards/jwt-auth.guard"; | |
| import { Appointment } from "@prisma/client"; | |
| import { RolesGuard } from "src/auth/guards/roles.guard"; | |
| const Roles = (...roles: string[]) => SetMetadata("roles", roles); | |
| ("appointments") | |
| (JwtAuthGuard, RolesGuard) | |
| export class AppointmentsController { | |
| constructor(private readonly appointmentsService: AppointmentsService) {} | |
| () | |
| ("FACILITY_ADMIN", "FACILITY_STAFF") | |
| create(() req: any, () dto: CreateAppointmentDto) { | |
| return this.appointmentsService.create(req.user.healthcareWorker.facilityId, dto); | |
| } | |
| () | |
| ("FACILITY_ADMIN", "FACILITY_STAFF") | |
| findAll(() req: any) { | |
| return this.appointmentsService.findAll(req.user.healthcareWorker.facilityId); | |
| } | |
| (":id") | |
| ("FACILITY_ADMIN", "FACILITY_STAFF") | |
| findOne(("id") id: string, () req: any) { | |
| return this.appointmentsService.findOne(id, req.user.healthcareWorker.facilityId); | |
| } | |
| (":id") | |
| ("FACILITY_ADMIN", "FACILITY_STAFF") | |
| update( | |
| ("id") id: string, | |
| () req: any, | |
| () dto: UpdateAppointmentDto, | |
| ) { | |
| return this.appointmentsService.update( | |
| id, | |
| req.user.healthcareWorker.facilityId, | |
| dto, | |
| ); | |
| } | |
| (":id") | |
| ("FACILITY_ADMIN", "FACILITY_STAFF") | |
| remove(("id") id: string, () req: any) { | |
| return this.appointmentsService.remove(id, req.user.healthcareWorker.facilityId); | |
| } | |
| } | |