view spring-boot-playground/src/main/java/de/comline/spring/controller/MovieController.java @ 13:a633d0623278

Die Sequenz startet bei 1 und wird auch nur um 1 erhoeht
author Dirk Olmes <dirk.olmes@codedo.de>
date Fri, 14 Aug 2020 08:13:57 +0200
parents d57d0c6a841b
children
line wrap: on
line source

package de.comline.spring.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import de.comline.spring.service.MovieService;

@RestController
public class MovieController {
	@Autowired
	private MovieService service;
	
	@GetMapping("/movies")
	public String getMovies() {
		return service.listAllMovies();
	}

	@PostMapping("/movie/{title}")
	public String createMovie(@PathVariable(name = "title") String title) {
		service.createMovie(title);
		return "Successfully created movie " + title + ".\n";
	}
}