Procházet zdrojové kódy

refactored forumService - added getters and setters for comments list and commentsRepository

Tyler před 5 roky
rodič
revize
63707cff71

+ 18
- 1
src/main/java/com/tyler/motivateme/service/ForumService.java Zobrazit soubor

@@ -14,8 +14,9 @@ public class ForumService {
14 14
     @Autowired
15 15
     private CommentRepository commentRepository;
16 16
 
17
+    private List<Comment> comments = new ArrayList<>();
18
+
17 19
     public List<Comment> allMessages() {
18
-        List<Comment> comments = new ArrayList<>();
19 20
         commentRepository.findAll()
20 21
                 .forEach(comments::add);
21 22
         return comments;
@@ -38,4 +39,20 @@ public class ForumService {
38 39
     public void deleteComment(Comment commentID) {
39 40
         commentRepository.delete(commentID);
40 41
     }
42
+
43
+    public CommentRepository getCommentRepository() {
44
+        return commentRepository;
45
+    }
46
+
47
+    public void setCommentRepository(CommentRepository commentRepository) {
48
+        this.commentRepository = commentRepository;
49
+    }
50
+
51
+    public List<Comment> getComments() {
52
+        return comments;
53
+    }
54
+
55
+    public void setComments(List<Comment> comments) {
56
+        this.comments = comments;
57
+    }
41 58
 }