source: src/main/java/com/example/service/impl/PhotographerServiceImpl.java

Last change on this file was a51a591, checked in by colovik <j.colovik@…>, 14 months ago

final

  • Property mode set to 100644
File size: 935 bytes
RevLine 
[a51a591]1package com.example.service.impl;
2
3import com.example.exceptions.NoSuchUsernameException;
4import com.example.model.Photographer;
5import com.example.repository.PhotographerRepository;
6import com.example.service.PhotographerService;
7import org.springframework.stereotype.Service;
8
9import java.util.List;
10
11@Service
12public 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.