Line | |
---|
1 | package com.example.cookbook.service.impl;
|
---|
2 |
|
---|
3 |
|
---|
4 | import com.example.cookbook.model.Komentar;
|
---|
5 | import com.example.cookbook.repository.KomentariRepository;
|
---|
6 | import com.example.cookbook.service.KomentariService;
|
---|
7 | import org.springframework.stereotype.Service;
|
---|
8 |
|
---|
9 | import java.sql.SQLException;
|
---|
10 | import java.time.LocalDateTime;
|
---|
11 | import java.util.List;
|
---|
12 |
|
---|
13 | @Service
|
---|
14 | public class KomentariServiceImpl implements KomentariService {
|
---|
15 |
|
---|
16 | private final KomentariRepository komentariRepository;
|
---|
17 |
|
---|
18 | public KomentariServiceImpl(KomentariRepository komentariRepository) {
|
---|
19 | this.komentariRepository = komentariRepository;
|
---|
20 | }
|
---|
21 |
|
---|
22 | @Override
|
---|
23 | public List<Komentar> findAllById(Long recId) throws SQLException {
|
---|
24 | return komentariRepository.findAllByRecId(recId);
|
---|
25 | }
|
---|
26 |
|
---|
27 | @Override
|
---|
28 | public void add(String telefon, Long id, Integer ocena, String komentar) throws SQLException {
|
---|
29 | if (telefon.isBlank() || ocena == null){
|
---|
30 | throw new IllegalArgumentException();
|
---|
31 | }
|
---|
32 | komentariRepository.save(new Komentar(LocalDateTime.now(), telefon, id, ocena, komentar));
|
---|
33 | }
|
---|
34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.