Proper wrapping for events custom responses

master
esensar 2017-06-18 18:24:42 +02:00
parent f8afdf1e6d
commit 78cafe0f1a
1 changed files with 6 additions and 2 deletions

View File

@ -61,14 +61,18 @@ public class EventController {
@RequestMapping(path = "/events", method = RequestMethod.GET)
public ResponseEntity<?> getEventsById(@RequestParam(required = false) Long typeId) {
Iterable<Event> result;
if(typeId == null) {
if (typeId == null) {
result = repository.findAll();
} else {
result = repository.findByEventTypeId(typeId);
}
return ResponseEntity
.status(HttpStatus.OK)
.body(new Object() { public Object _embedded = result;});
.body(new Object() {
public Object _embedded = new Object() {
public Object events = result;
};
});
}
}