소스 검색

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

Tyler 5 년 전
부모
커밋
63707cff71
1개의 변경된 파일18개의 추가작업 그리고 1개의 파일을 삭제
  1. 18
    1
      src/main/java/com/tyler/motivateme/service/ForumService.java

+ 18
- 1
src/main/java/com/tyler/motivateme/service/ForumService.java 파일 보기

@@ -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
 }