@RequestMapping(value = "/{orderId}/order", params = "status", method = RequestMethod.POST) ResponseEntity<Void> changeOrderStatus(@PathVariable Long orderId, @RequestParam String status) throws ResourceNotFoundException, IllegalArgumentException { LOGGER.info("Request to change status if order with id " + orderId); EOrderStatus orderStatus = EOrderStatus.valueOf(status); orderService.changeOrderStatus(orderId, orderStatus); return new ResponseEntity<>(HttpStatus.ACCEPTED); }
@RequestMapping( value = "/business/{businessID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Collection<OrderViewDTO>> getOrdersByBusinessId(@PathVariable Long businessID) throws ResourceNotFoundException { Collection<OrderViewDTO> businessOrders = orderService.fetchOrdersByBusinessID(businessID); LOGGER.info("Request for business orders.\nFetchedList size is " + businessOrders.size()); return new ResponseEntity<>(businessOrders, HttpStatus.OK); }
@RequestMapping( value = "/{orderID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<OrderViewDTO> getOrdersById(@PathVariable Long orderID) throws ResourceNotFoundException { LOGGER.info("Request for order with id " + orderID); OrderViewDTO orderView = orderService.fetchOrderById(orderID); return new ResponseEntity<>(orderView, HttpStatus.OK); }
@RequestMapping( value = "/business/{businessID}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Void> createOrder(@PathVariable Long businessID, @RequestBody OrderDTO orderDTO) throws ResourceNotFoundException { LOGGER.info("Request for order submit"); long orderID = orderService.submitOrder(businessID, orderDTO); URI location = URI.create(EDomainLinkProvider.INSTANCE.getLocationFor(EEntity.ORDER) + orderID); HttpHeaders headers = new HttpHeaders(); headers.setLocation(location); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
@RequestMapping( value = "/business/{businessID}/order", params = "status", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Collection<OrderViewDTO>> getOrdersByStatus( @PathVariable Long businessID, @RequestParam String status) throws ResourceNotFoundException, IllegalArgumentException { EOrderStatus orderStatus = EOrderStatus.valueOf(status); Collection<OrderViewDTO> businessOrders = orderService.fetchOrdersByStatus(businessID, orderStatus); LOGGER.info( "Request for business orders with status query.\nFetchedList size is " + businessOrders.size()); return new ResponseEntity<>(businessOrders, HttpStatus.OK); }