Rev | Line | |
---|
[a51a591] | 1 | package com.example.service.impl;
|
---|
| 2 |
|
---|
| 3 | import com.example.exceptions.NoSuchUsernameException;
|
---|
| 4 | import com.example.model.Photographer;
|
---|
| 5 | import com.example.repository.PhotographerRepository;
|
---|
| 6 | import com.example.service.PhotographerService;
|
---|
| 7 | import org.springframework.stereotype.Service;
|
---|
| 8 |
|
---|
| 9 | import java.util.List;
|
---|
| 10 |
|
---|
| 11 | @Service
|
---|
| 12 | public class PhotographerServiceImpl implements PhotographerService {
|
---|
| 13 |
|
---|
| 14 | private final PhotographerRepository photographerRepository;
|
---|
| 15 |
|
---|
| 16 | public PhotographerServiceImpl(PhotographerRepository photographerRepository) {
|
---|
| 17 | this.photographerRepository = photographerRepository;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | @Override
|
---|
| 21 | public List<Photographer> findAll() {
|
---|
| 22 | return this.photographerRepository.findAll();
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | @Override
|
---|
| 26 | public Photographer findByName(String name) {
|
---|
| 27 | return this.photographerRepository.findAllByName(name).stream().findFirst()
|
---|
| 28 | .orElseThrow(NoSuchUsernameException::new);
|
---|
| 29 | }
|
---|
| 30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.