source: Git/src/main/java/com/wediscussmovies/project/web/controller/rest/ReplyRestController.java@ 5b447b0

main
Last change on this file since 5b447b0 was 5b447b0, checked in by Test <matonikolov77@…>, 2 years ago

Adding models and resources

  • Property mode set to 100644
File size: 1.7 KB
Line 
1package com.wediscussmovies.project.web.controller.rest;
2
3import com.wediscussmovies.project.model.primarykeys.ReplyPK;
4import com.wediscussmovies.project.service.ReplyService;
5import org.springframework.http.ResponseEntity;
6import org.springframework.web.bind.annotation.*;
7
8@RestController
9@RequestMapping("api/replies")
10public class ReplyRestController {
11
12 private final ReplyService replyService;
13
14 public ReplyRestController(ReplyService replyService) {
15 this.replyService = replyService;
16 }
17
18 @PostMapping("/delete/{discussionId}")
19 public ResponseEntity deleteById(@RequestParam Integer replyId,@PathVariable Integer discussionId){
20 try {
21 this.replyService.delete(discussionId,replyId);
22 return ResponseEntity.ok(true);
23 }
24 catch (RuntimeException exception){
25 return ResponseEntity.ok(false);
26
27 }
28 }
29 @GetMapping("/like/{replyId}")
30 public ResponseEntity likeReply(@PathVariable Integer replyId,
31 @RequestParam Integer userId){
32 try {
33 this.replyService.likeReply(replyId,userId);
34 return ResponseEntity.ok(true);
35 }
36 catch (RuntimeException exception){
37 return ResponseEntity.ok(false);
38 }
39 }
40 @GetMapping("/unlike/{replyId}")
41 public ResponseEntity unlikeReply(@PathVariable Integer replyId,
42 @RequestParam Integer userId){
43 try {
44 this.replyService.unlikeReply(replyId,userId);
45 return ResponseEntity.ok(true);
46 }
47 catch (RuntimeException exception){
48 return ResponseEntity.ok(false);
49 }
50 }
51}
Note: See TracBrowser for help on using the repository browser.