Last change
on this file was 501396e, checked in by Blazho <aleksandar.blazhevski@…>, 9 months ago |
added missing files
|
-
Property mode
set to
100644
|
File size:
983 bytes
|
Line | |
---|
1 | package com.example.cookbook.service.impl;
|
---|
2 |
|
---|
3 | import com.example.cookbook.model.Recept;
|
---|
4 | import com.example.cookbook.model.exception.ReceptNeEPronajdenException;
|
---|
5 | import com.example.cookbook.repository.ReceptRepository;
|
---|
6 | import com.example.cookbook.service.ReceptService;
|
---|
7 | import org.springframework.stereotype.Service;
|
---|
8 |
|
---|
9 | import java.sql.SQLException;
|
---|
10 | import java.util.List;
|
---|
11 | import java.util.Optional;
|
---|
12 |
|
---|
13 | @Service
|
---|
14 | public class ReceptServiceImpl implements ReceptService {
|
---|
15 |
|
---|
16 | private final ReceptRepository receptRepository;
|
---|
17 |
|
---|
18 | public ReceptServiceImpl(ReceptRepository receptRepository) {
|
---|
19 | this.receptRepository = receptRepository;
|
---|
20 | }
|
---|
21 |
|
---|
22 | @Override
|
---|
23 | public List<Recept> listAll() throws SQLException {
|
---|
24 | return receptRepository.findAll();
|
---|
25 | }
|
---|
26 |
|
---|
27 | @Override
|
---|
28 | public Recept findById(Long id) throws SQLException {
|
---|
29 | Recept recept;
|
---|
30 |
|
---|
31 | recept = receptRepository.findById(id).orElseThrow(ReceptNeEPronajdenException::new);
|
---|
32 |
|
---|
33 | return recept;
|
---|
34 | }
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.