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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.