add order history to profile

This commit is contained in:
2026-04-16 00:38:10 -06:00
parent 26791de867
commit 4d6166a882
3 changed files with 129 additions and 1 deletions

View File

@@ -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(