27 lines
783 B
Java
27 lines
783 B
Java
package com.example.eatgo.interfaces;
|
|
|
|
import com.example.eatgo.domain.Restaurant;
|
|
import com.example.eatgo.domain.RestaurantRepository;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Scanner;
|
|
|
|
@RestController
|
|
public class RestaurantController {
|
|
|
|
private final RestaurantRepository repository = new RestaurantRepository();
|
|
|
|
@GetMapping("/restaurants")
|
|
public List<Restaurant> list() {
|
|
return repository.findAll();
|
|
}
|
|
@GetMapping("restaurants/{id}")
|
|
public Restaurant detail(@PathVariable Long id) {
|
|
return repository.findById(id);
|
|
}
|
|
}
|