source: backend/src/main/java/com/finki/icare/service/TherapistService.java

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
RevLine 
[700e2f9]1package com.finki.icare.service;
2
3import com.finki.icare.dto.PatientDTO;
4import com.finki.icare.dto.TherapistDTO;
5import com.finki.icare.mapper.PatientMapper;
6import com.finki.icare.mapper.TherapistMapper;
7import com.finki.icare.model.Patient;
8import com.finki.icare.model.Therapist;
9import com.finki.icare.repository.PatientRepository;
10import com.finki.icare.repository.TherapistRepository;
11import lombok.RequiredArgsConstructor;
12import org.springframework.stereotype.Service;
13
14import java.util.List;
15
16@Service
17@RequiredArgsConstructor
18public 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.