Class OrderController
java.lang.Object
com.mt.ecommerce.product.controller.OrderController
Controller for managing orders.
Provides endpoints for adding, updating, and retrieving orders.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOrder
(UUID vendorID, OrderBO orderBO, org.springframework.security.core.userdetails.UserDetails userDetails) Endpoint to add a new order.getUserOrder
(org.springframework.security.core.userdetails.UserDetails userDetails, int pageNo, int size) Endpoint to retrieve orders for the authenticated user.getVendorOrder
(String vendorId, int pageNo, int size) Endpoint to retrieve orders for a specific vendor.void
updateOrderStatus
(String orderId, String status) Endpoint to update the status of an order.
-
Constructor Details
-
OrderController
-
-
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 retrievedpageNo
- 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 detailspageNo
- 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 updatedstatus
- 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 placedorderBO
- the order detailsuserDetails
- the authenticated user's details
-