allOrders URL implementation

This commit is contained in:
Roshan Thomas 2016-04-15 00:13:17 -04:00
parent 17a72d00a3
commit c2d84ae1d2
1 changed files with 6 additions and 1 deletions

View File

@ -34,7 +34,12 @@ public class CustomerController {
@RequestMapping(value = "/customer/{customerId}/orders", method = RequestMethod.GET)
public List<Order> getOrdersForCustomer(@PathVariable final String customerId) {
return orderService.getAllOrdersForCustomer(customerId);
final List<Order> orders = orderService.getAllOrdersForCustomer(customerId);
for (final Order order : orders) {
final Link selfLink = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(CustomerController.class).getOrderById(customerId, order.getOrderId())).withSelfRel();
order.add(selfLink);
}
return orders;
}
@RequestMapping(value = "/customers", method = RequestMethod.GET)