Proper wrapping for events custom responses
parent
f8afdf1e6d
commit
78cafe0f1a
|
@ -61,14 +61,18 @@ public class EventController {
|
||||||
@RequestMapping(path = "/events", method = RequestMethod.GET)
|
@RequestMapping(path = "/events", method = RequestMethod.GET)
|
||||||
public ResponseEntity<?> getEventsById(@RequestParam(required = false) Long typeId) {
|
public ResponseEntity<?> getEventsById(@RequestParam(required = false) Long typeId) {
|
||||||
Iterable<Event> result;
|
Iterable<Event> result;
|
||||||
if(typeId == null) {
|
if (typeId == null) {
|
||||||
result = repository.findAll();
|
result = repository.findAll();
|
||||||
} else {
|
} else {
|
||||||
result = repository.findByEventTypeId(typeId);
|
result = repository.findByEventTypeId(typeId);
|
||||||
}
|
}
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.status(HttpStatus.OK)
|
.status(HttpStatus.OK)
|
||||||
.body(new Object() { public Object _embedded = result;});
|
.body(new Object() {
|
||||||
|
public Object _embedded = new Object() {
|
||||||
|
public Object events = result;
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue