- @GetMapping("/orders/{id}")
- public EntityModel<Order> order(@PathVariable(value = "id", required = true) Long id) {
+ @PutMapping("/{id}")
+ public EntityModel<Order> update(@PathVariable(value = "id", required = true) Long id, Order order) {
+ Link selfLink = actions(order);
+ return EntityModel.of(order, selfLink);
+ }
+
+ private Link actions(Order order) {
+ return linkTo(methodOn(OrderController.class).order(order.getId())).withSelfRel()
+ .andAffordance(afford(methodOn(OrderController.class).update(order.getId(), null)))
+ .andAffordance(afford(methodOn(OrderController.class).delete(order.getId())))
+ .andAffordance(afford(methodOn(OrderController.class).changeStatus(order.getId(), null)));
+ }
+
+ @PutMapping("/{id}/status")
+ public EntityModel<Order> changeStatus(@PathVariable(value = "id", required = true) Long id, String status) {