@RequestMapping(value = "/{id}", method = RequestMethod.GET) @JsonView(View.PrincipalWithManyToOne.class) public ResponseEntity<Offender> get(@PathVariable Long id) { return Optional.ofNullable(repository.findOneByIdAndType(id, OffenderTypeEnum.TEACHER)) .map(offender -> new ResponseEntity<>(offender, HttpStatus.OK)) .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND)); }
@RequestMapping(value = "", method = RequestMethod.GET) @JsonView(View.PrincipalWithManyToOne.class) public ResponseEntity<List<Offender>> getAll() { return ResponseEntity.ok().body(repository.findByType(OffenderTypeEnum.TEACHER)); }