Add create function
This commit is contained in:
parent
398bf16d56
commit
762bb8b97f
1 changed files with 10 additions and 1 deletions
|
@ -2,9 +2,13 @@ package ru.redrise.marinesco.library.api;
|
||||||
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import ru.redrise.marinesco.data.GenreRepository;
|
import ru.redrise.marinesco.data.GenreRepository;
|
||||||
|
@ -29,5 +33,10 @@ public class GenresApiController {
|
||||||
return genreRepository.findAll(pageRequest).getContent();
|
return genreRepository.findAll(pageRequest).getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(consumes = "application/json")
|
||||||
|
@ResponseStatus(HttpStatus.CREATED)
|
||||||
|
public Genre postGenre(@RequestBody Genre genre) {
|
||||||
|
return genreRepository.save(genre);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue