package com.faf223.expensetrackerfaf.controller; import com.faf223.expensetrackerfaf.model.Expense; import com.faf223.expensetrackerfaf.service.ExpenseService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController @RequestMapping("/expenses") public class ExpenseController { private final ExpenseService expenseService; @Autowired public ExpenseController(ExpenseService expenseService) { this.expenseService = expenseService; } @GetMapping("/user/{userUuid}") public ResponseEntity> getExpensesByUser(@PathVariable String userUuid) { List expenses = expenseService.getExpensesByUserId(userUuid); if (!expenses.isEmpty()) { return ResponseEntity.ok(expenses); } else { return ResponseEntity.notFound().build(); } } }