Select Git revision
RobinStrategy.java
Forked from
TRAVERS Corentin / flooding-template
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
PatientService.java 1.05 KiB
package com.projet.projetIndu.services;
import com.projet.projetIndu.entities.Patient;
import com.projet.projetIndu.repositories.PatientRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class PatientService {
private final PatientRepository patientRepository;
@Autowired
public PatientService(PatientRepository patientRepository) {
this.patientRepository = patientRepository;
}
public List<Patient> getAllPatients() {
return patientRepository.findAll();
}
public Optional<Patient> getPatientById(Long id) {
return patientRepository.findById(id);
}
public Optional<Patient> getPatientByEmail(String email) {
return patientRepository.findByEmail(email);
}
public Patient savePatient(Patient patient) {
return patientRepository.save(patient);
}
public void deletePatientById(Long id) {
patientRepository.deleteById(id);
}
}