Changeset a554435 for src


Ignore:
Timestamp:
02/04/23 19:55:16 (22 months ago)
Author:
milamihajlovska <mila.mihajlovska01@…>
Branches:
master
Children:
302b233, 4ee640e
Parents:
e097c1c
Message:

home controller added getMappings

Location:
src/main
Files:
2 added
4 edited
2 moved

Legend:

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

    re097c1c ra554435  
    44import org.springframework.data.jpa.repository.JpaRepository;
    55
     6import java.time.LocalDate;
     7import java.util.List;
     8
    69public interface ProjectionRepository extends JpaRepository<Projection,Integer> {
     10    //    NOTE: CHANGE THIS WITH MATERIALIZED VIEW
     11    List<Projection> findAllByDate_time_startBefore(LocalDate datum);
    712}
  • src/main/java/com/example/moviezone/service/Impl/ProjectionServiceImpl.java

    re097c1c ra554435  
    66import org.springframework.stereotype.Service;
    77
     8import java.time.LocalDate;
    89import java.util.List;
    910
     
    2021        return projectionRepository.findAll();
    2122    }
     23
     24    @Override
     25    public List<Projection> findAllAvailableProjections(LocalDate date) {
     26        return projectionRepository.findAllByDate_time_startBefore(date);
     27    }
     28
    2229}
  • src/main/java/com/example/moviezone/service/ProjectionService.java

    re097c1c ra554435  
    33import com.example.moviezone.model.Projection;
    44
     5import java.time.LocalDate;
    56import java.util.List;
    67
    78public interface ProjectionService {
    89    List<Projection> findAllProjections();
     10List<Projection> findAllAvailableProjections(LocalDate date);
     11
    912}
  • src/main/java/com/example/moviezone/web/HomeController.java

    re097c1c ra554435  
    44import com.example.moviezone.model.User;
    55import com.example.moviezone.model.exceptions.UserNotFoundException;
     6import com.example.moviezone.service.EventService;
    67import com.example.moviezone.service.FilmService;
     8import com.example.moviezone.service.ProjectionService;
    79import com.example.moviezone.service.UserService;
    810import org.springframework.stereotype.Controller;
     
    1416
    1517import javax.servlet.http.HttpSession;
     18import java.time.LocalDate;
    1619
    1720@Controller
     
    2124private final FilmService filmService;
    2225private final UserService userService;
     26private final ProjectionService projectionService;
     27private final EventService eventService;
    2328
    24     public HomeController(FilmService filmService, UserService userService) {
     29    public HomeController(FilmService filmService, UserService userService, ProjectionService projectionService, EventService eventService) {
    2530        this.filmService = filmService;
    2631        this.userService = userService;
     32        this.projectionService = projectionService;
     33        this.eventService = eventService;
    2734    }
    2835
     
    7784    }
    7885
     86    @GetMapping("/films")
     87    public String getFilmsPage(Model model){
     88        model.addAttribute("films",filmService.findAllFilms());
     89        model.addAttribute("bodyContent","films");
     90        return "master-template";
     91    }
     92
     93    @GetMapping("/projections")
     94    public String getProjectionsPage(Model model)
     95    {
     96        model.addAttribute("projections",projectionService.findAllAvailableProjections(LocalDate.now()));
     97        model.addAttribute("bodyContent","projections");
     98        return "master-template";
     99    }
     100    @GetMapping("/events")
     101    public String getEventsPage(Model model)
     102    {
     103        model.addAttribute("events",eventService.findAllEvents());
     104        model.addAttribute("bodyContent","events");
     105        return "master-template";
     106    }
     107
    79108}
Note: See TracChangeset for help on using the changeset viewer.