Class OrderController


  • @RestController
    @RequestMapping("/orders")
    @ExposesResourceFor(Order.class)
    public class OrderController
    extends Object
    The OrderController class is the @RestController that maps the endpoints of "/orders" for communication between the server-side and client-side for Order.
    • Constructor Detail

      • OrderController

        public OrderController​(OrderService orderService)
        Constructs the instance of OrderService object.
        Parameters:
        orderService - The instance of OrderService to initialize.
    • Method Detail

      • getUserOrders

        @GetMapping(value="/user-orders",
                    produces="application/json")
        public List<Order> getUserOrders​(org.springframework.security.core.Authentication auth)
        The Get method which returns a list of the user's placed orders.
        Parameters:
        auth - The user authentication.
        Returns:
        A List of Order objects representing the user's placed orders.
      • getUserSoldOrders

        @GetMapping(value="/user-sold-orders",
                    produces="application/json")
        public List<Order> getUserSoldOrders​(org.springframework.security.core.Authentication auth)
        The Get method which returns a list of the orders the user is responsible for fulfilling.
        Parameters:
        auth - The user authentication.
        Returns:
        A List of Order objects representing the orders the user is responsible for fulfilling.
      • getOrder

        @GetMapping(value="/{orderId:\\d+}",
                    produces="application/json")
        public Order getOrder​(@PathVariable
                              long orderId)
        The Get method which returns an order by the order ID.
        Parameters:
        orderId - The ID of the Order object requested.
        Returns:
        The Order object with the ID requested.
      • post

        @PostMapping(consumes={"application/json","text/plain"},
                     produces={"application/json","text/plain"})
        public Order post​(@RequestBody
                          Order order,
                          Product product,
                          org.springframework.security.core.Authentication auth)
        The Post method for creating an order.
        Parameters:
        order - The Order to be created.
        product - The Product on the order.
        auth - The authorization for the user.
        Returns:
        The Order object that was created.