Last change
on this file was b3f2adb, checked in by Aleksandar Siljanoski <acewow3@…>, 14 months ago |
Adding project to repo
|
-
Property mode
set to
100644
|
File size:
875 bytes
|
Line | |
---|
1 | package com.example.eatys_app.service;
|
---|
2 |
|
---|
3 | import com.example.eatys_app.model.Tip;
|
---|
4 | import com.example.eatys_app.model.exceptions.InvalidTipIdException;
|
---|
5 | import com.example.eatys_app.repository.TipRepository;
|
---|
6 | import org.springframework.stereotype.Service;
|
---|
7 |
|
---|
8 | import java.util.List;
|
---|
9 |
|
---|
10 | @Service
|
---|
11 | public class TipServiceImpl implements TipService{
|
---|
12 |
|
---|
13 | private final TipRepository tipRepository;
|
---|
14 |
|
---|
15 | public TipServiceImpl(TipRepository tipRepository) {
|
---|
16 | this.tipRepository = tipRepository;
|
---|
17 | }
|
---|
18 |
|
---|
19 |
|
---|
20 | @Override
|
---|
21 | public Tip findById(Integer id) {
|
---|
22 | return this.tipRepository.findById(id).orElseThrow(InvalidTipIdException::new);
|
---|
23 | }
|
---|
24 |
|
---|
25 | @Override
|
---|
26 | public List<Tip> listAll() {
|
---|
27 | return this.tipRepository.findAll();
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public Tip create(String ime) {
|
---|
32 | Tip tip = new Tip(ime);
|
---|
33 | return this.tipRepository.save(tip);
|
---|
34 | }
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.