Class OrderController

java.lang.Object
com.mt.ecommerce.product.controller.OrderController

@RestController @RequestMapping("/order") public class OrderController extends Object
Controller for managing orders. Provides endpoints for adding, updating, and retrieving orders.
  • Constructor Details

    • OrderController

      public OrderController(OrderService orderService)
  • Method Details

    • getVendorOrder

      @PreAuthorize("hasAnyAuthority(\'ROLE_VENDOR\', \'ROLE_ADMIN\')") @GetMapping(value="/vendor", produces="application/json") public List<OrderBO> getVendorOrder(@RequestParam(name="vendorId") String vendorId, @RequestParam(name="pageNo",defaultValue="0") int pageNo, @RequestParam(name="size",defaultValue="10") int size)
      Endpoint to retrieve orders for a specific vendor. Accessible by users with ROLE_VENDOR or ROLE_ADMIN.
      Parameters:
      vendorId - the ID of the vendor whose orders are to be retrieved
      pageNo - the page number for pagination (default is 0)
      size - the number of records per page (default is 10)
      Returns:
      a list of OrderBO objects representing the vendor's orders
    • getUserOrder

      @PreAuthorize("hasAnyAuthority(\'ROLE_USER\')") @GetMapping(value="/user", produces="application/json") public List<OrderBO> getUserOrder(@AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails userDetails, @RequestParam(name="pageNo",defaultValue="0") int pageNo, @RequestParam(name="size",defaultValue="10") int size)
      Endpoint to retrieve orders for the authenticated user. Accessible by users with ROLE_USER.
      Parameters:
      userDetails - the authenticated user's details
      pageNo - the page number for pagination (default is 0)
      size - the number of records per page (default is 10)
      Returns:
      a list of OrderBO objects representing the user's orders
    • updateOrderStatus

      @PreAuthorize("hasAnyAuthority(\'ROLE_VENDOR\', \'ROLE_ADMIN\')") @PutMapping("") public void updateOrderStatus(@RequestParam(name="orderId") String orderId, @RequestParam(name="status") String status)
      Endpoint to update the status of an order. Accessible by users with ROLE_VENDOR or ROLE_ADMIN.
      Parameters:
      orderId - the ID of the order to be updated
      status - the new status for the order
    • addOrder

      @PreAuthorize("hasAnyAuthority(\'ROLE_USER\', \'ROLE_VENDOR\')") @PostMapping(value="", consumes="application/json") public void addOrder(@RequestParam(name="vendor") UUID vendorID, @RequestBody OrderBO orderBO, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails userDetails)
      Endpoint to add a new order. Accessible by users with ROLE_USER or ROLE_VENDOR.
      Parameters:
      vendorID - the ID of the vendor for whom the order is being placed
      orderBO - the order details
      userDetails - the authenticated user's details