Changeset 0226942 in Git for src/main/java/com/wediscussmovies/project/web/controller/DiscussionController.java
- Timestamp:
- 02/08/22 22:07:07 (3 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/web/controller/DiscussionController.java
rad4243e r0226942 5 5 import com.wediscussmovies.project.model.Reply; 6 6 import com.wediscussmovies.project.model.User; 7 import com.wediscussmovies.project.model.relation.DiscussionLikes; 7 8 import com.wediscussmovies.project.service.DiscussionService; 8 9 import com.wediscussmovies.project.service.MovieService; … … 17 18 import org.springframework.web.bind.annotation.*; 18 19 20 import java.util.ArrayList; 19 21 import java.util.List; 20 22 … … 46 48 model.addAttribute("contentTemplate", "discussionsList"); 47 49 model.addAttribute("user",LoggedUser.getLoggedUser()); 50 this.addModelPropertiesForUser(model); 51 this.addModelPropertiesLikes(model,null, discussions); 48 52 return "template"; 49 53 } … … 62 66 model.addAttribute("user",LoggedUser.getLoggedUser()); 63 67 model.addAttribute("replies",this.replyService.findAllByDiscussion(disc)); 68 addModelPropertiesLikes(model, disc, null); 69 addModelPropertiesForUser(model); 64 70 65 71 return "template"; … … 171 177 172 178 } 179 private void addModelPropertiesForUser(Model model){ 180 User user = LoggedUser.getLoggedUser(); 181 model.addAttribute("likedDiscussions",this.discussionService.findLikedDiscussionsByUser(user)); 182 model.addAttribute("user",user); 183 } 184 private void addModelPropertiesLikes(Model model, Discussion discussion, List<Discussion> discussions){ 185 if(discussion==null){ 186 List<com.wediscussmovies.project.querymodels.DiscussionLikes> discussionLikes = new ArrayList<>(); 187 for(Discussion d: discussions){ 188 discussionLikes.add(discussionService.findLikesForDiscussionWithId(d.getDiscussionId())); 189 } 190 model.addAttribute("likes", discussionLikes); 191 } 192 else{ 193 model.addAttribute("likes",discussionService.findLikesForDiscussionWithId(discussion.getDiscussionId()).getLikes()); 194 } 195 } 173 196 174 197
Note:
See TracChangeset
for help on using the changeset viewer.