Add create function

master
Dmitry Isaenko 2024-01-27 22:49:17 +03:00
parent 398bf16d56
commit 762bb8b97f
1 changed files with 10 additions and 1 deletions

View File

@ -2,9 +2,13 @@ package ru.redrise.marinesco.library.api;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import ru.redrise.marinesco.data.GenreRepository;
@ -29,5 +33,10 @@ public class GenresApiController {
return genreRepository.findAll(pageRequest).getContent();
}
@PostMapping(consumes = "application/json")
@ResponseStatus(HttpStatus.CREATED)
public Genre postGenre(@RequestBody Genre genre) {
return genreRepository.save(genre);
}
}