|
@@ -1,29 +1,41 @@
|
1
|
1
|
package com.tyler.motivateme.service;
|
2
|
2
|
|
3
|
|
-import net.anthavio.disquo.api.DisqusApi;
|
4
|
|
-import net.anthavio.disquo.api.DisqusApplicationKeys;
|
5
|
|
-import net.anthavio.disquo.api.response.DisqusPost;
|
6
|
|
-import net.anthavio.disquo.api.response.DisqusResponse;
|
|
3
|
+import com.tyler.motivateme.model.Comment;
|
|
4
|
+import com.tyler.motivateme.repository.CommentRepository;
|
|
5
|
+import org.springframework.beans.factory.annotation.Autowired;
|
7
|
6
|
import org.springframework.stereotype.Service;
|
8
|
7
|
|
|
8
|
+import java.util.ArrayList;
|
9
|
9
|
import java.util.List;
|
10
|
10
|
|
11
|
11
|
@Service
|
12
|
12
|
public class ForumService {
|
13
|
|
- DisqusApplicationKeys keys = new DisqusApplicationKeys("...api_key...", "...secret_key...");
|
14
|
|
- DisqusApi disqus = new DisqusApi(keys);
|
15
|
|
- private int forumID;
|
16
|
13
|
|
|
14
|
+ @Autowired
|
|
15
|
+ private CommentRepository commentRepository;
|
17
|
16
|
|
18
|
|
- public ForumService (int forumID) {
|
19
|
|
- this.forumID = forumID;
|
|
17
|
+ public List<Comment> allMessages() {
|
|
18
|
+ List<Comment> comments = new ArrayList<>();
|
|
19
|
+ commentRepository.findAll()
|
|
20
|
+ .forEach(comments::add);
|
|
21
|
+ return comments;
|
20
|
22
|
}
|
21
|
23
|
|
22
|
|
- public void postComment(int forumID){
|
23
|
|
- disqus.forums();
|
|
24
|
+ public void getAllMessages(Integer id){
|
|
25
|
+ commentRepository.findById(id);
|
24
|
26
|
}
|
25
|
27
|
|
26
|
|
- public void updateComment(int commentID) {}
|
27
|
28
|
|
28
|
|
- public void deleteComment(int commentID) {}
|
|
29
|
+ public void postComment(Comment forumID){
|
|
30
|
+
|
|
31
|
+ commentRepository.save(forumID);
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ public void updateComment(Comment commentID) {
|
|
35
|
+ commentRepository.save(commentID);
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+ public void deleteComment(Comment commentID) {
|
|
39
|
+ commentRepository.delete(commentID);
|
|
40
|
+ }
|
29
|
41
|
}
|