source: source/MovieZilla-master/src/main/java/com/example/demo/controller/Rest/MovieRestController.java

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
2package com.example.demo.controller.Rest;
3
4import com.example.demo.model.Movie;
5import com.example.demo.model.dto.MovieDto;
6import com.example.demo.service.MovieService;
7import org.springframework.http.ResponseEntity;
8import org.springframework.web.bind.annotation.*;
9
10import java.util.List;
11
12@CrossOrigin(origins = "http://localhost:3000")
13@RequestMapping("/api/movies")
14public 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.