Ignore:
Timestamp:
02/04/23 21:01:13 (23 months ago)
Author:
milamihajlovska <mila.mihajlovska01@…>
Branches:
master
Children:
693f587
Parents:
a554435
Message:

home controller added mappings for add new film, event and projection

Location:
src/main/java/com/example/moviezone/service
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/service/EventService.java

    ra554435 r302b233  
    33import com.example.moviezone.model.Event;
    44
     5import java.time.LocalDate;
    56import java.util.List;
    67
    78public interface EventService {
    89    List<Event> findAllEvents();
    9 
     10    Event save(LocalDate start_date,String theme,String duration,String repeating);
    1011}
  • src/main/java/com/example/moviezone/service/FilmService.java

    ra554435 r302b233  
    33import com.example.moviezone.model.Film;
    44
     5import java.time.LocalDate;
    56import java.util.List;
    67
    78public interface FilmService {
    89    List<Film> findAllFilms();
     10    Film save(String name, Integer duration, String actors, String genre,
     11              String age_category, String url, String director, LocalDate start_date,LocalDate end_date );
    912}
  • src/main/java/com/example/moviezone/service/Impl/EventServiceImpl.java

    ra554435 r302b233  
    66import org.springframework.stereotype.Service;
    77
     8import java.time.LocalDate;
    89import java.util.List;
    910
     
    2021        return eventRepository.findAll();
    2122    }
     23
     24    @Override
     25    public Event save(LocalDate start_date, String theme, String duration, String repeating) {
     26        return eventRepository.save(new Event(theme,duration,repeating,start_date));
     27    }
    2228}
  • src/main/java/com/example/moviezone/service/Impl/FilmServiceImpl.java

    ra554435 r302b233  
    66import org.springframework.stereotype.Service;
    77
     8import java.time.LocalDate;
    89import java.util.List;
    910
     
    2021        return filmRepository.findAll();
    2122    }
     23
     24    @Override
     25    public Film save(String name, Integer duration, String actors, String genre, String age_category, String url, String director, LocalDate start_date, LocalDate end_date) {
     26        return filmRepository.save(new Film(name,duration,actors,genre,age_category,url,director,start_date,end_date));
     27    }
    2228}
  • src/main/java/com/example/moviezone/service/Impl/ProjectionServiceImpl.java

    ra554435 r302b233  
    11package com.example.moviezone.service.Impl;
    22
     3import com.example.moviezone.model.Film;
    34import com.example.moviezone.model.Projection;
     5import com.example.moviezone.repository.FilmRepository;
    46import com.example.moviezone.repository.ProjectionRepository;
    57import com.example.moviezone.service.ProjectionService;
     
    1214public class ProjectionServiceImpl implements ProjectionService {
    1315    private final ProjectionRepository projectionRepository;
    14 
    15     public ProjectionServiceImpl(ProjectionRepository projectionRepository) {
     16    private final FilmRepository filmRepository;
     17    public ProjectionServiceImpl(ProjectionRepository projectionRepository, FilmRepository filmRepository) {
    1618        this.projectionRepository = projectionRepository;
     19        this.filmRepository = filmRepository;
    1720    }
    1821
     
    2730    }
    2831
     32    @Override
     33    public Projection save(LocalDate date_time_start, LocalDate date_time_end, String type_of_technology, Integer id_film) {
     34       Film film=filmRepository.findById(id_film).orElseThrow(RuntimeException::new);
     35        return projectionRepository.save(new Projection(date_time_start,type_of_technology,date_time_end,film));
     36    }
     37
    2938}
  • src/main/java/com/example/moviezone/service/ProjectionService.java

    ra554435 r302b233  
    11package com.example.moviezone.service;
    22
     3import com.example.moviezone.model.Film;
    34import com.example.moviezone.model.Projection;
    45
     
    910    List<Projection> findAllProjections();
    1011List<Projection> findAllAvailableProjections(LocalDate date);
    11 
     12Projection save(LocalDate date_time_start,LocalDate date_time_end, String type_of_technology, Integer id_film );
    1213}
Note: See TracChangeset for help on using the changeset viewer.