@RequestMapping( method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE}) public Note create(@RequestBody Note note) { if ("Ошибка".equals(note.getTitle())) throw new BadTitleException(); return noteRepository.save(note); }
@RequestMapping( method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) public List<Note> readAll() { return noteRepository.findAll(); }