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 | |
---|
1 | package com.example.medweb.service.impl;
|
---|
2 |
|
---|
3 | import com.example.medweb.model.Doktor;
|
---|
4 | import com.example.medweb.model.exceptions.InvalidArgumentsException;
|
---|
5 | import com.example.medweb.model.exceptions.InvalidUserCredentialsException;
|
---|
6 | import com.example.medweb.repository.DoktorRepository;
|
---|
7 | import com.example.medweb.service.DoktorService;
|
---|
8 | import org.springframework.stereotype.Service;
|
---|
9 |
|
---|
10 | import java.util.List;
|
---|
11 | import java.util.Optional;
|
---|
12 |
|
---|
13 | @Service
|
---|
14 | public 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.