source: src/main/java/com/example/eatys_app/service/TipServiceImpl.java

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 
1package com.example.eatys_app.service;
2
3import com.example.eatys_app.model.Tip;
4import com.example.eatys_app.model.exceptions.InvalidTipIdException;
5import com.example.eatys_app.repository.TipRepository;
6import org.springframework.stereotype.Service;
7
8import java.util.List;
9
10@Service
11public 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.