source: src/main/java/com/example/medweb/service/impl/DoktorServiceImpl.java

Last change on this file was e5fefbd, checked in by Anita Terziska <63020646+Nit4e@…>, 2 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1package com.example.medweb.service.impl;
2
3import com.example.medweb.model.Doktor;
4import com.example.medweb.model.exceptions.InvalidArgumentsException;
5import com.example.medweb.model.exceptions.InvalidUserCredentialsException;
6import com.example.medweb.repository.DoktorRepository;
7import com.example.medweb.service.DoktorService;
8import org.springframework.stereotype.Service;
9
10import java.util.List;
11import java.util.Optional;
12
13@Service
14public class DoktorServiceImpl implements DoktorService {
15
16 private final DoktorRepository doktorRepository;
17
18 public DoktorServiceImpl(DoktorRepository doktorRepository) {
19
20 this.doktorRepository = doktorRepository;
21 }
22 @Override
23 public List<Doktor> listAll() {
24
25 return this.doktorRepository.findAll();
26 }
27 @Override
28 public Optional<Doktor> findById(Integer id) {
29
30 return this.doktorRepository.findById(id);
31 }
32
33 @Override
34 public Doktor login(String email, String pass) {
35 if (email == null || email.isEmpty() || pass == null || pass.isEmpty()) {
36 throw new InvalidArgumentsException();
37 }
38 return doktorRepository.findDoktorByEmailAndPass(email, pass)
39 .orElseThrow(InvalidUserCredentialsException::new);
40 }
41}
Note: See TracBrowser for help on using the repository browser.