Ignore:
Timestamp:
02/08/22 20:13:23 (3 years ago)
Author:
Petar Partaloski <ppartaloski@…>
Branches:
main
Children:
0226942, 3fe36de
Parents:
3c0f9a9
Message:

Added new core functionalities, fixed bugs and improved visual clarity

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/wediscussmovies/project/web/controller/MovieController.java

    r3c0f9a9 rc02189f  
    55import com.wediscussmovies.project.model.Person;
    66import com.wediscussmovies.project.model.User;
     7import com.wediscussmovies.project.querymodels.MovieLikesQM;
    78import com.wediscussmovies.project.service.GenreService;
    89import com.wediscussmovies.project.service.MovieService;
     
    2324import java.time.LocalDate;
    2425import java.util.ArrayList;
     26import java.util.HashMap;
     27import java.util.LinkedList;
    2528import java.util.List;
    2629
     
    3942
    4043    @GetMapping("/old")
    41     public String getMovies(@RequestParam(required = false) String titleQuery, Model model,
     44    public String getMoviesOld(@RequestParam(required = false) String titleQuery, Model model,
    4245                            @RequestParam(required = false) String error){
    4346        List<Movie> movies;
     
    5659        model.addAttribute("movie_rows", movie_rows);
    5760        model.addAttribute("contentTemplate", "moviesList");
     61        model.addAttribute("genres", genreService.findAll());
    5862        if (error != null && !error.equals(" "))
    5963            model.addAttribute("error",error);
     
    6367
    6468    @GetMapping
    65     public String getMoviesAlternative(@RequestParam(required = false) String titleQuery, Model model,
     69    public String getMovies(@RequestParam(required = false) String titleQuery, Model model,
    6670                            @RequestParam(required = false) String error, @RequestParam(required = false) String page){
    6771        if (page==null){
     
    7276        List<List<Movie>> movie_rows = new ArrayList<>();
    7377        DesignFrontMovies.designMovieList(movies,movie_rows);
     78        //addModelPropertiesForMoviesLikes(model, movies);
    7479        model.addAttribute("movies", movies);
    7580        model.addAttribute("movie_rows", movie_rows);
     81        model.addAttribute("genres", genreService.findAll());
    7682        model.addAttribute("contentTemplate", "moviesListPaged");
    7783        if (error != null && !error.equals(" "))
     
    8490        model.addAttribute("movie", movieService.findById(id));
    8591        addModelPropertiesForUser(model);
     92        model.addAttribute("likes", movieService.findLikesForMovieById(id).getLikes());
    8693        model.addAttribute("contentTemplate", "movieShow");
    8794        return "template";
     
    189196        model.addAttribute("user",user);
    190197    }
     198    private void addModelPropertiesForMoviesLikes(Model model, List<Movie> movies){
     199        HashMap<Integer,MovieLikesQM> movieLikes = new HashMap<>();
     200        for(Movie m: movies){
     201            movieLikes.put(m.getMovieId(),movieService.findLikesForMovieById(m.getMovieId()));
     202        }
     203        model.addAttribute("movieLikes", movieLikes);
     204    }
    191205
    192206}
Note: See TracChangeset for help on using the changeset viewer.