Changeset 8f1b7e9 in Git for src/main/java/com/wediscussmovies/project/service
- Timestamp:
- 02/10/22 13:28:00 (3 years ago)
- Branches:
- main
- Children:
- 980eeda
- Parents:
- 6f91f99
- Location:
- src/main/java/com/wediscussmovies/project/service
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/service/DiscussionService.java
r6f91f99 r8f1b7e9 22 22 DiscussionLikesQM findLikesForDiscussionWithId(Integer discussionId); 23 23 24 void findLikesForAllDiscussions(List<Discussion> discussions);24 List<DiscussionLikesQM> findLikesForAllDiscussions(); 25 25 26 26 } -
src/main/java/com/wediscussmovies/project/service/impl/DiscussionServiceImpl.java
r6f91f99 r8f1b7e9 16 16 import org.springframework.stereotype.Service; 17 17 18 import java.sql.Date;19 18 import java.time.LocalDate; 20 19 import java.util.ArrayList; 21 20 import java.util.List; 21 import java.util.concurrent.atomic.AtomicInteger; 22 22 23 23 @Service … … 45 45 @Override 46 46 public List<Discussion> listAll() { 47 return this.discussionRepository.findAll(); 47 List<Discussion> discussions = this.discussionRepository.findAll(); 48 List<DiscussionLikesQM> discussionLikes = this.discussionRepository.findAllDiscussionsWithLikes(); 49 for (int i = 0; i < discussionLikes.size(); i++){ 50 discussions.get(i).setLikes(discussionLikes.get(i).getLikes()); 51 } 52 return discussions; 48 53 } 49 54 50 55 @Override 51 56 public void save(Character type,Integer id,String title, String text,User user) { 52 Date date = Date.valueOf(LocalDate.now());57 LocalDate date = LocalDate.now(); 53 58 Discussion discussion; 54 59 … … 123 128 124 129 @Override 125 public void findLikesForAllDiscussions(List<Discussion> discussions) { 126 // this.discussionRepository.findAllDiscussionsWithLikes() 127 // .forEach(el ->{ 128 // if (discussions.) 129 // }); 130 public List<DiscussionLikesQM> findLikesForAllDiscussions() { 131 // return this.discussionRepository.findAllDiscussionsWithLikes(); 132 return this.discussionRepository.findAllDiscussionsWithLikes(); 130 133 } 131 134 … … 145 148 @Override 146 149 public Discussion findById(Integer id) { 147 return discussionRepository.findById(id).orElseThrow(() -> new DiscussionNotExistException(id)); 150 Discussion disc = discussionRepository.findById(id).orElseThrow(() -> new DiscussionNotExistException(id)); 151 disc.setLikes(this.discussionRepository.findDiscussionWithLikes(id).getLikes()); 152 return disc; 148 153 } 149 154
Note:
See TracChangeset
for help on using the changeset viewer.