Last change
on this file was fc7ec52, checked in by darkopopovski <darkopopovski39@…>, 2 years ago |
all files
|
-
Property mode
set to
100644
|
File size:
990 bytes
|
Line | |
---|
1 |
|
---|
2 | package com.example.demo.controller.Rest;
|
---|
3 |
|
---|
4 | import com.example.demo.model.Movie;
|
---|
5 | import com.example.demo.model.dto.MovieDto;
|
---|
6 | import com.example.demo.service.MovieService;
|
---|
7 | import org.springframework.http.ResponseEntity;
|
---|
8 | import org.springframework.web.bind.annotation.*;
|
---|
9 |
|
---|
10 | import java.util.List;
|
---|
11 |
|
---|
12 | @CrossOrigin(origins = "http://localhost:3000")
|
---|
13 | @RequestMapping("/api/movies")
|
---|
14 | public class MovieRestController {
|
---|
15 | private final com.example.demo.service.MovieService MovieService;
|
---|
16 |
|
---|
17 | public MovieRestController(MovieService MovieService) {
|
---|
18 | this.MovieService = MovieService;
|
---|
19 | }
|
---|
20 |
|
---|
21 | @GetMapping
|
---|
22 | private List<Movie> findAll() {
|
---|
23 | return this.MovieService.findAll();
|
---|
24 | }
|
---|
25 |
|
---|
26 | @GetMapping("/{movie_id}")
|
---|
27 | public ResponseEntity<Movie> findById(@PathVariable Integer movie_id) {
|
---|
28 | return this.MovieService.findById(movie_id)
|
---|
29 | .map(movie -> ResponseEntity.ok().body(movie))
|
---|
30 | .orElseGet(() -> ResponseEntity.notFound().build());
|
---|
31 | }
|
---|
32 |
|
---|
33 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.