-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathCommentController.java
More file actions
44 lines (35 loc) · 1.35 KB
/
CommentController.java
File metadata and controls
44 lines (35 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.example.VideoStreamingPlatform.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.example.VideoStreamingPlatform.Entity.CommentEntity;
import com.example.VideoStreamingPlatform.Service.CommentService;
@Controller
public class CommentController {
@Autowired
CommentService cs;
@GetMapping("/api/add/Comment/form")
public String displayCommentForm(Model m) {
CommentEntity comment = new CommentEntity();
m.addAttribute("comment", comment);
return "DisplayCommentForm";
}
@PostMapping("/api/add/Comment")
public String addComment(CommentEntity comment, @RequestParam("video") int video_id, @RequestParam("user") int user_id) {
cs.addComment(comment, video_id, user_id);
return "redirect:/homepage";
}
//Remove COmment
@GetMapping("/api/remove/Comment/form")
public String removeCommentForm() {
return "RemoveCommentForm";
}
@PostMapping("/api/remove/Comment/user")
public String removeLikes(@RequestParam("video") int video, @RequestParam("user") int user) {
cs.removeComment(video, user);
return "redirect:/homepage";
}
}