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.3 KB
|
| Rev | Line | |
|---|
| [700e2f9] | 1 | package com.finki.icare.service;
|
|---|
| 2 |
|
|---|
| 3 | import com.finki.icare.dto.PatientDTO;
|
|---|
| 4 | import com.finki.icare.dto.TherapistDTO;
|
|---|
| 5 | import com.finki.icare.mapper.PatientMapper;
|
|---|
| 6 | import com.finki.icare.mapper.TherapistMapper;
|
|---|
| 7 | import com.finki.icare.model.Patient;
|
|---|
| 8 | import com.finki.icare.model.Therapist;
|
|---|
| 9 | import com.finki.icare.repository.PatientRepository;
|
|---|
| 10 | import com.finki.icare.repository.TherapistRepository;
|
|---|
| 11 | import lombok.RequiredArgsConstructor;
|
|---|
| 12 | import org.springframework.stereotype.Service;
|
|---|
| 13 |
|
|---|
| 14 | import java.util.List;
|
|---|
| 15 |
|
|---|
| 16 | @Service
|
|---|
| 17 | @RequiredArgsConstructor
|
|---|
| 18 | public class TherapistService {
|
|---|
| 19 |
|
|---|
| 20 | private final TherapistRepository therapistRepository;
|
|---|
| 21 | private final TherapistMapper therapistMapper;
|
|---|
| 22 | private final PatientRepository patientRepository;
|
|---|
| 23 | private final PatientMapper patientMapper;
|
|---|
| 24 |
|
|---|
| 25 | public List<TherapistDTO> getAllTherapistsWithFreeSlots() {
|
|---|
| 26 | List<Therapist> therapists = therapistRepository.findAll();
|
|---|
| 27 |
|
|---|
| 28 | return therapists.stream()
|
|---|
| 29 | .map(therapistMapper::toDTO)
|
|---|
| 30 | .toList();
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | public List<PatientDTO> getTherapistPatients(Integer therapistId) {
|
|---|
| 34 | List<Patient> patients = patientRepository.findPatientsByTherapistId(therapistId);
|
|---|
| 35 |
|
|---|
| 36 | return patients.stream()
|
|---|
| 37 | .map(patientMapper::toDTO)
|
|---|
| 38 | .toList();
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.