Ignore:
Timestamp:
02/08/22 22:07:07 (3 years ago)
Author:
GitHub <noreply@…>
Branches:
main
Children:
967b414
Parents:
ad4243e (diff), c02189f (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.
git-author:
Mato-77 <56981531+Mato-77@…> (02/08/22 22:07:07)
git-committer:
GitHub <noreply@…> (02/08/22 22:07:07)
Message:

Merge pull request #3 from partaloski/master

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

    rad4243e r0226942  
    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.