Ignore:
Timestamp:
02/06/23 03:59:41 (22 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
f8ef9bd
Parents:
448bd84
Message:

Home Page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/web/HomeController.java

    r448bd84 reb5426c  
    33
    44import com.example.moviezone.model.Customer;
     5import com.example.moviezone.model.Film;
    56import com.example.moviezone.model.User;
    67import com.example.moviezone.model.exceptions.UserNotFoundException;
     
    910import org.springframework.stereotype.Controller;
    1011import org.springframework.ui.Model;
    11 import org.springframework.web.bind.annotation.GetMapping;
    12 import org.springframework.web.bind.annotation.PostMapping;
    13 import org.springframework.web.bind.annotation.RequestMapping;
    14 import org.springframework.web.bind.annotation.RequestParam;
     12import org.springframework.web.bind.annotation.*;
    1513
    1614import javax.servlet.http.HttpSession;
    1715import java.time.LocalDate;
     16import java.util.List;
     17import java.util.Optional;
     18import java.util.stream.Collectors;
    1819
    1920@Controller
    20 @RequestMapping("/")
     21@RequestMapping({"/","/home"})
    2122public class HomeController {
    2223
     
    3738    }
    3839
    39     @GetMapping({"/","/home"})
     40    @GetMapping
    4041    public String getHomePage(Model model) {
     42        List<Film> films=filmService.findAllFilms();
     43        films=films.stream().limit(5).collect(Collectors.toList());
     44        model.addAttribute("films", films);
    4145        model.addAttribute("bodyContent", "home");
     46
     47        return "master-template";
     48    }
     49    @GetMapping("/getFilm/{id}")
     50    public String getFilm(@PathVariable Long id, Model model) {
     51        Optional<Film> film=filmService.getFilmById(id);
     52        model.addAttribute("film", film);
     53        model.addAttribute("bodyContent", "home");
     54
    4255        return "master-template";
    4356    }
     
    97110    public String getProjectionsPage(Model model)
    98111    {
    99         model.addAttribute("projections",projectionService.findAllAvailableProjections(LocalDate.now()));
     112        model.addAttribute("projections",projectionService.findAllProjections());
    100113        model.addAttribute("bodyContent","projections");
    101114        return "master-template";
Note: See TracChangeset for help on using the changeset viewer.