add order history to profile
This commit is contained in:
@@ -3,6 +3,7 @@ package com.petshop.backend.controller;
|
||||
import com.petshop.backend.dto.sale.SaleRequest;
|
||||
import com.petshop.backend.dto.sale.SaleResponse;
|
||||
import com.petshop.backend.service.SaleService;
|
||||
import com.petshop.backend.util.AuthenticationHelper;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -21,6 +22,13 @@ public class SaleController {
|
||||
this.saleService = saleService;
|
||||
}
|
||||
|
||||
@GetMapping("/my")
|
||||
@PreAuthorize("hasAnyRole('CUSTOMER', 'ADMIN')")
|
||||
public ResponseEntity<Page<SaleResponse>> getMyOrders(Pageable pageable) {
|
||||
Long userId = AuthenticationHelper.getAuthenticatedUserId();
|
||||
return ResponseEntity.ok(saleService.getAllSales(null, null, null, false, userId, pageable));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAnyRole('STAFF', 'ADMIN')")
|
||||
public ResponseEntity<Page<SaleResponse>> getAllSales(
|
||||
|
||||
Reference in New Issue
Block a user