-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathLikeController.java
More file actions
44 lines (35 loc) · 1.26 KB
/
LikeController.java
File metadata and controls
44 lines (35 loc) · 1.26 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.LikeEntity;
import com.example.VideoStreamingPlatform.Service.LikeService;
@Controller
public class LikeController {
@Autowired
LikeService ls;
@GetMapping("/api/add/likes")
public String displayLikeForm(Model m) {
LikeEntity like = new LikeEntity();
m.addAttribute("like", like);
return "LikeForm";
}
@PostMapping("/api/add/likes/form")
public String addLike(@RequestParam("video") int video, @RequestParam("user") int user, LikeEntity like) {
ls.addLike(like, video, user);
return "redirect:/homepage";
}
//Delete Like
@GetMapping("/api/remove/likes")
public String removeLikeForm() {
return "RemoveLikeForm";
}
@PostMapping("/api/remove/likes/user")
public String removeLikes(@RequestParam("video") int video, @RequestParam("user") int user) {
ls.removeLike(video, user);
return "redirect:/homepage";
}
}