задача 10(new)

This commit is contained in:
Elena 2018-11-23 14:05:23 +04:00
parent 51e84e22a6
commit 8fc6d3b569
2 changed files with 9 additions and 0 deletions

View File

@ -37,6 +37,11 @@ public class PaperController {
return new Response<>(paperService.findAllDto()); return new Response<>(paperService.findAllDto());
} }
@GetMapping("/{paper-id}")
public Response<PaperDto> getPaper(@PathVariable("paper-id") Integer paperId){
return new Response(paperService.findPaper(paperId));
}
@PostMapping @PostMapping
public Response<Integer> createPaper(@RequestBody @Valid PaperDto paperDto) throws IOException { public Response<Integer> createPaper(@RequestBody @Valid PaperDto paperDto) throws IOException {
return new Response<>(paperService.create(paperDto)); return new Response<>(paperService.create(paperDto));

View File

@ -130,6 +130,10 @@ public class PaperService {
return convert(paperRepository.filter(userService.findById(filterDto.getAuthorId()), filterDto.getYear()), PaperDto::new); return convert(paperRepository.filter(userService.findById(filterDto.getAuthorId()), filterDto.getYear()), PaperDto::new);
} }
public PaperDto findPaper(int id){
return new PaperDto(paperRepository.getOne(id));
}
public void closeFailedPapers() { public void closeFailedPapers() {
List<Paper> papers = paperRepository.findAll() List<Paper> papers = paperRepository.findAll()
.stream() .stream()