source: backend/src/main/java/com/finki/icare/controller/TherapistController.java@ 700e2f9

main
Last change on this file since 700e2f9 was 700e2f9, checked in by 186079 <matej.milevski@…>, 5 days ago

Init

  • Property mode set to 100644
File size: 1.4 KB
Line 
1package com.finki.icare.controller;
2
3import com.finki.icare.dto.PatientDTO;
4import com.finki.icare.dto.TherapistDTO;
5import com.finki.icare.service.TherapistService;
6import com.finki.icare.utils.AuthUtils;
7import lombok.RequiredArgsConstructor;
8import org.springframework.http.ResponseEntity;
9import org.springframework.security.core.Authentication;
10import org.springframework.web.bind.annotation.CrossOrigin;
11import org.springframework.web.bind.annotation.GetMapping;
12import org.springframework.web.bind.annotation.RequestMapping;
13import org.springframework.web.bind.annotation.RestController;
14
15import java.util.List;
16
17@RestController
18@RequestMapping("/api/therapists")
19@CrossOrigin(origins = "http://localhost:3000")
20@RequiredArgsConstructor
21public class TherapistController {
22
23 private final TherapistService therapistService;
24
25 @GetMapping
26 public ResponseEntity<List<TherapistDTO>> getAllTherapists() {
27 List<TherapistDTO> therapists = therapistService.getAllTherapistsWithFreeSlots();
28 return ResponseEntity.ok(therapists);
29 }
30
31 @GetMapping("/patients")
32 public ResponseEntity<List<PatientDTO>> getTherapistPatients(Authentication authentication) {
33 Integer therapistId = AuthUtils.getUserId(authentication);
34 List<PatientDTO> patients = therapistService.getTherapistPatients(therapistId);
35 return ResponseEntity.ok(patients);
36 }
37}
Note: See TracBrowser for help on using the repository browser.