Changeset 632e3d8 for src/main/java


Ignore:
Timestamp:
02/08/23 14:41:27 (22 months ago)
Author:
milamihajlovska <mila.mihajlovska01@…>
Branches:
master
Children:
2c7a732
Parents:
39a45e6 (diff), 90317ea (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of https://github.com/DenicaKj/MovieZone

Location:
src/main/java/com/example/moviezone
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/repository/EventRepository.java

    r39a45e6 r632e3d8  
    22
    33import com.example.moviezone.model.Event;
     4import com.example.moviezone.model.Film;
    45import org.springframework.data.jpa.repository.JpaRepository;
     6import org.springframework.data.jpa.repository.query.Procedure;
     7
     8import java.util.List;
    59
    610public interface EventRepository extends JpaRepository<Event,Integer> {
     11    @Procedure("project.getEventsFromCinema")
     12    List<Event> getFilmsFromCinema(int id);
     13    @Procedure("project.getEventsFromNow")
     14    List<Event> getFilmsFromCinemaNow();
     15
    716}
  • src/main/java/com/example/moviezone/repository/FilmRepository.java

    r39a45e6 r632e3d8  
    1717    @Procedure("project.getFilmsFromCinema1")
    1818    List<Film> getFilmsFromCinema(int id);
    19 
     19    @Procedure("project.getFilmsFromCinemaNow")
     20    List<Film> getFilmsFromCinemaNow(int id);
     21    @Procedure("project.getFilmsNow")
     22    List<Film> getFilmsNow();
    2023}
  • src/main/java/com/example/moviezone/service/EventService.java

    r39a45e6 r632e3d8  
    55import java.time.LocalDate;
    66import java.util.List;
     7import java.util.Optional;
    78
    89public interface EventService {
    910    List<Event> findAllEvents();
    1011    Event save(LocalDate start_date,String theme,String duration,String repeating,String url);
     12    List<Event> getEventsNow();
     13    List<Event> getEventsFromCinema(int id);
     14    Optional<Event> getEventById(Long id);
    1115}
  • src/main/java/com/example/moviezone/service/FilmService.java

    r39a45e6 r632e3d8  
    1414    Optional<Film> getFilmById(Long id);
    1515    List<Film> getFilmsFromCinema(int id);
     16    List<Film> getFilmsFromCinemaNow(int id);
     17    List<Film> getFilmsNow();
    1618}
  • src/main/java/com/example/moviezone/service/Impl/EventServiceImpl.java

    r39a45e6 r632e3d8  
    77
    88import java.time.LocalDate;
     9import java.util.Collections;
    910import java.util.List;
     11import java.util.Optional;
    1012
    1113@Service
     
    2628        return eventRepository.save(new Event(theme,duration,repeating,start_date,img_url));
    2729    }
     30
     31    @Override
     32    public List<Event> getEventsNow() {
     33        return eventRepository.getFilmsFromCinemaNow();
     34    }
     35
     36    @Override
     37    public List<Event> getEventsFromCinema(int id) {
     38        return eventRepository.getFilmsFromCinema(id);
     39    }
     40
     41    @Override
     42    public Optional<Event> getEventById(Long id) {
     43        return eventRepository.findAllById(Collections.singleton(id.intValue())).stream().findFirst();
     44    }
    2845}
  • src/main/java/com/example/moviezone/service/Impl/FilmServiceImpl.java

    r39a45e6 r632e3d8  
    4040    }
    4141
     42    @Override
     43    public List<Film> getFilmsFromCinemaNow(int id) {
     44        return filmRepository.getFilmsFromCinemaNow(id);
     45    }
     46
     47    @Override
     48    public List<Film> getFilmsNow() {
     49        return filmRepository.getFilmsNow();
     50    }
     51
    4252}
  • src/main/java/com/example/moviezone/web/HomeController.java

    r39a45e6 r632e3d8  
    1616import org.springframework.web.bind.annotation.*;
    1717
     18import javax.naming.event.EventDirContext;
    1819import javax.servlet.http.HttpSession;
    1920import javax.transaction.Transactional;
     
    7980        return "master-template";
    8081    }
    81 
     82    @GetMapping("/getEvent/{id}")
     83    public String getEvent(@PathVariable Long id, Model model) {
     84        Event event =eventService.getEventById(id).get();
     85        model.addAttribute("event", event);
     86        model.addAttribute("bodyContent", "event");
     87
     88        return "master-template";
     89    }
    8290    @GetMapping("/login")
    8391    public String getLoginPage(Model model)
     
    149157        return "master-template";
    150158    }
    151 
     159    @Transactional
    152160    @GetMapping("/projections")
    153     public String getProjectionsPage(Model model)
    154     {
    155         model.addAttribute("projections",projectionService.findAllProjections());
    156         model.addAttribute("bodyContent","projections");
     161    public String getProjectionsPage(Model model,@RequestParam(required = false) Integer id_cinema)
     162    {
     163        model.addAttribute("cinemas",cinemaService.findAllCinemas());
     164        if (id_cinema!=null) {
     165            model.addAttribute("films",filmService.getFilmsFromCinemaNow(id_cinema));
     166        }else{
     167            List<FilmsReturnTable> pom=new LinkedList<>();
     168            model.addAttribute("films",filmService.getFilmsNow());
     169        }
     170        model.addAttribute("bodyContent","films");
    157171        return "master-template";
    158172    }
    159173    @GetMapping("/events")
    160     public String getEventsPage(Model model)
    161     {
    162         model.addAttribute("events",eventService.findAllEvents());
     174    @Transactional
     175    public String getEventsPage(Model model,@RequestParam(required = false) Integer id_cinema)
     176    {
     177        model.addAttribute("cinemas",cinemaService.findAllCinemas());
     178        if (id_cinema!=null) {
     179            model.addAttribute("events",eventService.getEventsFromCinema(id_cinema));
     180        }else{
     181            List<FilmsReturnTable> pom=new LinkedList<>();
     182            model.addAttribute("events",eventService.getEventsNow());
     183        }
    163184        model.addAttribute("bodyContent","events");
    164185        return "master-template";
Note: See TracChangeset for help on using the changeset viewer.