Ignore:
Timestamp:
02/07/22 19:57:58 (3 years ago)
Author:
Petar Partaloski <ppartaloski@…>
Branches:
main
Children:
ad4243e, c02189f
Parents:
7f36551
Message:

Added genre liking, fixed counter, improved paging, improved searches

File:
1 edited

Legend:

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

    r7f36551 r3c0f9a9  
    99import com.wediscussmovies.project.service.PersonService;
    1010import com.wediscussmovies.project.web.DesignFrontMovies;
     11import com.wediscussmovies.project.web.PageFrontMovies;
    1112import lombok.Data;
    1213import org.springframework.format.annotation.DateTimeFormat;
     
    3738    }
    3839
    39     @GetMapping
     40    @GetMapping("/old")
    4041    public String getMovies(@RequestParam(required = false) String titleQuery, Model model,
    4142                            @RequestParam(required = false) String error){
     
    5556        model.addAttribute("movie_rows", movie_rows);
    5657        model.addAttribute("contentTemplate", "moviesList");
     58        if (error != null && !error.equals(" "))
     59            model.addAttribute("error",error);
     60        return "template";
     61    }
     62
     63
     64    @GetMapping
     65    public String getMoviesAlternative(@RequestParam(required = false) String titleQuery, Model model,
     66                            @RequestParam(required = false) String error, @RequestParam(required = false) String page){
     67        if (page==null){
     68            return "redirect:/movies?page=1";
     69        }
     70        addModelPropertiesForUser(model);
     71        List<Movie> movies = PageFrontMovies.getPagedMovies(page, movieService, model);
     72        List<List<Movie>> movie_rows = new ArrayList<>();
     73        DesignFrontMovies.designMovieList(movies,movie_rows);
     74        model.addAttribute("movies", movies);
     75        model.addAttribute("movie_rows", movie_rows);
     76        model.addAttribute("contentTemplate", "moviesListPaged");
    5777        if (error != null && !error.equals(" "))
    5878            model.addAttribute("error",error);
     
    160180    }
    161181    private void addModelProperties(Model model){
    162 
    163         model.addAttribute("directors",  personService.findAllDirectors());
     182        model.addAttribute("directors", personService.findAllDirectors());
    164183        model.addAttribute("actors", personService.findAllActors());
    165184        model.addAttribute("genres", genreService.findAll());
     
    169188        model.addAttribute("likedMovies",this.movieService.findLikedMoviesByUser(user));
    170189        model.addAttribute("user",user);
    171         }
     190    }
    172191
    173192}
Note: See TracChangeset for help on using the changeset viewer.