package com.example.cookbook.service.impl; import com.example.cookbook.model.Komentar; import com.example.cookbook.repository.KomentariRepository; import com.example.cookbook.service.KomentariService; import org.springframework.stereotype.Service; import java.sql.SQLException; import java.time.LocalDateTime; import java.util.List; @Service public class KomentariServiceImpl implements KomentariService { private final KomentariRepository komentariRepository; public KomentariServiceImpl(KomentariRepository komentariRepository) { this.komentariRepository = komentariRepository; } @Override public List findAllById(Long recId) throws SQLException { return komentariRepository.findAllByRecId(recId); } @Override public void add(String telefon, Long id, Integer ocena, String komentar) throws SQLException { if (telefon.isBlank() || ocena == null){ throw new IllegalArgumentException(); } komentariRepository.save(new Komentar(LocalDateTime.now(), telefon, id, ocena, komentar)); } }