source: src/main/java/com/example/moviezone/service/Impl/FilmServiceImpl.java@ f8ef9bd

Last change on this file since f8ef9bd was eb5426c, checked in by DenicaKj <dkorvezir@…>, 22 months ago

Home Page

  • Property mode set to 100644
File size: 1.1 KB
Line 
1package com.example.moviezone.service.Impl;
2
3import com.example.moviezone.model.Film;
4import com.example.moviezone.repository.FilmRepository;
5import com.example.moviezone.service.FilmService;
6import org.springframework.stereotype.Service;
7
8import java.time.LocalDate;
9import java.util.Collections;
10import java.util.List;
11import java.util.Optional;
12
13@Service
14public class FilmServiceImpl implements FilmService {
15 private final FilmRepository filmRepository;
16
17 public FilmServiceImpl(FilmRepository filmRepository) {
18 this.filmRepository = filmRepository;
19 }
20
21 @Override
22 public List<Film> findAllFilms() {
23 return filmRepository.findAll();
24 }
25
26 @Override
27 public Film save(String name, Integer duration, String actors, String genre, String age_category, String url, String director, LocalDate start_date, LocalDate end_date) {
28 return filmRepository.save(new Film(name,duration,actors,genre,age_category,url,director,start_date,end_date));
29 }
30
31 @Override
32 public Optional<Film> getFilmById(Long id) {
33 return filmRepository.findAllById(Collections.singleton(id.intValue())).stream().findFirst();
34 }
35
36}
Note: See TracBrowser for help on using the repository browser.