source: Git/src/main/java/com/wediscussmovies/project/web/controller/rest/GenreRestController.java@ 3c0f9a9

main
Last change on this file since 3c0f9a9 was 3c0f9a9, checked in by Petar Partaloski <ppartaloski@…>, 2 years ago

Added genre liking, fixed counter, improved paging, improved searches

  • Property mode set to 100644
File size: 1.3 KB
Line 
1package com.wediscussmovies.project.web.controller.rest;
2
3import com.wediscussmovies.project.service.DiscussionService;
4import com.wediscussmovies.project.service.GenreService;
5import org.springframework.http.ResponseEntity;
6import org.springframework.web.bind.annotation.*;
7
8@RestController
9@RequestMapping("api/genres")
10public class GenreRestController {
11 private final GenreService genreService;
12
13 public GenreRestController(GenreService genreService) {
14 this.genreService = genreService;
15 }
16
17 @GetMapping("/like/{genreId}")
18 public ResponseEntity likeGenre(@PathVariable Integer genreId, @RequestParam Integer userId){
19 try {
20 this.genreService.likeGenre(genreId,userId);
21 return ResponseEntity.ok(true);
22 }
23 catch (RuntimeException exception){
24 return ResponseEntity.ok(false);
25 }
26 }
27 @GetMapping("/unlike/{genreId}")
28 public ResponseEntity unlikeGenre (@PathVariable Integer genreId, @RequestParam Integer userId){
29 try {
30 this.genreService.unlikeGenre(genreId,userId);
31 return ResponseEntity.ok(true);
32 }
33 catch (RuntimeException exception){
34 System.out.println(exception.getMessage());
35 return ResponseEntity.ok(false);
36 }
37 }
38}
Note: See TracBrowser for help on using the repository browser.