Pattern: in-memory storage
- No database needed for A1 — a map in memory is enough:
@RestController
@RequestMapping("/api/employees")
public class EmployeeController {
private final Map<Long, Employee> storage = new HashMap<>();
private final AtomicLong ids = new AtomicLong(1);
@GetMapping
public List<Employee> getAll() {
return new ArrayList<>(storage.values());
}
}
- Lab example uses
employees — your A1 resource is different, adapt it
- One controller class is fine for A1; layered architecture comes later