Changeset 42d565b in Git for src/main/java/com/wediscussmovies/project/web/controller/MovieController.java
- Timestamp:
- 02/06/22 21:38:16 (3 years ago)
- Branches:
- main
- Children:
- 7f36551
- Parents:
- 5b447b0 (diff), 2efe93e (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/06/22 21:38:16)
- git-committer:
- GitHub <noreply@…> (02/06/22 21:38:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/web/controller/MovieController.java
r5b447b0 r42d565b 1 1 package com.wediscussmovies.project.web.controller; 2 2 3 import com.wediscussmovies.project.LoggedUser; 3 4 import com.wediscussmovies.project.model.Movie; 4 5 import com.wediscussmovies.project.model.Person; … … 19 20 import java.sql.Date; 20 21 import java.time.LocalDate; 22 import java.util.ArrayList; 21 23 import java.util.List; 22 24 … … 53 55 model.addAttribute("user",user); 54 56 } 55 57 List<Movie> movieList = movies; 58 List<List<Movie>> movie_rows = new ArrayList<>(); 59 for(int i=0; i<movieList.size(); i+=4){ 60 int j = i+4; 61 if(j>movieList.size()) 62 j=movieList.size(); 63 movie_rows.add(movieList.subList(i, j)); 64 } 56 65 model.addAttribute("movies", movies); 66 model.addAttribute("movie_rows", movie_rows); 57 67 model.addAttribute("contentTemplate", "moviesList"); 58 68 if (error != null && !error.equals(" ")) … … 61 71 } 62 72 73 @GetMapping("/{id}") 74 public String getMovie(@PathVariable Integer id, Model model){ 75 model.addAttribute("movie", movieService.findById(id)); 76 77 Authentication auth = SecurityContextHolder.getContext().getAuthentication(); 78 if (!(auth instanceof AnonymousAuthenticationToken)){ 79 UserDetails userDetails = (UserDetails) auth.getPrincipal(); 80 User user = (User) userDetails; 81 model.addAttribute("likedMovies",this.movieService.findLikedMoviesByUser(user)); 82 model.addAttribute("user",user); 83 } 84 85 model.addAttribute("contentTemplate", "movieShow"); 86 return "template"; 87 } 63 88 64 89 @GetMapping("/add")
Note:
See TracChangeset
for help on using the changeset viewer.