main
|
Last change
on this file was 700e2f9, checked in by 186079 <matej.milevski@…>, 5 days ago |
|
Init
|
-
Property mode
set to
100644
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | package com.finki.icare.controller;
|
|---|
| 2 |
|
|---|
| 3 | import com.finki.icare.dto.PatientDTO;
|
|---|
| 4 | import com.finki.icare.dto.TherapistDTO;
|
|---|
| 5 | import com.finki.icare.service.TherapistService;
|
|---|
| 6 | import com.finki.icare.utils.AuthUtils;
|
|---|
| 7 | import lombok.RequiredArgsConstructor;
|
|---|
| 8 | import org.springframework.http.ResponseEntity;
|
|---|
| 9 | import org.springframework.security.core.Authentication;
|
|---|
| 10 | import org.springframework.web.bind.annotation.CrossOrigin;
|
|---|
| 11 | import org.springframework.web.bind.annotation.GetMapping;
|
|---|
| 12 | import org.springframework.web.bind.annotation.RequestMapping;
|
|---|
| 13 | import org.springframework.web.bind.annotation.RestController;
|
|---|
| 14 |
|
|---|
| 15 | import java.util.List;
|
|---|
| 16 |
|
|---|
| 17 | @RestController
|
|---|
| 18 | @RequestMapping("/api/therapists")
|
|---|
| 19 | @CrossOrigin(origins = "http://localhost:3000")
|
|---|
| 20 | @RequiredArgsConstructor
|
|---|
| 21 | public 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.