-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovieController.java
33 lines (28 loc) · 1.19 KB
/
MovieController.java
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
package com.example.moviesweb;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.web.ReactiveOffsetScrollPositionHandlerMethodArgumentResolver;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
@RestController
@RequestMapping("/api/movies")
@CrossOrigin
public class MovieController {
@Autowired
private MovieService movieService;
@GetMapping
public ResponseEntity<List<Movie>> getAllMovies(){
return new ResponseEntity<List<Movie>>(movieService.allMovies(),HttpStatus.OK);
}
// @GetMapping("/{id}")
// public ResponseEntity<Optional<Movie>> getSingleMovie(@PathVariable ObjectId id){
// return new ResponseEntity<Optional<Movie>>(movieService.singleMovie(id),HttpStatus.OK);
// }
@GetMapping("/{imdbId}")
public ResponseEntity<Optional<Movie>> getMovieByImdbId(@PathVariable String imdbId){
return new ResponseEntity<Optional<Movie>>(movieService.singleMovieByImdbId(imdbId), HttpStatus.OK);
}
}