source: src/main/java/com/example/cookbook/service/impl/KomentariServiceImpl.java@ d4d8fb9

Last change on this file since d4d8fb9 was d4d8fb9, checked in by Blazho <aleksandar.blazhevski@…>, 5 months ago

Posetitelot komentira i dava ocena za recept(https://develop.finki.ukim.mk/projects/cbdb/wiki/useCase11)

  • Property mode set to 100644
File size: 1.1 KB
Line 
1package com.example.cookbook.service.impl;
2
3
4import com.example.cookbook.model.Komentar;
5import com.example.cookbook.repository.KomentariRepository;
6import com.example.cookbook.service.KomentariService;
7import org.springframework.stereotype.Service;
8
9import java.sql.SQLException;
10import java.time.LocalDateTime;
11import java.util.List;
12
13@Service
14public 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.